Cython: mutiple_algos.pyx

Generated by Cython 0.29.20

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

Raw output: mutiple_algos.c

    +001: import math

      __pyx_t_1 = __Pyx_Import(__pyx_n_s_math, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_math, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /* … */
      __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +002: import numpy as np

      __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 2, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     003: from libc.math cimport sqrt

     004:

     005: cimport numpy as np

     006: cimport cython

     007: cimport cost_function_multiple

     008:

     009: from cost_function_multiple cimport mll_mean, mbic_mean, order_vec

     010: from cython.parallel import prange

     011:

    +012: DTYPE = np.float64

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    +013: ITYPE = np.int64

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_ITYPE, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    +014: ctypedef np.float64_t DTYPE_t

    typedef __pyx_t_5numpy_float64_t __pyx_t_14pychangepoints_12multiple_dim_DTYPE_t;

     015: ctypedef np.int64_t ITYPE_t

     016:

     017:

     018:

     019: @cython.wraparound(False)

     020: @cython.boundscheck(False)

    +021: def cbin_seg_multiple(np.ndarray[DTYPE_t, ndim=3] sumstat, ITYPE_t Q, ITYPE_t minseglen, str method):

    /* Python wrapper */
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_1cbin_seg_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_14pychangepoints_12multiple_dim_1cbin_seg_multiple = {"cbin_seg_multiple", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_12multiple_dim_1cbin_seg_multiple, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_1cbin_seg_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_sumstat = 0;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_Q;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_minseglen;
      PyObject *__pyx_v_method = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cbin_seg_multiple (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_Q,&__pyx_n_s_minseglen,&__pyx_n_s_method,0};
        PyObject* values[4] = {0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cbin_seg_multiple", 1, 4, 4, 1); __PYX_ERR(0, 21, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minseglen)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cbin_seg_multiple", 1, 4, 4, 2); __PYX_ERR(0, 21, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cbin_seg_multiple", 1, 4, 4, 3); __PYX_ERR(0, 21, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cbin_seg_multiple") < 0)) __PYX_ERR(0, 21, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
        }
        __pyx_v_sumstat = ((PyArrayObject *)values[0]);
        __pyx_v_Q = __Pyx_PyInt_As_npy_int64(values[1]); if (unlikely((__pyx_v_Q == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
        __pyx_v_minseglen = __Pyx_PyInt_As_npy_int64(values[2]); if (unlikely((__pyx_v_minseglen == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
        __pyx_v_method = ((PyObject*)values[3]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("cbin_seg_multiple", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 21, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cbin_seg_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 21, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 21, __pyx_L1_error)
      __pyx_r = __pyx_pf_14pychangepoints_12multiple_dim_cbin_seg_multiple(__pyx_self, __pyx_v_sumstat, __pyx_v_Q, __pyx_v_minseglen, __pyx_v_method);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

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

    static PyObject *__pyx_pf_14pychangepoints_12multiple_dim_cbin_seg_multiple(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_Q, __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_minseglen, PyObject *__pyx_v_method) {
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_n;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_dim;
      PyArrayObject *__pyx_v_cptsout = 0;
      __Pyx_memviewslice __pyx_v_likeout = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_lambda_ = { 0, 0, { 0 }, { 0 }, { 0 } };
      PyArrayObject *__pyx_v_tau_ = 0;
      double __pyx_v_null;
      double __pyx_v_res_lamb;
      double __pyx_v_oldmax;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_q;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_i;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_j;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_st;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_end;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_dim_;
      __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t);
      PyObject *__pyx_v_max_out = NULL;
      PyObject *__pyx_v_whichout = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_cptsout;
      __Pyx_Buffer __pyx_pybuffer_cptsout;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat;
      __Pyx_Buffer __pyx_pybuffer_sumstat;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_tau_;
      __Pyx_Buffer __pyx_pybuffer_tau_;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cbin_seg_multiple", 0);
      __pyx_pybuffer_cptsout.pybuffer.buf = NULL;
      __pyx_pybuffer_cptsout.refcount = 0;
      __pyx_pybuffernd_cptsout.data = NULL;
      __pyx_pybuffernd_cptsout.rcbuffer = &__pyx_pybuffer_cptsout;
      __pyx_pybuffer_tau_.pybuffer.buf = NULL;
      __pyx_pybuffer_tau_.refcount = 0;
      __pyx_pybuffernd_tau_.data = NULL;
      __pyx_pybuffernd_tau_.rcbuffer = &__pyx_pybuffer_tau_;
      __pyx_pybuffer_sumstat.pybuffer.buf = NULL;
      __pyx_pybuffer_sumstat.refcount = 0;
      __pyx_pybuffernd_sumstat.data = NULL;
      __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 21, __pyx_L1_error)
      }
      __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sumstat.diminfo[1].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sumstat.diminfo[1].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_sumstat.diminfo[2].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_sumstat.diminfo[2].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[2];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cbin_seg_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_cptsout);
      __PYX_XDEC_MEMVIEW(&__pyx_v_likeout, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_lambda_, 1);
      __Pyx_XDECREF((PyObject *)__pyx_v_tau_);
      __Pyx_XDECREF(__pyx_v_max_out);
      __Pyx_XDECREF(__pyx_v_whichout);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__27 = PyTuple_Pack(24, __pyx_n_s_sumstat, __pyx_n_s_Q, __pyx_n_s_minseglen, __pyx_n_s_method, __pyx_n_s_n, __pyx_n_s_dim, __pyx_n_s_cptsout, __pyx_n_s_likeout, __pyx_n_s_op_cps, __pyx_n_s_lambda, __pyx_n_s_tau, __pyx_n_s_null, __pyx_n_s_res_lamb, __pyx_n_s_oldmax, __pyx_n_s_q, __pyx_n_s_p, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_st, __pyx_n_s_end, __pyx_n_s_dim_2, __pyx_n_s_current_cost, __pyx_n_s_max_out, __pyx_n_s_whichout); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__27);
      __Pyx_GIVEREF(__pyx_tuple__27);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_12multiple_dim_1cbin_seg_multiple, NULL, __pyx_n_s_pychangepoints_multiple_dim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_cbin_seg_multiple, __pyx_t_1) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(4, 0, 24, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_mutiple_algos_pyx, __pyx_n_s_cbin_seg_multiple, 21, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) __PYX_ERR(0, 21, __pyx_L1_error)

    +022:     cdef ITYPE_t n = sumstat.shape[0] - 1

      __pyx_v_n = ((__pyx_v_sumstat->dimensions[0]) - 1);

    +023:     cdef ITYPE_t dim = sumstat.shape[2]

      __pyx_v_dim = (__pyx_v_sumstat->dimensions[2]);

    +024:     cdef np.ndarray[ITYPE_t, ndim=1] cptsout = np.zeros(Q, dtype=np.int64)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_int64); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 24, __pyx_L1_error)
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cptsout.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_cptsout = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 24, __pyx_L1_error)
        } else {__pyx_pybuffernd_cptsout.diminfo[0].strides = __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cptsout.diminfo[0].shape = __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_cptsout = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

    +025:     cdef double [:] likeout = np.zeros(Q)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_likeout = __pyx_t_7;
      __pyx_t_7.memview = NULL;
      __pyx_t_7.data = NULL;

     026:     cdef ITYPE_t op_cps

    +027:     cdef double [:] lambda_ = np.zeros(n)

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_5, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_lambda_ = __pyx_t_7;
      __pyx_t_7.memview = NULL;
      __pyx_t_7.data = NULL;

    +028:     cdef np.ndarray[ITYPE_t, ndim=1] tau_ = np.zeros(Q+2).astype(np.int64)

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_npy_int64((__pyx_v_Q + 2)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_astype); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_2, function);
        }
      }
      __pyx_t_5 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 28, __pyx_L1_error)
      __pyx_t_8 = ((PyArrayObject *)__pyx_t_5);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tau_.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
          __pyx_v_tau_ = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 28, __pyx_L1_error)
        } else {__pyx_pybuffernd_tau_.diminfo[0].strides = __pyx_pybuffernd_tau_.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tau_.diminfo[0].shape = __pyx_pybuffernd_tau_.rcbuffer->pybuffer.shape[0];
        }
      }
      __pyx_t_8 = 0;
      __pyx_v_tau_ = ((PyArrayObject *)__pyx_t_5);
      __pyx_t_5 = 0;

    +029:     tau_[0] = 0

      __pyx_t_9 = 0;
      *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_tau_.diminfo[0].strides) = 0;

    +030:     tau_[1] = n

      __pyx_t_10 = 1;
      *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_tau_.diminfo[0].strides) = __pyx_v_n;

     031:     cdef double null, res_lamb

    +032:     cdef double oldmax = np.inf

      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_inf); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_oldmax = __pyx_t_11;

     033:     cdef ITYPE_t q, p, i, j, st, end, dim_

     034:

    +035:     if method == "mll_mean":

      __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 35, __pyx_L1_error)
      __pyx_t_13 = (__pyx_t_12 != 0);
      if (__pyx_t_13) {
    /* … */
        goto __pyx_L3;
      }

    +036:         current_cost = mll_mean

        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mll_mean;

     037:     else:

    +038:         current_cost = mbic_mean

      /*else*/ {
        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mbic_mean;
      }
      __pyx_L3:;

     039:

    +040:     for q in range(Q):

      __pyx_t_14 = __pyx_v_Q;
      __pyx_t_15 = __pyx_t_14;
      for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_15; __pyx_t_16+=1) {
        __pyx_v_q = __pyx_t_16;

    +041:         lambda_= np.zeros(n)

        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 41, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 41, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 41, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 41, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_t_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 41, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __PYX_XDEC_MEMVIEW(&__pyx_v_lambda_, 1);
        __pyx_v_lambda_ = __pyx_t_7;
        __pyx_t_7.memview = NULL;
        __pyx_t_7.data = NULL;

    +042:         i = 1

        __pyx_v_i = 1;

    +043:         st = tau_[0]+1

        __pyx_t_17 = 0;
        __pyx_v_st = ((*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_tau_.diminfo[0].strides)) + 1);

    +044:         end = tau_[1]

        __pyx_t_17 = 1;
        __pyx_v_end = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_17, __pyx_pybuffernd_tau_.diminfo[0].strides));

    +045:         null = 0

        __pyx_v_null = 0.0;

    +046:         for dim_ in range(0, dim):

        __pyx_t_18 = __pyx_v_dim;
        __pyx_t_19 = __pyx_t_18;
        for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
          __pyx_v_dim_ = __pyx_t_20;

    +047:             null += (-0.5)*current_cost(sumstat[end, 0, dim_]-sumstat[st-1, 0, dim_], sumstat[end, 1, dim_]-sumstat[st-1, 1, dim_], sumstat[end, 2, dim_]-sumstat[st-1, 2, dim_], end - st + 1, dim)

          __pyx_t_21 = __pyx_v_end;
          __pyx_t_17 = 0;
          __pyx_t_22 = __pyx_v_dim_;
          __pyx_t_23 = (__pyx_v_st - 1);
          __pyx_t_24 = 0;
          __pyx_t_25 = __pyx_v_dim_;
          __pyx_t_26 = __pyx_v_end;
          __pyx_t_27 = 1;
          __pyx_t_28 = __pyx_v_dim_;
          __pyx_t_29 = (__pyx_v_st - 1);
          __pyx_t_30 = 1;
          __pyx_t_31 = __pyx_v_dim_;
          __pyx_t_32 = __pyx_v_end;
          __pyx_t_33 = 2;
          __pyx_t_34 = __pyx_v_dim_;
          __pyx_t_35 = (__pyx_v_st - 1);
          __pyx_t_36 = 2;
          __pyx_t_37 = __pyx_v_dim_;
          __pyx_v_null = (__pyx_v_null + (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_37, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((__pyx_v_end - __pyx_v_st) + 1), __pyx_v_dim)));
        }

    +048:         for j in range(2, n-2):

        __pyx_t_18 = (__pyx_v_n - 2);
        __pyx_t_19 = __pyx_t_18;
        for (__pyx_t_20 = 2; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
          __pyx_v_j = __pyx_t_20;

    +049:             if (j == end):

          __pyx_t_13 = ((__pyx_v_j == __pyx_v_end) != 0);
          if (__pyx_t_13) {
    /* … */
            goto __pyx_L10;
          }

    +050:                 st = end+1

            __pyx_v_st = (__pyx_v_end + 1);

    +051:                 i = i+1

            __pyx_v_i = (__pyx_v_i + 1);

    +052:                 end = tau_[i]

            __pyx_t_37 = __pyx_v_i;
            __pyx_v_end = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_37, __pyx_pybuffernd_tau_.diminfo[0].strides));

    +053:                 null = 0

            __pyx_v_null = 0.0;

    +054:                 for dim_ in range(0, dim):

            __pyx_t_37 = __pyx_v_dim;
            __pyx_t_35 = __pyx_t_37;
            for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_35; __pyx_t_34+=1) {
              __pyx_v_dim_ = __pyx_t_34;

    +055:                     null += (-0.5)*current_cost(sumstat[end, 0, dim_]-sumstat[st-1, 0, dim_], sumstat[end, 1, dim_]-sumstat[st-1, 1, dim_], sumstat[end, 2, dim_]-sumstat[st-1, 2, dim_], end - st + 1, dim)

              __pyx_t_32 = __pyx_v_end;
              __pyx_t_36 = 0;
              __pyx_t_31 = __pyx_v_dim_;
              __pyx_t_29 = (__pyx_v_st - 1);
              __pyx_t_33 = 0;
              __pyx_t_28 = __pyx_v_dim_;
              __pyx_t_26 = __pyx_v_end;
              __pyx_t_30 = 1;
              __pyx_t_25 = __pyx_v_dim_;
              __pyx_t_23 = (__pyx_v_st - 1);
              __pyx_t_27 = 1;
              __pyx_t_22 = __pyx_v_dim_;
              __pyx_t_21 = __pyx_v_end;
              __pyx_t_24 = 2;
              __pyx_t_38 = __pyx_v_dim_;
              __pyx_t_39 = (__pyx_v_st - 1);
              __pyx_t_17 = 2;
              __pyx_t_40 = __pyx_v_dim_;
              __pyx_v_null = (__pyx_v_null + (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_38, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_40, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((__pyx_v_end - __pyx_v_st) + 1), __pyx_v_dim)));
            }

     056:             else:

    +057:                 if (j-st >= minseglen) & (end-j >= minseglen):

          /*else*/ {
            __pyx_t_13 = ((((__pyx_v_j - __pyx_v_st) >= __pyx_v_minseglen) & ((__pyx_v_end - __pyx_v_j) >= __pyx_v_minseglen)) != 0);
            if (__pyx_t_13) {
    /* … */
            }
          }
          __pyx_L10:;
        }

    +058:                     res_lamb = 0

              __pyx_v_res_lamb = 0.0;

    +059:                     for dim_ in range(0, dim):

              __pyx_t_37 = __pyx_v_dim;
              __pyx_t_35 = __pyx_t_37;
              for (__pyx_t_34 = 0; __pyx_t_34 < __pyx_t_35; __pyx_t_34+=1) {
                __pyx_v_dim_ = __pyx_t_34;

    +060:                         res_lamb+=((-0.5)*current_cost(sumstat[j, 0, dim_]-sumstat[st-1, 0, dim_], sumstat[j, 1, dim_]-sumstat[st-1, 1, dim_], sumstat[j, 2, dim_]-sumstat[st-1, 2, dim_], j - st + 1, dim)) + ((-0.5)*current_cost(sumstat[end, 0, dim_]-sumstat[j, 0, dim_], sumstat[end, 1, dim_]-sumstat[j, 1, dim_], sumstat[end, 2, dim_]-sumstat[j, 2, dim_], end - j, dim)) - null

                __pyx_t_40 = __pyx_v_j;
                __pyx_t_17 = 0;
                __pyx_t_39 = __pyx_v_dim_;
                __pyx_t_38 = (__pyx_v_st - 1);
                __pyx_t_24 = 0;
                __pyx_t_21 = __pyx_v_dim_;
                __pyx_t_22 = __pyx_v_j;
                __pyx_t_27 = 1;
                __pyx_t_23 = __pyx_v_dim_;
                __pyx_t_25 = (__pyx_v_st - 1);
                __pyx_t_30 = 1;
                __pyx_t_26 = __pyx_v_dim_;
                __pyx_t_28 = __pyx_v_j;
                __pyx_t_33 = 2;
                __pyx_t_29 = __pyx_v_dim_;
                __pyx_t_31 = (__pyx_v_st - 1);
                __pyx_t_36 = 2;
                __pyx_t_32 = __pyx_v_dim_;
                __pyx_t_41 = __pyx_v_end;
                __pyx_t_42 = 0;
                __pyx_t_43 = __pyx_v_dim_;
                __pyx_t_44 = __pyx_v_j;
                __pyx_t_45 = 0;
                __pyx_t_46 = __pyx_v_dim_;
                __pyx_t_47 = __pyx_v_end;
                __pyx_t_48 = 1;
                __pyx_t_49 = __pyx_v_dim_;
                __pyx_t_50 = __pyx_v_j;
                __pyx_t_51 = 1;
                __pyx_t_52 = __pyx_v_dim_;
                __pyx_t_53 = __pyx_v_end;
                __pyx_t_54 = 2;
                __pyx_t_55 = __pyx_v_dim_;
                __pyx_t_56 = __pyx_v_j;
                __pyx_t_57 = 2;
                __pyx_t_58 = __pyx_v_dim_;
                __pyx_v_res_lamb = (__pyx_v_res_lamb + (((-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_40, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_39, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_36, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_32, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((__pyx_v_j - __pyx_v_st) + 1), __pyx_v_dim)) + (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_41, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_42, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_43, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_44, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_45, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_46, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_47, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_48, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_49, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_50, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_51, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_52, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_53, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_54, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_55, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_56, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_57, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_58, __pyx_pybuffernd_sumstat.diminfo[2].strides))), (__pyx_v_end - __pyx_v_j), __pyx_v_dim))) - __pyx_v_null));
              }

    +061:                     lambda_[j] = res_lamb

              __pyx_t_37 = __pyx_v_j;
              *((double *) ( /* dim=0 */ (__pyx_v_lambda_.data + __pyx_t_37 * __pyx_v_lambda_.strides[0]) )) = __pyx_v_res_lamb;

    +062:         max_out = np.max(lambda_)

        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_max); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 62, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_lambda_, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_5, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 62, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF_SET(__pyx_v_max_out, __pyx_t_2);
        __pyx_t_2 = 0;

    +063:         whichout = np.argmax(lambda_)

        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_argmax); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 63, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __pyx_memoryview_fromslice(__pyx_v_lambda_, 1, (PyObject *(*)(char *)) __pyx_memview_get_double, (int (*)(char *, PyObject *)) __pyx_memview_set_double, 0);; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 63, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = NULL;
        if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
          if (likely(__pyx_t_1)) {
            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(function);
            __Pyx_DECREF_SET(__pyx_t_3, function);
          }
        }
        __pyx_t_2 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_1, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 63, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF_SET(__pyx_v_whichout, __pyx_t_2);
        __pyx_t_2 = 0;

     064:

    +065:         cptsout[q] = whichout

        __pyx_t_18 = __Pyx_PyInt_As_npy_int64(__pyx_v_whichout); if (unlikely((__pyx_t_18 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 65, __pyx_L1_error)
        __pyx_t_19 = __pyx_v_q;
        *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cptsout.rcbuffer->pybuffer.buf, __pyx_t_19, __pyx_pybuffernd_cptsout.diminfo[0].strides) = __pyx_t_18;

    +066:         likeout[q] =  min(oldmax, max_out)

        __Pyx_INCREF(__pyx_v_max_out);
        __pyx_t_2 = __pyx_v_max_out;
        __pyx_t_11 = __pyx_v_oldmax;
        __pyx_t_5 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_5, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_13 < 0)) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_13) {
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_3 = __pyx_t_2;
        } else {
          __pyx_t_1 = PyFloat_FromDouble(__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __pyx_t_1;
          __pyx_t_1 = 0;
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_11 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_11 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_18 = __pyx_v_q;
        *((double *) ( /* dim=0 */ (__pyx_v_likeout.data + __pyx_t_18 * __pyx_v_likeout.strides[0]) )) = __pyx_t_11;

    +067:         oldmax = likeout[q]

        __pyx_t_20 = __pyx_v_q;
        __pyx_v_oldmax = (*((double *) ( /* dim=0 */ (__pyx_v_likeout.data + __pyx_t_20 * __pyx_v_likeout.strides[0]) )));

    +068:         tau_[q+2] = whichout

        __pyx_t_20 = __Pyx_PyInt_As_npy_int64(__pyx_v_whichout); if (unlikely((__pyx_t_20 == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L1_error)
        __pyx_t_35 = (__pyx_v_q + 2);
        *__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_tau_.rcbuffer->pybuffer.buf, __pyx_t_35, __pyx_pybuffernd_tau_.diminfo[0].strides) = __pyx_t_20;

     069:         #tau_ = order_vec(tau_, q+3)

    +070:         order_vec(tau_, q+3)

        __pyx_t_3 = __pyx_f_14pychangepoints_22cost_function_multiple_order_vec(((PyArrayObject *)__pyx_v_tau_), (__pyx_v_q + 3)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }

     071:

    +072:     return np.array(cptsout)

      __Pyx_XDECREF(__pyx_r);
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_3 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, ((PyObject *)__pyx_v_cptsout)) : __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_cptsout));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

     073:

     074: @cython.wraparound(False)

     075: @cython.boundscheck(False)

    +076: def cpelt_multiple(np.ndarray[DTYPE_t, ndim=3] sumstat, double pen, int minseglen, int n, str method):

    /* Python wrapper */
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_3cpelt_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_14pychangepoints_12multiple_dim_3cpelt_multiple = {"cpelt_multiple", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_12multiple_dim_3cpelt_multiple, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_3cpelt_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_sumstat = 0;
      double __pyx_v_pen;
      int __pyx_v_minseglen;
      int __pyx_v_n;
      PyObject *__pyx_v_method = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cpelt_multiple (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_pen,&__pyx_n_s_minseglen,&__pyx_n_s_n,&__pyx_n_s_method,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pen)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cpelt_multiple", 1, 5, 5, 1); __PYX_ERR(0, 76, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_minseglen)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cpelt_multiple", 1, 5, 5, 2); __PYX_ERR(0, 76, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cpelt_multiple", 1, 5, 5, 3); __PYX_ERR(0, 76, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cpelt_multiple", 1, 5, 5, 4); __PYX_ERR(0, 76, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cpelt_multiple") < 0)) __PYX_ERR(0, 76, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        }
        __pyx_v_sumstat = ((PyArrayObject *)values[0]);
        __pyx_v_pen = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_pen == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L3_error)
        __pyx_v_minseglen = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_minseglen == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L3_error)
        __pyx_v_n = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 76, __pyx_L3_error)
        __pyx_v_method = ((PyObject*)values[4]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("cpelt_multiple", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 76, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cpelt_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 76, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 76, __pyx_L1_error)
      __pyx_r = __pyx_pf_14pychangepoints_12multiple_dim_2cpelt_multiple(__pyx_self, __pyx_v_sumstat, __pyx_v_pen, __pyx_v_minseglen, __pyx_v_n, __pyx_v_method);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

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

    static PyObject *__pyx_pf_14pychangepoints_12multiple_dim_2cpelt_multiple(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, double __pyx_v_pen, int __pyx_v_minseglen, int __pyx_v_n, PyObject *__pyx_v_method) {
      CYTHON_UNUSED int __pyx_v_error;
      int __pyx_v_nchecklist;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_dim;
      __Pyx_memviewslice __pyx_v_cptsout = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_lastchangecpts = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_checklist = { 0, 0, { 0 }, { 0 }, { 0 } };
      CYTHON_UNUSED __Pyx_memviewslice __pyx_v_tmpt = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_numchangecpts = { 0, 0, { 0 }, { 0 }, { 0 } };
      PyObject *__pyx_v_a = NULL;
      PyObject *__pyx_v_b = NULL;
      PyObject *__pyx_v_c = NULL;
      PyObject *__pyx_v_d = NULL;
      PyObject *__pyx_v_e = NULL;
      __Pyx_memviewslice __pyx_v_lastchangelike = { 0, 0, { 0 }, { 0 }, { 0 } };
      __Pyx_memviewslice __pyx_v_tmplike = { 0, 0, { 0 }, { 0 }, { 0 } };
      PyObject *__pyx_v_zeros_array_double = NULL;
      PyObject *__pyx_v_zeros_array_double_2 = NULL;
      int __pyx_v_tstar;
      int __pyx_v_i;
      int __pyx_v_whichout;
      int __pyx_v_nchecktmp;
      double __pyx_v_minout;
      __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t);
      int __pyx_v_j;
      int __pyx_v_dim_;
      int __pyx_v_dim_1;
      __pyx_t_14pychangepoints_12multiple_dim_DTYPE_t __pyx_v_a1;
      __pyx_t_14pychangepoints_12multiple_dim_DTYPE_t __pyx_v_a2;
      __pyx_t_14pychangepoints_12multiple_dim_DTYPE_t __pyx_v_a3;
      int __pyx_v_ncpts;
      int __pyx_v_last;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat;
      __Pyx_Buffer __pyx_pybuffer_sumstat;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cpelt_multiple", 0);
      __pyx_pybuffer_sumstat.pybuffer.buf = NULL;
      __pyx_pybuffer_sumstat.refcount = 0;
      __pyx_pybuffernd_sumstat.data = NULL;
      __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 76, __pyx_L1_error)
      }
      __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sumstat.diminfo[1].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sumstat.diminfo[1].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_sumstat.diminfo[2].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_sumstat.diminfo[2].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[2];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cpelt_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
      __pyx_L2:;
      __PYX_XDEC_MEMVIEW(&__pyx_v_cptsout, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_lastchangecpts, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_checklist, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_tmpt, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_numchangecpts, 1);
      __Pyx_XDECREF(__pyx_v_a);
      __Pyx_XDECREF(__pyx_v_b);
      __Pyx_XDECREF(__pyx_v_c);
      __Pyx_XDECREF(__pyx_v_d);
      __Pyx_XDECREF(__pyx_v_e);
      __PYX_XDEC_MEMVIEW(&__pyx_v_lastchangelike, 1);
      __PYX_XDEC_MEMVIEW(&__pyx_v_tmplike, 1);
      __Pyx_XDECREF(__pyx_v_zeros_array_double);
      __Pyx_XDECREF(__pyx_v_zeros_array_double_2);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__29 = PyTuple_Pack(36, __pyx_n_s_sumstat, __pyx_n_s_pen, __pyx_n_s_minseglen, __pyx_n_s_n, __pyx_n_s_method, __pyx_n_s_error, __pyx_n_s_nchecklist, __pyx_n_s_dim, __pyx_n_s_cptsout, __pyx_n_s_lastchangecpts, __pyx_n_s_checklist, __pyx_n_s_tmpt, __pyx_n_s_numchangecpts, __pyx_n_s_a, __pyx_n_s_b, __pyx_n_s_c, __pyx_n_s_d, __pyx_n_s_e, __pyx_n_s_lastchangelike, __pyx_n_s_tmplike, __pyx_n_s_zeros_array_double, __pyx_n_s_zeros_array_double_2, __pyx_n_s_tstar, __pyx_n_s_i, __pyx_n_s_whichout, __pyx_n_s_nchecktmp, __pyx_n_s_minout, __pyx_n_s_current_cost, __pyx_n_s_j, __pyx_n_s_dim_2, __pyx_n_s_dim_1, __pyx_n_s_a1, __pyx_n_s_a2, __pyx_n_s_a3, __pyx_n_s_ncpts, __pyx_n_s_last); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__29);
      __Pyx_GIVEREF(__pyx_tuple__29);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_12multiple_dim_3cpelt_multiple, NULL, __pyx_n_s_pychangepoints_multiple_dim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_cpelt_multiple, __pyx_t_1) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__30 = (PyObject*)__Pyx_PyCode_New(5, 0, 36, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__29, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_mutiple_algos_pyx, __pyx_n_s_cpelt_multiple, 76, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__30)) __PYX_ERR(0, 76, __pyx_L1_error)

     077:     #cdef int n = sumstat.shape[0] - 1

    +078:     cdef int error = 0

      __pyx_v_error = 0;

     079:     cdef int nchecklist

    +080:     cdef ITYPE_t dim = sumstat.shape[2]

      __pyx_v_dim = (__pyx_v_sumstat->dimensions[2]);

     081:

     082:     cdef int [:] cptsout, lastchangecpts, checklist, tmpt, numchangecpts

    +083:     a = np.zeros(n+1, dtype=np.intc)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_a = __pyx_t_5;
      __pyx_t_5 = 0;

    +084:     cptsout = a

      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_a, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 84, __pyx_L1_error)
      __pyx_v_cptsout = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;

    +085:     b = np.zeros(n+1, dtype=np.intc)

      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
      __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_intc); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_4) < 0) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_b = __pyx_t_4;
      __pyx_t_4 = 0;

     086:

    +087:     lastchangecpts = b

      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_b, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 87, __pyx_L1_error)
      __pyx_v_lastchangecpts = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;

    +088:     c = np.zeros(n+1, dtype=np.intc)

      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_intc); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_c = __pyx_t_2;
      __pyx_t_2 = 0;

    +089:     checklist = c

      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_c, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 89, __pyx_L1_error)
      __pyx_v_checklist = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;

    +090:     d = np.zeros(n+1, dtype=np.intc)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
      __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_intc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_v_d = __pyx_t_1;
      __pyx_t_1 = 0;

    +091:     tmpt = d

      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_d, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 91, __pyx_L1_error)
      __pyx_v_tmpt = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;

    +092:     e = np.zeros(n+1, dtype=np.intc)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_np); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_intc); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_dtype, __pyx_t_5) < 0) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_e = __pyx_t_5;
      __pyx_t_5 = 0;

     093:

    +094:     numchangecpts = e

      __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_ds_int(__pyx_v_e, PyBUF_WRITABLE); if (unlikely(!__pyx_t_6.memview)) __PYX_ERR(0, 94, __pyx_L1_error)
      __pyx_v_numchangecpts = __pyx_t_6;
      __pyx_t_6.memview = NULL;
      __pyx_t_6.data = NULL;

     095:     cdef double [:] lastchangelike, tmplike

    +096:     zeros_array_double = np.zeros(n+1)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_zeros_array_double = __pyx_t_5;
      __pyx_t_5 = 0;

    +097:     lastchangelike = zeros_array_double

      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_zeros_array_double, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 97, __pyx_L1_error)
      __pyx_v_lastchangelike = __pyx_t_7;
      __pyx_t_7.memview = NULL;
      __pyx_t_7.data = NULL;

    +098:     zeros_array_double_2 = np.zeros(n+1)

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_n + 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_zeros_array_double_2 = __pyx_t_5;
      __pyx_t_5 = 0;

     099:

    +100:     tmplike = zeros_array_double_2

      __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_ds_double(__pyx_v_zeros_array_double_2, PyBUF_WRITABLE); if (unlikely(!__pyx_t_7.memview)) __PYX_ERR(0, 100, __pyx_L1_error)
      __pyx_v_tmplike = __pyx_t_7;
      __pyx_t_7.memview = NULL;
      __pyx_t_7.data = NULL;

     101:     cdef int tstar, i, whichout, nchecktmp

     102:     cdef double minout

    +103:     lastchangelike[0] = -pen

      __pyx_t_8 = 0;
      *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_8 * __pyx_v_lastchangelike.strides[0]) )) = (-__pyx_v_pen);

    +104:     lastchangecpts[0] = 0

      __pyx_t_9 = 0;
      *((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_9 * __pyx_v_lastchangecpts.strides[0]) )) = 0;

    +105:     numchangecpts[0] = 0

      __pyx_t_10 = 0;
      *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_10 * __pyx_v_numchangecpts.strides[0]) )) = 0;

    +106:     if method == "mll_mean":

      __pyx_t_11 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_11 < 0)) __PYX_ERR(0, 106, __pyx_L1_error)
      __pyx_t_12 = (__pyx_t_11 != 0);
      if (__pyx_t_12) {
    /* … */
        goto __pyx_L3;
      }

    +107:         current_cost = mll_mean

        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mll_mean;

    +108:     elif method == "mbic_mean":

      __pyx_t_12 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_mean, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 108, __pyx_L1_error)
      __pyx_t_11 = (__pyx_t_12 != 0);
      if (__pyx_t_11) {
    /* … */
        goto __pyx_L3;
      }

    +109:         current_cost = mbic_mean

        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mbic_mean;

     110:     else:

    +111:         current_cost = mbic_mean

      /*else*/ {
        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mbic_mean;
      }
      __pyx_L3:;

     112:

     113:

     114:     cdef int j, dim_, dim_1

    +115:     for j in range(minseglen, 2*minseglen):

      __pyx_t_13 = (2 * __pyx_v_minseglen);
      __pyx_t_14 = __pyx_t_13;
      for (__pyx_t_15 = __pyx_v_minseglen; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
        __pyx_v_j = __pyx_t_15;

    +116:         lastchangelike[j] = 0

        __pyx_t_16 = __pyx_v_j;
        *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_16 * __pyx_v_lastchangelike.strides[0]) )) = 0.0;

    +117:         for dim_ in range(0, dim):

        __pyx_t_17 = __pyx_v_dim;
        __pyx_t_18 = __pyx_t_17;
        for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {
          __pyx_v_dim_ = __pyx_t_19;

    +118:             lastchangelike[j] += current_cost(sumstat[j, 0, dim_], sumstat[j, 1, dim_], sumstat[j, 2, dim_], j, dim)

          __pyx_t_20 = __pyx_v_j;
          __pyx_t_21 = 0;
          __pyx_t_22 = __pyx_v_dim_;
          __pyx_t_23 = __pyx_v_j;
          __pyx_t_24 = 1;
          __pyx_t_25 = __pyx_v_dim_;
          __pyx_t_26 = __pyx_v_j;
          __pyx_t_27 = 2;
          __pyx_t_28 = __pyx_v_dim_;
          __pyx_t_29 = __pyx_v_j;
          *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_29 * __pyx_v_lastchangelike.strides[0]) )) += __pyx_v_current_cost((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[2].strides)), (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[2].strides)), (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[2].strides)), __pyx_v_j, __pyx_v_dim);
        }
      }

    +119:     for j in range(minseglen, 2*minseglen):

      __pyx_t_13 = (2 * __pyx_v_minseglen);
      __pyx_t_14 = __pyx_t_13;
      for (__pyx_t_15 = __pyx_v_minseglen; __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
        __pyx_v_j = __pyx_t_15;

    +120:         numchangecpts[j] = 1

        __pyx_t_28 = __pyx_v_j;
        *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_28 * __pyx_v_numchangecpts.strides[0]) )) = 1;
      }

     121:     cdef  DTYPE_t a1 , a2, a3

     122:

    +123:     nchecklist = 2

      __pyx_v_nchecklist = 2;

    +124:     checklist[0] = 0

      __pyx_t_27 = 0;
      *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_27 * __pyx_v_checklist.strides[0]) )) = 0;

    +125:     checklist[1] = minseglen

      __pyx_t_26 = 1;
      *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_26 * __pyx_v_checklist.strides[0]) )) = __pyx_v_minseglen;

    +126:     for tstar in range(2*minseglen, n+1):

      __pyx_t_13 = (__pyx_v_n + 1);
      __pyx_t_14 = __pyx_t_13;
      for (__pyx_t_15 = (2 * __pyx_v_minseglen); __pyx_t_15 < __pyx_t_14; __pyx_t_15+=1) {
        __pyx_v_tstar = __pyx_t_15;

    +127:         if lastchangelike[tstar] == 0:

        __pyx_t_25 = __pyx_v_tstar;
        __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_25 * __pyx_v_lastchangelike.strides[0]) ))) == 0.0) != 0);
        if (__pyx_t_11) {
    /* … */
        }

    +128:             for i in range(0, nchecklist):

          __pyx_t_19 = __pyx_v_nchecklist;
          __pyx_t_30 = __pyx_t_19;
          for (__pyx_t_31 = 0; __pyx_t_31 < __pyx_t_30; __pyx_t_31+=1) {
            __pyx_v_i = __pyx_t_31;

    +129:                 tmplike[i] = lastchangelike[checklist[i]] + pen

            __pyx_t_25 = __pyx_v_i;
            __pyx_t_24 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_25 * __pyx_v_checklist.strides[0]) )));
            __pyx_t_23 = __pyx_v_i;
            *((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_23 * __pyx_v_tmplike.strides[0]) )) = ((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_24 * __pyx_v_lastchangelike.strides[0]) ))) + __pyx_v_pen);

    +130:                 for dim_1 in range(0, dim):

            __pyx_t_17 = __pyx_v_dim;
            __pyx_t_18 = __pyx_t_17;
            for (__pyx_t_32 = 0; __pyx_t_32 < __pyx_t_18; __pyx_t_32+=1) {
              __pyx_v_dim_1 = __pyx_t_32;

    +131:                     a1 = sumstat[tstar, 0, dim_1]-sumstat[checklist[i], 0, dim_1]

              __pyx_t_25 = __pyx_v_tstar;
              __pyx_t_24 = 0;
              __pyx_t_22 = __pyx_v_dim_1;
              __pyx_t_21 = __pyx_v_i;
              __pyx_t_20 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_21 * __pyx_v_checklist.strides[0]) )));
              __pyx_t_33 = 0;
              __pyx_t_34 = __pyx_v_dim_1;
              __pyx_v_a1 = ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[2].strides)));

    +132:                     a2 = sumstat[tstar, 1, dim_1]-sumstat[checklist[i], 1, dim_1]

              __pyx_t_21 = __pyx_v_tstar;
              __pyx_t_34 = 1;
              __pyx_t_33 = __pyx_v_dim_1;
              __pyx_t_20 = __pyx_v_i;
              __pyx_t_22 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_20 * __pyx_v_checklist.strides[0]) )));
              __pyx_t_24 = 1;
              __pyx_t_25 = __pyx_v_dim_1;
              __pyx_v_a2 = ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[2].strides)));

    +133:                     a3 = sumstat[tstar, 2, dim_1]-sumstat[checklist[i], 2, dim_1]

              __pyx_t_20 = __pyx_v_tstar;
              __pyx_t_25 = 2;
              __pyx_t_24 = __pyx_v_dim_1;
              __pyx_t_22 = __pyx_v_i;
              __pyx_t_33 = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_22 * __pyx_v_checklist.strides[0]) )));
              __pyx_t_34 = 2;
              __pyx_t_21 = __pyx_v_dim_1;
              __pyx_v_a3 = ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[2].strides)));

    +134:                     tmplike[i] += current_cost(a1, a2, a3, tstar-checklist[i], dim)

              __pyx_t_22 = __pyx_v_i;
              __pyx_t_21 = __pyx_v_i;
              *((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_21 * __pyx_v_tmplike.strides[0]) )) += __pyx_v_current_cost(__pyx_v_a1, __pyx_v_a2, __pyx_v_a3, (__pyx_v_tstar - (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_22 * __pyx_v_checklist.strides[0]) )))), __pyx_v_dim);
            }
          }

     135:                 #tmplike[i] += lastchangelike[checklist[i]] + pen

    +136:             minout = tmplike[0]

          __pyx_t_22 = 0;
          __pyx_v_minout = (*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_22 * __pyx_v_tmplike.strides[0]) )));

    +137:             whichout = 0

          __pyx_v_whichout = 0;

    +138:             for i in range(1, nchecklist):

          __pyx_t_19 = __pyx_v_nchecklist;
          __pyx_t_30 = __pyx_t_19;
          for (__pyx_t_31 = 1; __pyx_t_31 < __pyx_t_30; __pyx_t_31+=1) {
            __pyx_v_i = __pyx_t_31;

    +139:                 if tmplike[i] <= minout:

            __pyx_t_22 = __pyx_v_i;
            __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_22 * __pyx_v_tmplike.strides[0]) ))) <= __pyx_v_minout) != 0);
            if (__pyx_t_11) {
    /* … */
            }
          }

    +140:                     minout = tmplike[i]

              __pyx_t_22 = __pyx_v_i;
              __pyx_v_minout = (*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_22 * __pyx_v_tmplike.strides[0]) )));

    +141:                     whichout = i

              __pyx_v_whichout = __pyx_v_i;

    +142:             lastchangelike[tstar] = minout

          __pyx_t_22 = __pyx_v_tstar;
          *((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_22 * __pyx_v_lastchangelike.strides[0]) )) = __pyx_v_minout;

    +143:             lastchangecpts[tstar] = checklist[whichout]

          __pyx_t_34 = __pyx_v_whichout;
          __pyx_t_33 = __pyx_v_tstar;
          *((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_33 * __pyx_v_lastchangecpts.strides[0]) )) = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_34 * __pyx_v_checklist.strides[0]) )));

    +144:             numchangecpts[tstar] = numchangecpts[lastchangecpts[tstar]]+1

          __pyx_t_34 = __pyx_v_tstar;
          __pyx_t_24 = (*((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_34 * __pyx_v_lastchangecpts.strides[0]) )));
          __pyx_t_25 = __pyx_v_tstar;
          *((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_25 * __pyx_v_numchangecpts.strides[0]) )) = ((*((int *) ( /* dim=0 */ (__pyx_v_numchangecpts.data + __pyx_t_24 * __pyx_v_numchangecpts.strides[0]) ))) + 1);

    +145:             nchecktmp=0

          __pyx_v_nchecktmp = 0;

    +146:             for i in range(0, nchecklist):

          __pyx_t_19 = __pyx_v_nchecklist;
          __pyx_t_30 = __pyx_t_19;
          for (__pyx_t_31 = 0; __pyx_t_31 < __pyx_t_30; __pyx_t_31+=1) {
            __pyx_v_i = __pyx_t_31;

    +147:                 if(tmplike[i] <= (lastchangelike[tstar]+pen)):

            __pyx_t_34 = __pyx_v_i;
            __pyx_t_24 = __pyx_v_tstar;
            __pyx_t_11 = (((*((double *) ( /* dim=0 */ (__pyx_v_tmplike.data + __pyx_t_34 * __pyx_v_tmplike.strides[0]) ))) <= ((*((double *) ( /* dim=0 */ (__pyx_v_lastchangelike.data + __pyx_t_24 * __pyx_v_lastchangelike.strides[0]) ))) + __pyx_v_pen)) != 0);
            if (__pyx_t_11) {
    /* … */
            }
          }

    +148:                     checklist[nchecktmp] = checklist[i]

              __pyx_t_24 = __pyx_v_i;
              __pyx_t_34 = __pyx_v_nchecktmp;
              *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_34 * __pyx_v_checklist.strides[0]) )) = (*((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_24 * __pyx_v_checklist.strides[0]) )));

    +149:                     nchecktmp = nchecktmp+1

              __pyx_v_nchecktmp = (__pyx_v_nchecktmp + 1);

    +150:             nchecklist = nchecktmp

          __pyx_v_nchecklist = __pyx_v_nchecktmp;

    +151:         checklist[nchecklist] = tstar-(minseglen-1)

        __pyx_t_24 = __pyx_v_nchecklist;
        *((int *) ( /* dim=0 */ (__pyx_v_checklist.data + __pyx_t_24 * __pyx_v_checklist.strides[0]) )) = (__pyx_v_tstar - (__pyx_v_minseglen - 1));

    +152:         nchecklist += 1

        __pyx_v_nchecklist = (__pyx_v_nchecklist + 1);
      }

     153:

    +154:     cdef int ncpts = 0

      __pyx_v_ncpts = 0;

    +155:     cdef int last = n

      __pyx_v_last = __pyx_v_n;

    +156:     while (last != 0):

      while (1) {
        __pyx_t_11 = ((__pyx_v_last != 0) != 0);
        if (!__pyx_t_11) break;

    +157:         cptsout[ncpts] = last

        __pyx_t_20 = __pyx_v_ncpts;
        *((int *) ( /* dim=0 */ (__pyx_v_cptsout.data + __pyx_t_20 * __pyx_v_cptsout.strides[0]) )) = __pyx_v_last;

    +158:         last=lastchangecpts[last]

        __pyx_t_35 = __pyx_v_last;
        __pyx_v_last = (*((int *) ( /* dim=0 */ (__pyx_v_lastchangecpts.data + __pyx_t_35 * __pyx_v_lastchangecpts.strides[0]) )));

    +159:         ncpts += 1

        __pyx_v_ncpts = (__pyx_v_ncpts + 1);
      }

    +160:     return np.array(cptsout)[0:ncpts], ncpts

      __Pyx_XDECREF(__pyx_r);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __pyx_memoryview_fromslice(__pyx_v_cptsout, 1, (PyObject *(*)(char *)) __pyx_memview_get_int, (int (*)(char *, PyObject *)) __pyx_memview_set_int, 0);; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_2)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_5 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_t_5, 0, __pyx_v_ncpts, NULL, NULL, NULL, 1, 1, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_ncpts); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5);
      __pyx_t_3 = 0;
      __pyx_t_5 = 0;
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     161:

     162: @cython.wraparound(False)

     163: @cython.boundscheck(False)

    +164: def cseg_neigh_multiple(np.ndarray[DTYPE_t, ndim=3] sumstat, ITYPE_t Q, str method):

    /* Python wrapper */
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_5cseg_neigh_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_14pychangepoints_12multiple_dim_5cseg_neigh_multiple = {"cseg_neigh_multiple", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_14pychangepoints_12multiple_dim_5cseg_neigh_multiple, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_14pychangepoints_12multiple_dim_5cseg_neigh_multiple(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_sumstat = 0;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_Q;
      PyObject *__pyx_v_method = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cseg_neigh_multiple (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sumstat,&__pyx_n_s_Q,&__pyx_n_s_method,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sumstat)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cseg_neigh_multiple", 1, 3, 3, 1); __PYX_ERR(0, 164, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_method)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("cseg_neigh_multiple", 1, 3, 3, 2); __PYX_ERR(0, 164, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "cseg_neigh_multiple") < 0)) __PYX_ERR(0, 164, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_sumstat = ((PyArrayObject *)values[0]);
        __pyx_v_Q = __Pyx_PyInt_As_npy_int64(values[1]); if (unlikely((__pyx_v_Q == ((npy_int64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 164, __pyx_L3_error)
        __pyx_v_method = ((PyObject*)values[2]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("cseg_neigh_multiple", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 164, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cseg_neigh_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sumstat), __pyx_ptype_5numpy_ndarray, 1, "sumstat", 0))) __PYX_ERR(0, 164, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_method), (&PyString_Type), 1, "method", 1))) __PYX_ERR(0, 164, __pyx_L1_error)
      __pyx_r = __pyx_pf_14pychangepoints_12multiple_dim_4cseg_neigh_multiple(__pyx_self, __pyx_v_sumstat, __pyx_v_Q, __pyx_v_method);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

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

    static PyObject *__pyx_pf_14pychangepoints_12multiple_dim_4cseg_neigh_multiple(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_sumstat, __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_Q, PyObject *__pyx_v_method) {
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_n;
      PyArrayObject *__pyx_v_all_seg = 0;
      int __pyx_v_i;
      int __pyx_v_j;
      int __pyx_v_q;
      int __pyx_v_dim_;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_dim;
      __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t (*__pyx_v_current_cost)(__pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_DTYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t, __pyx_t_14pychangepoints_22cost_function_multiple_ITYPE_t);
      PyArrayObject *__pyx_v_like_q = 0;
      PyArrayObject *__pyx_v_cp = 0;
      __pyx_t_14pychangepoints_12multiple_dim_DTYPE_t __pyx_v_max_out;
      __pyx_t_14pychangepoints_12multiple_dim_ITYPE_t __pyx_v_max_which;
      PyArrayObject *__pyx_v_like = 0;
      PyArrayObject *__pyx_v_cps_Q = 0;
      PyObject *__pyx_v_criterium = NULL;
      PyObject *__pyx_v_op_cps = NULL;
      PyObject *__pyx_v_cpts = NULL;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_all_seg;
      __Pyx_Buffer __pyx_pybuffer_all_seg;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_cp;
      __Pyx_Buffer __pyx_pybuffer_cp;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_cps_Q;
      __Pyx_Buffer __pyx_pybuffer_cps_Q;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_like;
      __Pyx_Buffer __pyx_pybuffer_like;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_like_q;
      __Pyx_Buffer __pyx_pybuffer_like_q;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_sumstat;
      __Pyx_Buffer __pyx_pybuffer_sumstat;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("cseg_neigh_multiple", 0);
      __pyx_pybuffer_all_seg.pybuffer.buf = NULL;
      __pyx_pybuffer_all_seg.refcount = 0;
      __pyx_pybuffernd_all_seg.data = NULL;
      __pyx_pybuffernd_all_seg.rcbuffer = &__pyx_pybuffer_all_seg;
      __pyx_pybuffer_like_q.pybuffer.buf = NULL;
      __pyx_pybuffer_like_q.refcount = 0;
      __pyx_pybuffernd_like_q.data = NULL;
      __pyx_pybuffernd_like_q.rcbuffer = &__pyx_pybuffer_like_q;
      __pyx_pybuffer_cp.pybuffer.buf = NULL;
      __pyx_pybuffer_cp.refcount = 0;
      __pyx_pybuffernd_cp.data = NULL;
      __pyx_pybuffernd_cp.rcbuffer = &__pyx_pybuffer_cp;
      __pyx_pybuffer_like.pybuffer.buf = NULL;
      __pyx_pybuffer_like.refcount = 0;
      __pyx_pybuffernd_like.data = NULL;
      __pyx_pybuffernd_like.rcbuffer = &__pyx_pybuffer_like;
      __pyx_pybuffer_cps_Q.pybuffer.buf = NULL;
      __pyx_pybuffer_cps_Q.refcount = 0;
      __pyx_pybuffernd_cps_Q.data = NULL;
      __pyx_pybuffernd_cps_Q.rcbuffer = &__pyx_pybuffer_cps_Q;
      __pyx_pybuffer_sumstat.pybuffer.buf = NULL;
      __pyx_pybuffer_sumstat.refcount = 0;
      __pyx_pybuffernd_sumstat.data = NULL;
      __pyx_pybuffernd_sumstat.rcbuffer = &__pyx_pybuffer_sumstat;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer, (PyObject*)__pyx_v_sumstat, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) __PYX_ERR(0, 164, __pyx_L1_error)
      }
      __pyx_pybuffernd_sumstat.diminfo[0].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_sumstat.diminfo[0].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_sumstat.diminfo[1].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_sumstat.diminfo[1].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_sumstat.diminfo[2].strides = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_sumstat.diminfo[2].shape = __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.shape[2];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      __Pyx_XDECREF(__pyx_t_5);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cp.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("pychangepoints.multiple_dim.cseg_neigh_multiple", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cp.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_sumstat.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XDECREF((PyObject *)__pyx_v_all_seg);
      __Pyx_XDECREF((PyObject *)__pyx_v_like_q);
      __Pyx_XDECREF((PyObject *)__pyx_v_cp);
      __Pyx_XDECREF((PyObject *)__pyx_v_like);
      __Pyx_XDECREF((PyObject *)__pyx_v_cps_Q);
      __Pyx_XDECREF(__pyx_v_criterium);
      __Pyx_XDECREF(__pyx_v_op_cps);
      __Pyx_XDECREF(__pyx_v_cpts);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__31 = PyTuple_Pack(21, __pyx_n_s_sumstat, __pyx_n_s_Q, __pyx_n_s_method, __pyx_n_s_n, __pyx_n_s_all_seg, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_q, __pyx_n_s_dim_2, __pyx_n_s_s, __pyx_n_s_dim, __pyx_n_s_current_cost, __pyx_n_s_like_q, __pyx_n_s_cp, __pyx_n_s_max_out, __pyx_n_s_max_which, __pyx_n_s_like, __pyx_n_s_cps_Q, __pyx_n_s_criterium, __pyx_n_s_op_cps, __pyx_n_s_cpts); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__31);
      __Pyx_GIVEREF(__pyx_tuple__31);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14pychangepoints_12multiple_dim_5cseg_neigh_multiple, NULL, __pyx_n_s_pychangepoints_multiple_dim); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_cseg_neigh_multiple, __pyx_t_1) < 0) __PYX_ERR(0, 164, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__32 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__31, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_pychangepoints_mutiple_algos_pyx, __pyx_n_s_cseg_neigh_multiple, 164, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__32)) __PYX_ERR(0, 164, __pyx_L1_error)

    +165:     cdef ITYPE_t n=sumstat.shape[0]

      __pyx_v_n = (__pyx_v_sumstat->dimensions[0]);

    +166:     cdef np.ndarray[DTYPE_t, ndim=2] all_seg = np.zeros((n, n))

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
      __pyx_t_2 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_3, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 166, __pyx_L1_error)
      __pyx_t_6 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_all_seg.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          __pyx_v_all_seg = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 166, __pyx_L1_error)
        } else {__pyx_pybuffernd_all_seg.diminfo[0].strides = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_all_seg.diminfo[0].shape = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_all_seg.diminfo[1].strides = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_all_seg.diminfo[1].shape = __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_t_6 = 0;
      __pyx_v_all_seg = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

     167:     cdef int i, j, q, dim_

     168:     cdef DTYPE_t s

    +169:     cdef ITYPE_t dim = sumstat.shape[2]

      __pyx_v_dim = (__pyx_v_sumstat->dimensions[2]);

     170:

    +171:     if method == "mll_mean":

      __pyx_t_7 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mll_mean, Py_EQ)); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 171, __pyx_L1_error)
      __pyx_t_8 = (__pyx_t_7 != 0);
      if (__pyx_t_8) {
    /* … */
        goto __pyx_L3;
      }

    +172:         current_cost = mll_mean

        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mll_mean;

    +173:     elif method == "mbic_mean":

      __pyx_t_8 = (__Pyx_PyString_Equals(__pyx_v_method, __pyx_n_s_mbic_mean, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 173, __pyx_L1_error)
      __pyx_t_7 = (__pyx_t_8 != 0);
      if (__pyx_t_7) {
    /* … */
        goto __pyx_L3;
      }

    +174:         current_cost = mbic_mean

        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mbic_mean;

     175:     else:

    +176:         current_cost = mbic_mean

      /*else*/ {
        __pyx_v_current_cost = __pyx_f_14pychangepoints_22cost_function_multiple_mbic_mean;
      }
      __pyx_L3:;

     177:

    +178:     for i in range(0, n) :

      __pyx_t_9 = __pyx_v_n;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_i = __pyx_t_11;

    +179:         for j in prange(i, n, nogil=True):

        {
            #ifdef WITH_THREAD
            PyThreadState *_save;
            Py_UNBLOCK_THREADS
            __Pyx_FastGIL_Remember();
            #endif
            /*try:*/ {
              __pyx_t_12 = __pyx_v_i;
              __pyx_t_13 = __pyx_v_n;
              if ((1 == 0)) abort();
              {
                  #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                      #undef likely
                      #undef unlikely
                      #define likely(x)   (x)
                      #define unlikely(x) (x)
                  #endif
                  __pyx_t_15 = (__pyx_t_13 - __pyx_t_12 + 1 - 1/abs(1)) / 1;
                  if (__pyx_t_15 > 0)
                  {
                      #ifdef _OPENMP
                      #pragma omp parallel
                      #endif /* _OPENMP */
                      {
                          #ifdef _OPENMP
                          #pragma omp for lastprivate(__pyx_v_dim_) firstprivate(__pyx_v_j) lastprivate(__pyx_v_j)
                          #endif /* _OPENMP */
                          for (__pyx_t_14 = 0; __pyx_t_14 < __pyx_t_15; __pyx_t_14++){
                              {
                                  __pyx_v_j = (int)(__pyx_t_12 + 1 * __pyx_t_14);
                                  /* Initialize private variables to invalid values */
                                  __pyx_v_dim_ = ((int)0xbad0bad0);
    /* … */
            /*finally:*/ {
              /*normal exit:*/{
                #ifdef WITH_THREAD
                __Pyx_FastGIL_Forget();
                Py_BLOCK_THREADS
                #endif
                goto __pyx_L10;
              }
              __pyx_L10:;
            }
        }
      }

    +180:             all_seg[i,j] = 0

                                  __pyx_t_16 = __pyx_v_i;
                                  __pyx_t_17 = __pyx_v_j;
                                  *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_all_seg.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_all_seg.diminfo[1].strides) = 0.0;

    +181:             for dim_ in range(0, dim):

                                  __pyx_t_18 = __pyx_v_dim;
                                  __pyx_t_19 = __pyx_t_18;
                                  for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_19; __pyx_t_20+=1) {
                                    __pyx_v_dim_ = __pyx_t_20;

    +182:                 all_seg[i, j] += -0.5*current_cost(sumstat[j, 0, dim_]-sumstat[i, 0, dim_], sumstat[j, 1, dim_]-sumstat[i, 1, dim_], sumstat[j, 2, dim_]-sumstat[i, 2, dim_], j - i+1, dim)

                                    __pyx_t_21 = __pyx_v_j;
                                    __pyx_t_22 = 0;
                                    __pyx_t_23 = __pyx_v_dim_;
                                    __pyx_t_24 = __pyx_v_i;
                                    __pyx_t_25 = 0;
                                    __pyx_t_26 = __pyx_v_dim_;
                                    __pyx_t_27 = __pyx_v_j;
                                    __pyx_t_28 = 1;
                                    __pyx_t_29 = __pyx_v_dim_;
                                    __pyx_t_30 = __pyx_v_i;
                                    __pyx_t_31 = 1;
                                    __pyx_t_32 = __pyx_v_dim_;
                                    __pyx_t_33 = __pyx_v_j;
                                    __pyx_t_34 = 2;
                                    __pyx_t_35 = __pyx_v_dim_;
                                    __pyx_t_36 = __pyx_v_i;
                                    __pyx_t_37 = 2;
                                    __pyx_t_38 = __pyx_v_dim_;
                                    __pyx_t_39 = __pyx_v_i;
                                    __pyx_t_40 = __pyx_v_j;
                                    *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_all_seg.rcbuffer->pybuffer.buf, __pyx_t_39, __pyx_pybuffernd_all_seg.diminfo[0].strides, __pyx_t_40, __pyx_pybuffernd_all_seg.diminfo[1].strides) += (-0.5 * __pyx_v_current_cost(((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_21, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_23, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_26, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_29, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_32, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_34, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_35, __pyx_pybuffernd_sumstat.diminfo[2].strides)) - (*__Pyx_BufPtrStrided3d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_sumstat.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_sumstat.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_sumstat.diminfo[1].strides, __pyx_t_38, __pyx_pybuffernd_sumstat.diminfo[2].strides))), ((__pyx_v_j - __pyx_v_i) + 1), __pyx_v_dim));
                                  }
                              }
                          }
                      }
                  }
              }
              #if ((defined(__APPLE__) || defined(__OSX__)) && (defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))))
                  #undef likely
                  #undef unlikely
                  #define likely(x)   __builtin_expect(!!(x), 1)
                  #define unlikely(x) __builtin_expect(!!(x), 0)
              #endif
            }

    +183:     cdef np.ndarray[DTYPE_t, ndim=2] like_q = np.zeros((Q, n))

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_3);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_4);
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_4 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_4)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 183, __pyx_L1_error)
      __pyx_t_41 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like_q.rcbuffer->pybuffer, (PyObject*)__pyx_t_41, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          __pyx_v_like_q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_like_q.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 183, __pyx_L1_error)
        } else {__pyx_pybuffernd_like_q.diminfo[0].strides = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_like_q.diminfo[0].shape = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_like_q.diminfo[1].strides = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_like_q.diminfo[1].shape = __pyx_pybuffernd_like_q.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_t_41 = 0;
      __pyx_v_like_q = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

    +184:     like_q[0, :] = all_seg[0, :]

      __pyx_slice_ = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_slice_);
      __Pyx_GIVEREF(__pyx_slice_);
    /* … */
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_all_seg), __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_like_q), __pyx_tuple__2, __pyx_t_1) < 0)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_tuple__2 = PyTuple_Pack(2, __pyx_int_0, __pyx_slice_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 184, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__2);
      __Pyx_GIVEREF(__pyx_tuple__2);

    +185:     cdef  np.ndarray[ITYPE_t, ndim=2] cp = np.zeros((Q, n), dtype=np.int64)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_int64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_3) < 0) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 185, __pyx_L1_error)
      __pyx_t_42 = ((PyArrayObject *)__pyx_t_3);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cp.rcbuffer->pybuffer, (PyObject*)__pyx_t_42, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          __pyx_v_cp = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 185, __pyx_L1_error)
        } else {__pyx_pybuffernd_cp.diminfo[0].strides = __pyx_pybuffernd_cp.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cp.diminfo[0].shape = __pyx_pybuffernd_cp.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_cp.diminfo[1].strides = __pyx_pybuffernd_cp.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_cp.diminfo[1].shape = __pyx_pybuffernd_cp.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_t_42 = 0;
      __pyx_v_cp = ((PyArrayObject *)__pyx_t_3);
      __pyx_t_3 = 0;

    +186:     cdef DTYPE_t max_out = -np.inf

      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_np); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_inf); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyNumber_Negative(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_43 = __pyx_PyFloat_AsDouble(__pyx_t_3); if (unlikely((__pyx_t_43 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 186, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_max_out = __pyx_t_43;

     187:     cdef ITYPE_t max_which

     188:     cdef np.ndarray[DTYPE_t, ndim=1] like

     189:

    +190:     for q in range(1, Q):

      __pyx_t_9 = __pyx_v_Q;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_q = __pyx_t_11;

    +191:         for j in range(q, n):

        __pyx_t_15 = __pyx_v_n;
        __pyx_t_14 = __pyx_t_15;
        for (__pyx_t_12 = __pyx_v_q; __pyx_t_12 < __pyx_t_14; __pyx_t_12+=1) {
          __pyx_v_j = __pyx_t_12;

    +192:             like = like_q[q-1, (q-1):(j-1)]+all_seg[q:j,j]

          __pyx_t_3 = __Pyx_PyInt_From_long((__pyx_v_q - 1)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PyInt_From_long((__pyx_v_q - 1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_j - 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = PySlice_New(__pyx_t_4, __pyx_t_2, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_5);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
          __pyx_t_3 = 0;
          __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_like_q), __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_q); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = PySlice_New(__pyx_t_2, __pyx_t_3, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_4);
          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_3);
          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
          __pyx_t_4 = 0;
          __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_all_seg), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 192, __pyx_L1_error)
          __pyx_t_44 = ((PyArrayObject *)__pyx_t_2);
          {
            __Pyx_BufFmt_StackElem __pyx_stack[1];
            __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_like.rcbuffer->pybuffer);
            __pyx_t_20 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like.rcbuffer->pybuffer, (PyObject*)__pyx_t_44, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
            if (unlikely(__pyx_t_20 < 0)) {
              PyErr_Fetch(&__pyx_t_45, &__pyx_t_46, &__pyx_t_47);
              if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_like.rcbuffer->pybuffer, (PyObject*)__pyx_v_like, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
                Py_XDECREF(__pyx_t_45); Py_XDECREF(__pyx_t_46); Py_XDECREF(__pyx_t_47);
                __Pyx_RaiseBufferFallbackError();
              } else {
                PyErr_Restore(__pyx_t_45, __pyx_t_46, __pyx_t_47);
              }
              __pyx_t_45 = __pyx_t_46 = __pyx_t_47 = 0;
            }
            __pyx_pybuffernd_like.diminfo[0].strides = __pyx_pybuffernd_like.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_like.diminfo[0].shape = __pyx_pybuffernd_like.rcbuffer->pybuffer.shape[0];
            if (unlikely(__pyx_t_20 < 0)) __PYX_ERR(0, 192, __pyx_L1_error)
          }
          __pyx_t_44 = 0;
          __Pyx_XDECREF_SET(__pyx_v_like, ((PyArrayObject *)__pyx_t_2));
          __pyx_t_2 = 0;

    +193:             max_which = 0

          __pyx_v_max_which = 0;

    +194:             max_out = -np.inf

          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_inf); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = PyNumber_Negative(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_43 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_43 == ((npy_float64)-1)) && PyErr_Occurred())) __PYX_ERR(0, 194, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_v_max_out = __pyx_t_43;

    +195:             for i in range(0, j-q):

          __pyx_t_20 = (__pyx_v_j - __pyx_v_q);
          __pyx_t_48 = __pyx_t_20;
          for (__pyx_t_49 = 0; __pyx_t_49 < __pyx_t_48; __pyx_t_49+=1) {
            __pyx_v_i = __pyx_t_49;

    +196:                 if  max_out <= like[i]:

            __pyx_t_38 = __pyx_v_i;
            __pyx_t_7 = ((__pyx_v_max_out <= (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_like.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_like.diminfo[0].strides))) != 0);
            if (__pyx_t_7) {
    /* … */
            }
          }

    +197:                     max_out = like[i]

              __pyx_t_38 = __pyx_v_i;
              __pyx_v_max_out = (*__Pyx_BufPtrStrided1d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_like.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_like.diminfo[0].strides));

    +198:                     max_which = i

              __pyx_v_max_which = __pyx_v_i;

     199:             #print(max_out, max_which)

     200:

    +201:             like_q[q, j] = max_out

          __pyx_t_38 = __pyx_v_q;
          __pyx_t_37 = __pyx_v_j;
          *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_DTYPE_t *, __pyx_pybuffernd_like_q.rcbuffer->pybuffer.buf, __pyx_t_38, __pyx_pybuffernd_like_q.diminfo[0].strides, __pyx_t_37, __pyx_pybuffernd_like_q.diminfo[1].strides) = __pyx_v_max_out;

    +202:             cp[q, j] = max_which + q

          __pyx_t_36 = __pyx_v_q;
          __pyx_t_35 = __pyx_v_j;
          *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_36, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_35, __pyx_pybuffernd_cp.diminfo[1].strides) = (__pyx_v_max_which + __pyx_v_q);
        }
      }

    +203:     cdef  np.ndarray[ITYPE_t, ndim=2] cps_Q = np.zeros((Q, Q), dtype=np.int64)

      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = __Pyx_PyInt_From_npy_int64(__pyx_v_Q); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_2);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_5);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
      __pyx_t_2 = 0;
      __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_4);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
      __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_np); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_1) < 0) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) __PYX_ERR(0, 203, __pyx_L1_error)
      __pyx_t_50 = ((PyArrayObject *)__pyx_t_1);
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_cps_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_50, &__Pyx_TypeInfo_nn___pyx_t_14pychangepoints_12multiple_dim_ITYPE_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) {
          __pyx_v_cps_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf = NULL;
          __PYX_ERR(0, 203, __pyx_L1_error)
        } else {__pyx_pybuffernd_cps_Q.diminfo[0].strides = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_cps_Q.diminfo[0].shape = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_cps_Q.diminfo[1].strides = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_cps_Q.diminfo[1].shape = __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.shape[1];
        }
      }
      __pyx_t_50 = 0;
      __pyx_v_cps_Q = ((PyArrayObject *)__pyx_t_1);
      __pyx_t_1 = 0;

    +204:     for q in range(1, Q):

      __pyx_t_9 = __pyx_v_Q;
      __pyx_t_10 = __pyx_t_9;
      for (__pyx_t_11 = 1; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
        __pyx_v_q = __pyx_t_11;

    +205:         cps_Q[q,0] = cp[q, n-1]

        __pyx_t_34 = __pyx_v_q;
        __pyx_t_15 = (__pyx_v_n - 1);
        __pyx_t_33 = __pyx_v_q;
        __pyx_t_32 = 0;
        *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_33, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_32, __pyx_pybuffernd_cps_Q.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_cp.diminfo[1].strides));

    +206:         for i in range(0, q):

        __pyx_t_12 = __pyx_v_q;
        __pyx_t_20 = __pyx_t_12;
        for (__pyx_t_48 = 0; __pyx_t_48 < __pyx_t_20; __pyx_t_48+=1) {
          __pyx_v_i = __pyx_t_48;

    +207:             cps_Q[q, i+1] = cp[q-i-1, cps_Q[q, i]]

          __pyx_t_34 = __pyx_v_q;
          __pyx_t_31 = __pyx_v_i;
          __pyx_t_30 = ((__pyx_v_q - __pyx_v_i) - 1);
          __pyx_t_15 = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_34, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_cps_Q.diminfo[1].strides));
          __pyx_t_29 = __pyx_v_q;
          __pyx_t_28 = (__pyx_v_i + 1);
          *__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cps_Q.rcbuffer->pybuffer.buf, __pyx_t_29, __pyx_pybuffernd_cps_Q.diminfo[0].strides, __pyx_t_28, __pyx_pybuffernd_cps_Q.diminfo[1].strides) = (*__Pyx_BufPtrStrided2d(__pyx_t_14pychangepoints_12multiple_dim_ITYPE_t *, __pyx_pybuffernd_cp.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_cp.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_cp.diminfo[1].strides));
        }
      }

     208:

    +209:     criterium = -2 * like_q[:, n-2]

      __pyx_t_1 = __Pyx_PyInt_From_npy_int64((__pyx_v_n - 2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_slice_);
      __Pyx_GIVEREF(__pyx_slice_);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice_);
      __Pyx_GIVEREF(__pyx_t_1);
      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
      __pyx_t_1 = 0;
      __pyx_t_1 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_like_q), __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = PyNumber_Multiply(__pyx_int_neg_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 209, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_criterium = __pyx_t_4;
      __pyx_t_4 = 0;

    +210:     op_cps = np.argmin(criterium)

      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_np); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_argmin); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
        if (likely(__pyx_t_1)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_5, function);
        }
      }
      __pyx_t_4 = (__pyx_t_1) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_1, __pyx_v_criterium) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_criterium);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 210, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_v_op_cps = __pyx_t_4;
      __pyx_t_4 = 0;

    +211:     cpts = np.sort(cps_Q[op_cps, :][cps_Q[op_cps, :] > 0])

      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_np); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sort); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_op_cps);
      __Pyx_GIVEREF(__pyx_v_op_cps);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_op_cps);
      __Pyx_INCREF(__pyx_slice_);
      __Pyx_GIVEREF(__pyx_slice_);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice_);
      __pyx_t_3 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_cps_Q), __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_v_op_cps);
      __Pyx_GIVEREF(__pyx_v_op_cps);
      PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_op_cps);
      __Pyx_INCREF(__pyx_slice_);
      __Pyx_GIVEREF(__pyx_slice_);
      PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice_);
      __pyx_t_2 = __Pyx_PyObject_GetItem(((PyObject *)__pyx_v_cps_Q), __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_5 = NULL;
      if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
        if (likely(__pyx_t_5)) {
          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(function);
          __Pyx_DECREF_SET(__pyx_t_1, function);
        }
      }
      __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_5, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_v_cpts = __pyx_t_4;
      __pyx_t_4 = 0;

     212:

    +213:     return cpts

      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_cpts);
      __pyx_r = __pyx_v_cpts;
      goto __pyx_L0;