diff --git a/GPy/inference/latent_function_inference/svgp.py b/GPy/inference/latent_function_inference/svgp.py index 7aad399d..a7ee9d14 100644 --- a/GPy/inference/latent_function_inference/svgp.py +++ b/GPy/inference/latent_function_inference/svgp.py @@ -13,7 +13,12 @@ class SVGP(LatentFunctionInference): #expand cholesky representation L = choleskies.flat_to_triang(q_u_chol) - S = np.einsum('ijk,ljk->ilk', L, L) #L.dot(L.T) + + + S_ein = np.einsum('ijk,ljk->ilk', L, L) #L.dot(L.T) + S = np.empty((num_outputs, num_inducing, num_inducing)) + [np.dot(L[:,:,i], L[:,:,i].T, S[i,:,:]) for i in range(num_outputs)] + S = S.swapaxes(0,2) #Si,_ = linalg.dpotri(np.asfortranarray(L), lower=1) Si = choleskies.multiple_dpotri(L) logdetS = np.array([2.*np.sum(np.log(np.abs(np.diag(L[:,:,i])))) for i in range(L.shape[-1])]) diff --git a/GPy/util/choleskies_cython.c b/GPy/util/choleskies_cython.c index 42fe5a6c..0bcf8e69 100644 --- a/GPy/util/choleskies_cython.c +++ b/GPy/util/choleskies_cython.c @@ -831,9 +831,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObjec static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); -static void __Pyx_RaiseBufferIndexError(int axis); - #define __Pyx_BufPtrStrided2d(type, buf, i0, s0, i1, s1) (type)((char*)buf + i0 * s0 + i1 * s1) +#define __Pyx_BufPtrStrided3d(type, buf, i0, s0, i1, s1, i2, s2) (type)((char*)buf + i0 * s0 + i1 * s1 + i2 * s2) static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); @@ -1107,7 +1106,7 @@ static char __pyx_k_triang_to_flat[] = "triang_to_flat"; static char __pyx_k_backprop_gradient[] = "backprop_gradient"; static char __pyx_k_GPy_util_choleskies_cython[] = "GPy.util.choleskies_cython"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; -static char __pyx_k_Users_james_work_GPy_GPy_util_c[] = "/Users/james/work/GPy/GPy/util/choleskies_cython.pyx"; +static char __pyx_k_home_james_work_GPy_GPy_util_ch[] = "/home/james/work/GPy/GPy/util/choleskies_cython.pyx"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; @@ -1122,7 +1121,6 @@ static PyObject *__pyx_n_s_M; static PyObject *__pyx_n_s_N; static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; static PyObject *__pyx_n_s_RuntimeError; -static PyObject *__pyx_kp_s_Users_james_work_GPy_GPy_util_c; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_backprop_gradient; static PyObject *__pyx_n_s_copy; @@ -1133,6 +1131,7 @@ static PyObject *__pyx_n_s_dL_dK; static PyObject *__pyx_n_s_empty; static PyObject *__pyx_n_s_flat; static PyObject *__pyx_n_s_flat_to_triang; +static PyObject *__pyx_kp_s_home_james_work_GPy_GPy_util_ch; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_j; @@ -1151,7 +1150,6 @@ static PyObject *__pyx_n_s_triang_to_flat; static PyObject *__pyx_n_s_tril; static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; static PyObject *__pyx_n_s_zeros; -static PyObject *__pyx_int_1; static PyObject *__pyx_tuple_; static PyObject *__pyx_tuple__2; static PyObject *__pyx_tuple__3; @@ -1165,7 +1163,7 @@ static PyObject *__pyx_codeobj__8; static PyObject *__pyx_codeobj__10; static PyObject *__pyx_codeobj__12; -/* "GPy/util/choleskies_cython.pyx":9 +/* "GPy/util/choleskies_cython.pyx":10 * cimport numpy as np * * def flat_to_triang(np.ndarray[double, ndim=2] flat, int M): # <<<<<<<<<<<<<< @@ -1206,11 +1204,11 @@ static PyObject *__pyx_pw_3GPy_4util_17choleskies_cython_1flat_to_triang(PyObjec case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_M)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("flat_to_triang", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("flat_to_triang", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "flat_to_triang") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "flat_to_triang") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -1219,17 +1217,17 @@ static PyObject *__pyx_pw_3GPy_4util_17choleskies_cython_1flat_to_triang(PyObjec values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } __pyx_v_flat = ((PyArrayObject *)values[0]); - __pyx_v_M = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_M == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_M = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_M == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("flat_to_triang", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("flat_to_triang", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("GPy.util.choleskies_cython.flat_to_triang", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_flat), __pyx_ptype_5numpy_ndarray, 1, "flat", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_flat), __pyx_ptype_5numpy_ndarray, 1, "flat", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(__pyx_self, __pyx_v_flat, __pyx_v_M); /* function exit code */ @@ -1247,8 +1245,8 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U int __pyx_v_count; PyArrayObject *__pyx_v_ret = 0; int __pyx_v_d; - PyObject *__pyx_v_m = NULL; - PyObject *__pyx_v_mm = NULL; + int __pyx_v_m; + int __pyx_v_mm; __Pyx_LocalBuf_ND __pyx_pybuffernd_flat; __Pyx_Buffer __pyx_pybuffer_flat; __Pyx_LocalBuf_ND __pyx_pybuffernd_ret; @@ -1264,13 +1262,15 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U PyArrayObject *__pyx_t_7 = NULL; int __pyx_t_8; int __pyx_t_9; - Py_ssize_t __pyx_t_10; - PyObject *(*__pyx_t_11)(PyObject *); - Py_ssize_t __pyx_t_12; - PyObject *(*__pyx_t_13)(PyObject *); + int __pyx_t_10; + int __pyx_t_11; + long __pyx_t_12; + int __pyx_t_13; int __pyx_t_14; int __pyx_t_15; int __pyx_t_16; + int __pyx_t_17; + int __pyx_t_18; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -1285,11 +1285,11 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U __pyx_pybuffernd_flat.rcbuffer = &__pyx_pybuffer_flat; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flat.rcbuffer->pybuffer, (PyObject*)__pyx_v_flat, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flat.rcbuffer->pybuffer, (PyObject*)__pyx_v_flat, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_flat.diminfo[0].strides = __pyx_pybuffernd_flat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_flat.diminfo[0].shape = __pyx_pybuffernd_flat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_flat.diminfo[1].strides = __pyx_pybuffernd_flat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_flat.diminfo[1].shape = __pyx_pybuffernd_flat.rcbuffer->pybuffer.shape[1]; - /* "GPy/util/choleskies_cython.pyx":16 + /* "GPy/util/choleskies_cython.pyx":17 * the lower triangluar portion of the d'th slice of the result is filled by the d'th column of flat. * """ * cdef int N = flat.shape[0] # <<<<<<<<<<<<<< @@ -1298,7 +1298,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U */ __pyx_v_N = (__pyx_v_flat->dimensions[0]); - /* "GPy/util/choleskies_cython.pyx":17 + /* "GPy/util/choleskies_cython.pyx":18 * """ * cdef int N = flat.shape[0] * cdef int D = flat.shape[1] # <<<<<<<<<<<<<< @@ -1307,34 +1307,34 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U */ __pyx_v_D = (__pyx_v_flat->dimensions[1]); - /* "GPy/util/choleskies_cython.pyx":18 + /* "GPy/util/choleskies_cython.pyx":19 * cdef int N = flat.shape[0] * cdef int D = flat.shape[1] * cdef int count = 0 # <<<<<<<<<<<<<< * cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D)) - * for d in range(D): + * cdef int d, m, mm */ __pyx_v_count = 0; - /* "GPy/util/choleskies_cython.pyx":19 + /* "GPy/util/choleskies_cython.pyx":20 * cdef int D = flat.shape[1] * cdef int count = 0 * cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D)) # <<<<<<<<<<<<<< + * cdef int d, m, mm * for d in range(D): - * count = 0 */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __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_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_D); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_D); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -1356,28 +1356,28 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U } } if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_ret.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 3, 0, __pyx_stack) == -1)) { __pyx_v_ret = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_ret.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_ret.diminfo[0].strides = __pyx_pybuffernd_ret.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_ret.diminfo[0].shape = __pyx_pybuffernd_ret.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_ret.diminfo[1].strides = __pyx_pybuffernd_ret.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_ret.diminfo[1].shape = __pyx_pybuffernd_ret.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_ret.diminfo[2].strides = __pyx_pybuffernd_ret.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_ret.diminfo[2].shape = __pyx_pybuffernd_ret.rcbuffer->pybuffer.shape[2]; } } @@ -1385,9 +1385,9 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U __pyx_v_ret = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":20 - * cdef int count = 0 + /* "GPy/util/choleskies_cython.pyx":22 * cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D)) + * cdef int d, m, mm * for d in range(D): # <<<<<<<<<<<<<< * count = 0 * for m in range(M): @@ -1396,8 +1396,8 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U for (__pyx_t_9 = 0; __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_d = __pyx_t_9; - /* "GPy/util/choleskies_cython.pyx":21 - * cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D)) + /* "GPy/util/choleskies_cython.pyx":23 + * cdef int d, m, mm * for d in range(D): * count = 0 # <<<<<<<<<<<<<< * for m in range(M): @@ -1405,123 +1405,29 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U */ __pyx_v_count = 0; - /* "GPy/util/choleskies_cython.pyx":22 + /* "GPy/util/choleskies_cython.pyx":24 * for d in range(D): * count = 0 * for m in range(M): # <<<<<<<<<<<<<< * for mm in range(m+1): * ret[m, mm, d] = flat[count,d] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { - __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; - __pyx_t_11 = NULL; - } else { - __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (likely(!__pyx_t_11)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } else { - if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_1); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } - } else { - __pyx_t_1 = __pyx_t_11(__pyx_t_3); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_10 = __pyx_v_M; + for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { + __pyx_v_m = __pyx_t_11; - /* "GPy/util/choleskies_cython.pyx":23 + /* "GPy/util/choleskies_cython.pyx":25 * count = 0 * for m in range(M): * for mm in range(m+1): # <<<<<<<<<<<<<< * ret[m, mm, d] = flat[count,d] * count += 1 */ - __pyx_t_1 = PyNumber_Add(__pyx_v_m, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { - __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_12 = 0; - __pyx_t_13 = NULL; - } else { - __pyx_t_12 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_13 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (likely(!__pyx_t_13)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } else { - if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_12); __Pyx_INCREF(__pyx_t_1); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } - } else { - __pyx_t_1 = __pyx_t_13(__pyx_t_4); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_mm, __pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_12 = (__pyx_v_m + 1); + for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) { + __pyx_v_mm = __pyx_t_13; - /* "GPy/util/choleskies_cython.pyx":24 + /* "GPy/util/choleskies_cython.pyx":26 * for m in range(M): * for mm in range(m+1): * ret[m, mm, d] = flat[count,d] # <<<<<<<<<<<<<< @@ -1530,39 +1436,17 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U */ __pyx_t_14 = __pyx_v_count; __pyx_t_15 = __pyx_v_d; - __pyx_t_16 = -1; - if (__pyx_t_14 < 0) { - __pyx_t_14 += __pyx_pybuffernd_flat.diminfo[0].shape; - if (unlikely(__pyx_t_14 < 0)) __pyx_t_16 = 0; - } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_flat.diminfo[0].shape)) __pyx_t_16 = 0; - if (__pyx_t_15 < 0) { - __pyx_t_15 += __pyx_pybuffernd_flat.diminfo[1].shape; - if (unlikely(__pyx_t_15 < 0)) __pyx_t_16 = 1; - } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_flat.diminfo[1].shape)) __pyx_t_16 = 1; - if (unlikely(__pyx_t_16 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_16); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_1 = PyFloat_FromDouble((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_flat.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_flat.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_flat.diminfo[1].strides))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_d); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_m); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_m); - __Pyx_GIVEREF(__pyx_v_m); - __Pyx_INCREF(__pyx_v_mm); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_mm); - __Pyx_GIVEREF(__pyx_v_mm); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_6 = 0; - if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_t_5, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_pybuffernd_flat.diminfo[0].shape; + if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_pybuffernd_flat.diminfo[1].shape; + __pyx_t_16 = __pyx_v_m; + __pyx_t_17 = __pyx_v_mm; + __pyx_t_18 = __pyx_v_d; + if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_pybuffernd_ret.diminfo[0].shape; + if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_pybuffernd_ret.diminfo[1].shape; + if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_pybuffernd_ret.diminfo[2].shape; + *__Pyx_BufPtrStrided3d(double *, __pyx_pybuffernd_ret.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_ret.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_ret.diminfo[1].strides, __pyx_t_18, __pyx_pybuffernd_ret.diminfo[2].strides) = (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_flat.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_flat.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_flat.diminfo[1].strides)); - /* "GPy/util/choleskies_cython.pyx":25 + /* "GPy/util/choleskies_cython.pyx":27 * for mm in range(m+1): * ret[m, mm, d] = flat[count,d] * count += 1 # <<<<<<<<<<<<<< @@ -1570,29 +1454,11 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U * */ __pyx_v_count = (__pyx_v_count + 1); - - /* "GPy/util/choleskies_cython.pyx":23 - * count = 0 - * for m in range(M): - * for mm in range(m+1): # <<<<<<<<<<<<<< - * ret[m, mm, d] = flat[count,d] - * count += 1 - */ } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "GPy/util/choleskies_cython.pyx":22 - * for d in range(D): - * count = 0 - * for m in range(M): # <<<<<<<<<<<<<< - * for mm in range(m+1): - * ret[m, mm, d] = flat[count,d] - */ } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "GPy/util/choleskies_cython.pyx":26 + /* "GPy/util/choleskies_cython.pyx":28 * ret[m, mm, d] = flat[count,d] * count += 1 * return ret # <<<<<<<<<<<<<< @@ -1604,7 +1470,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U __pyx_r = ((PyObject *)__pyx_v_ret); goto __pyx_L0; - /* "GPy/util/choleskies_cython.pyx":9 + /* "GPy/util/choleskies_cython.pyx":10 * cimport numpy as np * * def flat_to_triang(np.ndarray[double, ndim=2] flat, int M): # <<<<<<<<<<<<<< @@ -1633,14 +1499,12 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_flat_to_triang(CYTHON_U __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_ret.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_ret); - __Pyx_XDECREF(__pyx_v_m); - __Pyx_XDECREF(__pyx_v_mm); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "GPy/util/choleskies_cython.pyx":28 +/* "GPy/util/choleskies_cython.pyx":30 * return ret * * def triang_to_flat(np.ndarray[double, ndim=3] L): # <<<<<<<<<<<<<< @@ -1658,7 +1522,7 @@ static PyObject *__pyx_pw_3GPy_4util_17choleskies_cython_3triang_to_flat(PyObjec PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("triang_to_flat (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_L), __pyx_ptype_5numpy_ndarray, 1, "L", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_L), __pyx_ptype_5numpy_ndarray, 1, "L", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(__pyx_self, ((PyArrayObject *)__pyx_v_L)); /* function exit code */ @@ -1677,8 +1541,8 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ int __pyx_v_count; PyArrayObject *__pyx_v_flat = 0; int __pyx_v_d; - PyObject *__pyx_v_m = NULL; - PyObject *__pyx_v_mm = NULL; + int __pyx_v_m; + int __pyx_v_mm; __Pyx_LocalBuf_ND __pyx_pybuffernd_L; __Pyx_Buffer __pyx_pybuffer_L; __Pyx_LocalBuf_ND __pyx_pybuffernd_flat; @@ -1693,14 +1557,15 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ PyArrayObject *__pyx_t_6 = NULL; int __pyx_t_7; int __pyx_t_8; - Py_ssize_t __pyx_t_9; - PyObject *(*__pyx_t_10)(PyObject *); - Py_ssize_t __pyx_t_11; - PyObject *(*__pyx_t_12)(PyObject *); - double __pyx_t_13; + int __pyx_t_9; + int __pyx_t_10; + long __pyx_t_11; + int __pyx_t_12; + int __pyx_t_13; int __pyx_t_14; int __pyx_t_15; int __pyx_t_16; + int __pyx_t_17; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -1715,11 +1580,11 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ __pyx_pybuffernd_L.rcbuffer = &__pyx_pybuffer_L; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_L.rcbuffer->pybuffer, (PyObject*)__pyx_v_L, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_L.rcbuffer->pybuffer, (PyObject*)__pyx_v_L, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_L.diminfo[0].strides = __pyx_pybuffernd_L.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_L.diminfo[0].shape = __pyx_pybuffernd_L.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_L.diminfo[1].strides = __pyx_pybuffernd_L.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_L.diminfo[1].shape = __pyx_pybuffernd_L.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_L.diminfo[2].strides = __pyx_pybuffernd_L.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_L.diminfo[2].shape = __pyx_pybuffernd_L.rcbuffer->pybuffer.shape[2]; - /* "GPy/util/choleskies_cython.pyx":29 + /* "GPy/util/choleskies_cython.pyx":31 * * def triang_to_flat(np.ndarray[double, ndim=3] L): * cdef int M = L.shape[0] # <<<<<<<<<<<<<< @@ -1728,7 +1593,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ */ __pyx_v_M = (__pyx_v_L->dimensions[0]); - /* "GPy/util/choleskies_cython.pyx":30 + /* "GPy/util/choleskies_cython.pyx":32 * def triang_to_flat(np.ndarray[double, ndim=3] L): * cdef int M = L.shape[0] * cdef int D = L.shape[2] # <<<<<<<<<<<<<< @@ -1737,7 +1602,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ */ __pyx_v_D = (__pyx_v_L->dimensions[2]); - /* "GPy/util/choleskies_cython.pyx":31 + /* "GPy/util/choleskies_cython.pyx":33 * cdef int M = L.shape[0] * cdef int D = L.shape[2] * cdef int N = M*(M+1)/2 # <<<<<<<<<<<<<< @@ -1746,32 +1611,32 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ */ __pyx_v_N = __Pyx_div_long((__pyx_v_M * (__pyx_v_M + 1)), 2); - /* "GPy/util/choleskies_cython.pyx":32 + /* "GPy/util/choleskies_cython.pyx":34 * cdef int D = L.shape[2] * cdef int N = M*(M+1)/2 * cdef int count = 0 # <<<<<<<<<<<<<< * cdef np.ndarray[double, ndim=2] flat = np.empty((N, D)) - * for d in range(D): + * cdef int d, m, mm */ __pyx_v_count = 0; - /* "GPy/util/choleskies_cython.pyx":33 + /* "GPy/util/choleskies_cython.pyx":35 * cdef int N = M*(M+1)/2 * cdef int count = 0 * cdef np.ndarray[double, ndim=2] flat = np.empty((N, D)) # <<<<<<<<<<<<<< + * cdef int d, m, mm * for d in range(D): - * count = 0 */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_empty); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_D); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_D); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -1790,28 +1655,28 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ } } if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __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_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_6 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_flat.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_flat = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_flat.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_flat.diminfo[0].strides = __pyx_pybuffernd_flat.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_flat.diminfo[0].shape = __pyx_pybuffernd_flat.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_flat.diminfo[1].strides = __pyx_pybuffernd_flat.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_flat.diminfo[1].shape = __pyx_pybuffernd_flat.rcbuffer->pybuffer.shape[1]; } } @@ -1819,9 +1684,9 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ __pyx_v_flat = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":34 - * cdef int count = 0 + /* "GPy/util/choleskies_cython.pyx":37 * cdef np.ndarray[double, ndim=2] flat = np.empty((N, D)) + * cdef int d, m, mm * for d in range(D): # <<<<<<<<<<<<<< * count = 0 * for m in range(M): @@ -1830,8 +1695,8 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { __pyx_v_d = __pyx_t_8; - /* "GPy/util/choleskies_cython.pyx":35 - * cdef np.ndarray[double, ndim=2] flat = np.empty((N, D)) + /* "GPy/util/choleskies_cython.pyx":38 + * cdef int d, m, mm * for d in range(D): * count = 0 # <<<<<<<<<<<<<< * for m in range(M): @@ -1839,165 +1704,48 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ */ __pyx_v_count = 0; - /* "GPy/util/choleskies_cython.pyx":36 + /* "GPy/util/choleskies_cython.pyx":39 * for d in range(D): * count = 0 * for m in range(M): # <<<<<<<<<<<<<< * for mm in range(m+1): * flat[count,d] = L[m, mm, d] */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { - __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - } else { - __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (likely(!__pyx_t_10)) { - if (likely(PyList_CheckExact(__pyx_t_3))) { - if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } else { - if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } - } else { - __pyx_t_1 = __pyx_t_10(__pyx_t_3); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_m, __pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_9 = __pyx_v_M; + for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_9; __pyx_t_10+=1) { + __pyx_v_m = __pyx_t_10; - /* "GPy/util/choleskies_cython.pyx":37 + /* "GPy/util/choleskies_cython.pyx":40 * count = 0 * for m in range(M): * for mm in range(m+1): # <<<<<<<<<<<<<< * flat[count,d] = L[m, mm, d] * count += 1 */ - __pyx_t_1 = PyNumber_Add(__pyx_v_m, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) { - __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_11 = 0; - __pyx_t_12 = NULL; - } else { - __pyx_t_11 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (;;) { - if (likely(!__pyx_t_12)) { - if (likely(PyList_CheckExact(__pyx_t_2))) { - if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } else { - if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - } - } else { - __pyx_t_1 = __pyx_t_12(__pyx_t_2); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_mm, __pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_11 = (__pyx_v_m + 1); + for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { + __pyx_v_mm = __pyx_t_12; - /* "GPy/util/choleskies_cython.pyx":38 + /* "GPy/util/choleskies_cython.pyx":41 * for m in range(M): * for mm in range(m+1): * flat[count,d] = L[m, mm, d] # <<<<<<<<<<<<<< * count += 1 * return flat */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_d); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_m); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_m); - __Pyx_GIVEREF(__pyx_v_m); - __Pyx_INCREF(__pyx_v_mm); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_mm); - __Pyx_GIVEREF(__pyx_v_mm); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_L), __pyx_t_5); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_13 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_13 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_14 = __pyx_v_count; + __pyx_t_13 = __pyx_v_m; + __pyx_t_14 = __pyx_v_mm; __pyx_t_15 = __pyx_v_d; - __pyx_t_16 = -1; - if (__pyx_t_14 < 0) { - __pyx_t_14 += __pyx_pybuffernd_flat.diminfo[0].shape; - if (unlikely(__pyx_t_14 < 0)) __pyx_t_16 = 0; - } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_flat.diminfo[0].shape)) __pyx_t_16 = 0; - if (__pyx_t_15 < 0) { - __pyx_t_15 += __pyx_pybuffernd_flat.diminfo[1].shape; - if (unlikely(__pyx_t_15 < 0)) __pyx_t_16 = 1; - } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_flat.diminfo[1].shape)) __pyx_t_16 = 1; - if (unlikely(__pyx_t_16 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_16); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_flat.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_flat.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_flat.diminfo[1].strides) = __pyx_t_13; + if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_pybuffernd_L.diminfo[1].shape; + if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_pybuffernd_L.diminfo[2].shape; + __pyx_t_16 = __pyx_v_count; + __pyx_t_17 = __pyx_v_d; + if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_pybuffernd_flat.diminfo[0].shape; + if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_pybuffernd_flat.diminfo[1].shape; + *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_flat.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_flat.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_flat.diminfo[1].strides) = (*__Pyx_BufPtrStrided3d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_13, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_14, __pyx_pybuffernd_L.diminfo[1].strides, __pyx_t_15, __pyx_pybuffernd_L.diminfo[2].strides)); - /* "GPy/util/choleskies_cython.pyx":39 + /* "GPy/util/choleskies_cython.pyx":42 * for mm in range(m+1): * flat[count,d] = L[m, mm, d] * count += 1 # <<<<<<<<<<<<<< @@ -2005,29 +1753,11 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ * */ __pyx_v_count = (__pyx_v_count + 1); - - /* "GPy/util/choleskies_cython.pyx":37 - * count = 0 - * for m in range(M): - * for mm in range(m+1): # <<<<<<<<<<<<<< - * flat[count,d] = L[m, mm, d] - * count += 1 - */ } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "GPy/util/choleskies_cython.pyx":36 - * for d in range(D): - * count = 0 - * for m in range(M): # <<<<<<<<<<<<<< - * for mm in range(m+1): - * flat[count,d] = L[m, mm, d] - */ } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } - /* "GPy/util/choleskies_cython.pyx":40 + /* "GPy/util/choleskies_cython.pyx":43 * flat[count,d] = L[m, mm, d] * count += 1 * return flat # <<<<<<<<<<<<<< @@ -2039,7 +1769,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ __pyx_r = ((PyObject *)__pyx_v_flat); goto __pyx_L0; - /* "GPy/util/choleskies_cython.pyx":28 + /* "GPy/util/choleskies_cython.pyx":30 * return ret * * def triang_to_flat(np.ndarray[double, ndim=3] L): # <<<<<<<<<<<<<< @@ -2067,14 +1797,12 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_2triang_to_flat(CYTHON_ __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_flat.rcbuffer->pybuffer); __pyx_L2:; __Pyx_XDECREF((PyObject *)__pyx_v_flat); - __Pyx_XDECREF(__pyx_v_m); - __Pyx_XDECREF(__pyx_v_mm); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "GPy/util/choleskies_cython.pyx":43 +/* "GPy/util/choleskies_cython.pyx":46 * * * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): # <<<<<<<<<<<<<< @@ -2114,11 +1842,11 @@ static PyObject *__pyx_pw_3GPy_4util_17choleskies_cython_5backprop_gradient(PyOb case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_L)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("backprop_gradient", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("backprop_gradient", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "backprop_gradient") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "backprop_gradient") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -2131,14 +1859,14 @@ static PyObject *__pyx_pw_3GPy_4util_17choleskies_cython_5backprop_gradient(PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("backprop_gradient", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("backprop_gradient", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("GPy.util.choleskies_cython.backprop_gradient", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dL), __pyx_ptype_5numpy_ndarray, 1, "dL", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_L), __pyx_ptype_5numpy_ndarray, 1, "L", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dL), __pyx_ptype_5numpy_ndarray, 1, "dL", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_L), __pyx_ptype_5numpy_ndarray, 1, "L", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(__pyx_self, __pyx_v_dL, __pyx_v_L); /* function exit code */ @@ -2197,7 +1925,6 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH int __pyx_t_31; int __pyx_t_32; int __pyx_t_33; - int __pyx_t_34; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -2216,25 +1943,25 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH __pyx_pybuffernd_L.rcbuffer = &__pyx_pybuffer_L; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dL.rcbuffer->pybuffer, (PyObject*)__pyx_v_dL, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dL.rcbuffer->pybuffer, (PyObject*)__pyx_v_dL, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_dL.diminfo[0].strides = __pyx_pybuffernd_dL.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dL.diminfo[0].shape = __pyx_pybuffernd_dL.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dL.diminfo[1].strides = __pyx_pybuffernd_dL.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dL.diminfo[1].shape = __pyx_pybuffernd_dL.rcbuffer->pybuffer.shape[1]; { __Pyx_BufFmt_StackElem __pyx_stack[1]; - if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_L.rcbuffer->pybuffer, (PyObject*)__pyx_v_L, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_L.rcbuffer->pybuffer, (PyObject*)__pyx_v_L, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_pybuffernd_L.diminfo[0].strides = __pyx_pybuffernd_L.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_L.diminfo[0].shape = __pyx_pybuffernd_L.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_L.diminfo[1].strides = __pyx_pybuffernd_L.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_L.diminfo[1].shape = __pyx_pybuffernd_L.rcbuffer->pybuffer.shape[1]; - /* "GPy/util/choleskies_cython.pyx":44 + /* "GPy/util/choleskies_cython.pyx":47 * * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): * cdef np.ndarray[double, ndim=2] dL_dK = np.tril(dL).copy() # <<<<<<<<<<<<<< * cdef int N = L.shape[0] * cdef int k, j, i */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tril); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tril); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = NULL; @@ -2248,21 +1975,21 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH } } if (!__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_dL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_dL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL; __Pyx_INCREF(((PyObject *)__pyx_v_dL)); PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_dL)); __Pyx_GIVEREF(((PyObject *)__pyx_v_dL)); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_copy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; @@ -2276,20 +2003,20 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH } } if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_GOTREF(__pyx_t_1); __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_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_6 = ((PyArrayObject *)__pyx_t_1); { __Pyx_BufFmt_StackElem __pyx_stack[1]; if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dL_dK.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 2, 0, __pyx_stack) == -1)) { __pyx_v_dL_dK = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf = NULL; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else {__pyx_pybuffernd_dL_dK.diminfo[0].strides = __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dL_dK.diminfo[0].shape = __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dL_dK.diminfo[1].strides = __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dL_dK.diminfo[1].shape = __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.shape[1]; } } @@ -2297,7 +2024,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH __pyx_v_dL_dK = ((PyArrayObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":45 + /* "GPy/util/choleskies_cython.pyx":48 * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): * cdef np.ndarray[double, ndim=2] dL_dK = np.tril(dL).copy() * cdef int N = L.shape[0] # <<<<<<<<<<<<<< @@ -2306,7 +2033,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_v_N = (__pyx_v_L->dimensions[0]); - /* "GPy/util/choleskies_cython.pyx":47 + /* "GPy/util/choleskies_cython.pyx":50 * cdef int N = L.shape[0] * cdef int k, j, i * for k in range(N - 1, -1, -1): # <<<<<<<<<<<<<< @@ -2316,7 +2043,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH for (__pyx_t_7 = (__pyx_v_N - 1); __pyx_t_7 > -1; __pyx_t_7-=1) { __pyx_v_k = __pyx_t_7; - /* "GPy/util/choleskies_cython.pyx":48 + /* "GPy/util/choleskies_cython.pyx":51 * cdef int k, j, i * for k in range(N - 1, -1, -1): * for j in range(k + 1, N): # <<<<<<<<<<<<<< @@ -2327,7 +2054,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH for (__pyx_t_9 = (__pyx_v_k + 1); __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_j = __pyx_t_9; - /* "GPy/util/choleskies_cython.pyx":49 + /* "GPy/util/choleskies_cython.pyx":52 * for k in range(N - 1, -1, -1): * for j in range(k + 1, N): * for i in range(j, N): # <<<<<<<<<<<<<< @@ -2338,7 +2065,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH for (__pyx_t_11 = __pyx_v_j; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) { __pyx_v_i = __pyx_t_11; - /* "GPy/util/choleskies_cython.pyx":50 + /* "GPy/util/choleskies_cython.pyx":53 * for j in range(k + 1, N): * for i in range(j, N): * dL_dK[i, k] -= dL_dK[i, j] * L[j, k] # <<<<<<<<<<<<<< @@ -2347,52 +2074,19 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_t_12 = __pyx_v_i; __pyx_t_13 = __pyx_v_j; - __pyx_t_14 = -1; - if (__pyx_t_12 < 0) { - __pyx_t_12 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_12 < 0)) __pyx_t_14 = 0; - } else if (unlikely(__pyx_t_12 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_14 = 0; - if (__pyx_t_13 < 0) { - __pyx_t_13 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_13 < 0)) __pyx_t_14 = 1; - } else if (unlikely(__pyx_t_13 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_14 = 1; - if (unlikely(__pyx_t_14 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_14); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_12 < 0) __pyx_t_12 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_13 < 0) __pyx_t_13 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; __pyx_t_14 = __pyx_v_j; __pyx_t_15 = __pyx_v_k; - __pyx_t_16 = -1; - if (__pyx_t_14 < 0) { - __pyx_t_14 += __pyx_pybuffernd_L.diminfo[0].shape; - if (unlikely(__pyx_t_14 < 0)) __pyx_t_16 = 0; - } else if (unlikely(__pyx_t_14 >= __pyx_pybuffernd_L.diminfo[0].shape)) __pyx_t_16 = 0; - if (__pyx_t_15 < 0) { - __pyx_t_15 += __pyx_pybuffernd_L.diminfo[1].shape; - if (unlikely(__pyx_t_15 < 0)) __pyx_t_16 = 1; - } else if (unlikely(__pyx_t_15 >= __pyx_pybuffernd_L.diminfo[1].shape)) __pyx_t_16 = 1; - if (unlikely(__pyx_t_16 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_16); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_14 < 0) __pyx_t_14 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_15 < 0) __pyx_t_15 += __pyx_pybuffernd_L.diminfo[1].shape; __pyx_t_16 = __pyx_v_i; __pyx_t_17 = __pyx_v_k; - __pyx_t_18 = -1; - if (__pyx_t_16 < 0) { - __pyx_t_16 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_16 < 0)) __pyx_t_18 = 0; - } else if (unlikely(__pyx_t_16 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_18 = 0; - if (__pyx_t_17 < 0) { - __pyx_t_17 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_17 < 0)) __pyx_t_18 = 1; - } else if (unlikely(__pyx_t_17 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_18 = 1; - if (unlikely(__pyx_t_18 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_18); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_16 < 0) __pyx_t_16 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_17 < 0) __pyx_t_17 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_16, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_17, __pyx_pybuffernd_dL_dK.diminfo[1].strides) -= ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_12, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_13, __pyx_pybuffernd_dL_dK.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_14, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_15, __pyx_pybuffernd_L.diminfo[1].strides))); - /* "GPy/util/choleskies_cython.pyx":51 + /* "GPy/util/choleskies_cython.pyx":54 * for i in range(j, N): * dL_dK[i, k] -= dL_dK[i, j] * L[j, k] * dL_dK[j, k] -= dL_dK[i, j] * L[i, k] # <<<<<<<<<<<<<< @@ -2401,54 +2095,21 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_t_18 = __pyx_v_i; __pyx_t_19 = __pyx_v_j; - __pyx_t_20 = -1; - if (__pyx_t_18 < 0) { - __pyx_t_18 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_18 < 0)) __pyx_t_20 = 0; - } else if (unlikely(__pyx_t_18 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_20 = 0; - if (__pyx_t_19 < 0) { - __pyx_t_19 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_19 < 0)) __pyx_t_20 = 1; - } else if (unlikely(__pyx_t_19 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_20 = 1; - if (unlikely(__pyx_t_20 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_20); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_18 < 0) __pyx_t_18 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_19 < 0) __pyx_t_19 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; __pyx_t_20 = __pyx_v_i; __pyx_t_21 = __pyx_v_k; - __pyx_t_22 = -1; - if (__pyx_t_20 < 0) { - __pyx_t_20 += __pyx_pybuffernd_L.diminfo[0].shape; - if (unlikely(__pyx_t_20 < 0)) __pyx_t_22 = 0; - } else if (unlikely(__pyx_t_20 >= __pyx_pybuffernd_L.diminfo[0].shape)) __pyx_t_22 = 0; - if (__pyx_t_21 < 0) { - __pyx_t_21 += __pyx_pybuffernd_L.diminfo[1].shape; - if (unlikely(__pyx_t_21 < 0)) __pyx_t_22 = 1; - } else if (unlikely(__pyx_t_21 >= __pyx_pybuffernd_L.diminfo[1].shape)) __pyx_t_22 = 1; - if (unlikely(__pyx_t_22 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_22); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_20 < 0) __pyx_t_20 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_21 < 0) __pyx_t_21 += __pyx_pybuffernd_L.diminfo[1].shape; __pyx_t_22 = __pyx_v_j; __pyx_t_23 = __pyx_v_k; - __pyx_t_24 = -1; - if (__pyx_t_22 < 0) { - __pyx_t_22 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_22 < 0)) __pyx_t_24 = 0; - } else if (unlikely(__pyx_t_22 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_24 = 0; - if (__pyx_t_23 < 0) { - __pyx_t_23 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_23 < 0)) __pyx_t_24 = 1; - } else if (unlikely(__pyx_t_23 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_24 = 1; - if (unlikely(__pyx_t_24 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_24); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_22 < 0) __pyx_t_22 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_23 < 0) __pyx_t_23 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_dL_dK.diminfo[1].strides) -= ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_18, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_19, __pyx_pybuffernd_dL_dK.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_20, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_21, __pyx_pybuffernd_L.diminfo[1].strides))); } } - /* "GPy/util/choleskies_cython.pyx":52 + /* "GPy/util/choleskies_cython.pyx":55 * dL_dK[i, k] -= dL_dK[i, j] * L[j, k] * dL_dK[j, k] -= dL_dK[i, j] * L[i, k] * for j in range(k + 1, N): # <<<<<<<<<<<<<< @@ -2459,7 +2120,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH for (__pyx_t_9 = (__pyx_v_k + 1); __pyx_t_9 < __pyx_t_8; __pyx_t_9+=1) { __pyx_v_j = __pyx_t_9; - /* "GPy/util/choleskies_cython.pyx":53 + /* "GPy/util/choleskies_cython.pyx":56 * dL_dK[j, k] -= dL_dK[i, j] * L[i, k] * for j in range(k + 1, N): * dL_dK[j, k] /= L[k, k] # <<<<<<<<<<<<<< @@ -2468,37 +2129,15 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_t_10 = __pyx_v_k; __pyx_t_11 = __pyx_v_k; - __pyx_t_24 = -1; - if (__pyx_t_10 < 0) { - __pyx_t_10 += __pyx_pybuffernd_L.diminfo[0].shape; - if (unlikely(__pyx_t_10 < 0)) __pyx_t_24 = 0; - } else if (unlikely(__pyx_t_10 >= __pyx_pybuffernd_L.diminfo[0].shape)) __pyx_t_24 = 0; - if (__pyx_t_11 < 0) { - __pyx_t_11 += __pyx_pybuffernd_L.diminfo[1].shape; - if (unlikely(__pyx_t_11 < 0)) __pyx_t_24 = 1; - } else if (unlikely(__pyx_t_11 >= __pyx_pybuffernd_L.diminfo[1].shape)) __pyx_t_24 = 1; - if (unlikely(__pyx_t_24 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_24); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_10 < 0) __pyx_t_10 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_11 < 0) __pyx_t_11 += __pyx_pybuffernd_L.diminfo[1].shape; __pyx_t_24 = __pyx_v_j; __pyx_t_25 = __pyx_v_k; - __pyx_t_26 = -1; - if (__pyx_t_24 < 0) { - __pyx_t_24 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_24 < 0)) __pyx_t_26 = 0; - } else if (unlikely(__pyx_t_24 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_26 = 0; - if (__pyx_t_25 < 0) { - __pyx_t_25 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_25 < 0)) __pyx_t_26 = 1; - } else if (unlikely(__pyx_t_25 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_26 = 1; - if (unlikely(__pyx_t_26 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_26); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_24 < 0) __pyx_t_24 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_25 < 0) __pyx_t_25 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_24, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_25, __pyx_pybuffernd_dL_dK.diminfo[1].strides) /= (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_10, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_11, __pyx_pybuffernd_L.diminfo[1].strides)); - /* "GPy/util/choleskies_cython.pyx":54 + /* "GPy/util/choleskies_cython.pyx":57 * for j in range(k + 1, N): * dL_dK[j, k] /= L[k, k] * dL_dK[k, k] -= L[j, k] * dL_dK[j, k] # <<<<<<<<<<<<<< @@ -2507,53 +2146,20 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_t_26 = __pyx_v_j; __pyx_t_27 = __pyx_v_k; - __pyx_t_28 = -1; - if (__pyx_t_26 < 0) { - __pyx_t_26 += __pyx_pybuffernd_L.diminfo[0].shape; - if (unlikely(__pyx_t_26 < 0)) __pyx_t_28 = 0; - } else if (unlikely(__pyx_t_26 >= __pyx_pybuffernd_L.diminfo[0].shape)) __pyx_t_28 = 0; - if (__pyx_t_27 < 0) { - __pyx_t_27 += __pyx_pybuffernd_L.diminfo[1].shape; - if (unlikely(__pyx_t_27 < 0)) __pyx_t_28 = 1; - } else if (unlikely(__pyx_t_27 >= __pyx_pybuffernd_L.diminfo[1].shape)) __pyx_t_28 = 1; - if (unlikely(__pyx_t_28 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_28); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_26 < 0) __pyx_t_26 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_27 < 0) __pyx_t_27 += __pyx_pybuffernd_L.diminfo[1].shape; __pyx_t_28 = __pyx_v_j; __pyx_t_29 = __pyx_v_k; - __pyx_t_30 = -1; - if (__pyx_t_28 < 0) { - __pyx_t_28 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_28 < 0)) __pyx_t_30 = 0; - } else if (unlikely(__pyx_t_28 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_30 = 0; - if (__pyx_t_29 < 0) { - __pyx_t_29 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_29 < 0)) __pyx_t_30 = 1; - } else if (unlikely(__pyx_t_29 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_30 = 1; - if (unlikely(__pyx_t_30 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_30); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_28 < 0) __pyx_t_28 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_29 < 0) __pyx_t_29 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; __pyx_t_30 = __pyx_v_k; __pyx_t_31 = __pyx_v_k; - __pyx_t_32 = -1; - if (__pyx_t_30 < 0) { - __pyx_t_30 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_30 < 0)) __pyx_t_32 = 0; - } else if (unlikely(__pyx_t_30 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_32 = 0; - if (__pyx_t_31 < 0) { - __pyx_t_31 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_31 < 0)) __pyx_t_32 = 1; - } else if (unlikely(__pyx_t_31 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_32 = 1; - if (unlikely(__pyx_t_32 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_32); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_30 < 0) __pyx_t_30 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_31 < 0) __pyx_t_31 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_30, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_31, __pyx_pybuffernd_dL_dK.diminfo[1].strides) -= ((*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_L.diminfo[1].strides)) * (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_28, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_29, __pyx_pybuffernd_dL_dK.diminfo[1].strides))); } - /* "GPy/util/choleskies_cython.pyx":55 + /* "GPy/util/choleskies_cython.pyx":58 * dL_dK[j, k] /= L[k, k] * dL_dK[k, k] -= L[j, k] * dL_dK[j, k] * dL_dK[k, k] /= (2. * L[k, k]) # <<<<<<<<<<<<<< @@ -2561,38 +2167,16 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH */ __pyx_t_8 = __pyx_v_k; __pyx_t_9 = __pyx_v_k; - __pyx_t_32 = -1; - if (__pyx_t_8 < 0) { - __pyx_t_8 += __pyx_pybuffernd_L.diminfo[0].shape; - if (unlikely(__pyx_t_8 < 0)) __pyx_t_32 = 0; - } else if (unlikely(__pyx_t_8 >= __pyx_pybuffernd_L.diminfo[0].shape)) __pyx_t_32 = 0; - if (__pyx_t_9 < 0) { - __pyx_t_9 += __pyx_pybuffernd_L.diminfo[1].shape; - if (unlikely(__pyx_t_9 < 0)) __pyx_t_32 = 1; - } else if (unlikely(__pyx_t_9 >= __pyx_pybuffernd_L.diminfo[1].shape)) __pyx_t_32 = 1; - if (unlikely(__pyx_t_32 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_32); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_8 < 0) __pyx_t_8 += __pyx_pybuffernd_L.diminfo[0].shape; + if (__pyx_t_9 < 0) __pyx_t_9 += __pyx_pybuffernd_L.diminfo[1].shape; __pyx_t_32 = __pyx_v_k; __pyx_t_33 = __pyx_v_k; - __pyx_t_34 = -1; - if (__pyx_t_32 < 0) { - __pyx_t_32 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; - if (unlikely(__pyx_t_32 < 0)) __pyx_t_34 = 0; - } else if (unlikely(__pyx_t_32 >= __pyx_pybuffernd_dL_dK.diminfo[0].shape)) __pyx_t_34 = 0; - if (__pyx_t_33 < 0) { - __pyx_t_33 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; - if (unlikely(__pyx_t_33 < 0)) __pyx_t_34 = 1; - } else if (unlikely(__pyx_t_33 >= __pyx_pybuffernd_dL_dK.diminfo[1].shape)) __pyx_t_34 = 1; - if (unlikely(__pyx_t_34 != -1)) { - __Pyx_RaiseBufferIndexError(__pyx_t_34); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + if (__pyx_t_32 < 0) __pyx_t_32 += __pyx_pybuffernd_dL_dK.diminfo[0].shape; + if (__pyx_t_33 < 0) __pyx_t_33 += __pyx_pybuffernd_dL_dK.diminfo[1].shape; *__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_dL_dK.rcbuffer->pybuffer.buf, __pyx_t_32, __pyx_pybuffernd_dL_dK.diminfo[0].strides, __pyx_t_33, __pyx_pybuffernd_dL_dK.diminfo[1].strides) /= (2. * (*__Pyx_BufPtrStrided2d(double *, __pyx_pybuffernd_L.rcbuffer->pybuffer.buf, __pyx_t_8, __pyx_pybuffernd_L.diminfo[0].strides, __pyx_t_9, __pyx_pybuffernd_L.diminfo[1].strides))); } - /* "GPy/util/choleskies_cython.pyx":56 + /* "GPy/util/choleskies_cython.pyx":59 * dL_dK[k, k] -= L[j, k] * dL_dK[j, k] * dL_dK[k, k] /= (2. * L[k, k]) * return dL_dK # <<<<<<<<<<<<<< @@ -2602,7 +2186,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_4backprop_gradient(CYTH __pyx_r = ((PyObject *)__pyx_v_dL_dK); goto __pyx_L0; - /* "GPy/util/choleskies_cython.pyx":43 + /* "GPy/util/choleskies_cython.pyx":46 * * * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): # <<<<<<<<<<<<<< @@ -4683,7 +4267,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1}, {&__pyx_kp_u_Non_native_byte_order_not_suppor, __pyx_k_Non_native_byte_order_not_suppor, sizeof(__pyx_k_Non_native_byte_order_not_suppor), 0, 1, 0, 0}, {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_k_Users_james_work_GPy_GPy_util_c, sizeof(__pyx_k_Users_james_work_GPy_GPy_util_c), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_backprop_gradient, __pyx_k_backprop_gradient, sizeof(__pyx_k_backprop_gradient), 0, 0, 1, 1}, {&__pyx_n_s_copy, __pyx_k_copy, sizeof(__pyx_k_copy), 0, 0, 1, 1}, @@ -4694,6 +4277,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, {&__pyx_n_s_flat, __pyx_k_flat, sizeof(__pyx_k_flat), 0, 0, 1, 1}, {&__pyx_n_s_flat_to_triang, __pyx_k_flat_to_triang, sizeof(__pyx_k_flat_to_triang), 0, 0, 1, 1}, + {&__pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_k_home_james_work_GPy_GPy_util_ch, sizeof(__pyx_k_home_james_work_GPy_GPy_util_ch), 0, 0, 1, 0}, {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, @@ -4715,7 +4299,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {0, 0, 0, 0, 0, 0, 0} }; static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; @@ -4793,41 +4377,41 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); - /* "GPy/util/choleskies_cython.pyx":9 + /* "GPy/util/choleskies_cython.pyx":10 * cimport numpy as np * * def flat_to_triang(np.ndarray[double, ndim=2] flat, int M): # <<<<<<<<<<<<<< * """take a matrix N x D and return a M X M x D array where * */ - __pyx_tuple__7 = PyTuple_Pack(9, __pyx_n_s_flat, __pyx_n_s_M, __pyx_n_s_N, __pyx_n_s_D, __pyx_n_s_count, __pyx_n_s_ret, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__7 = PyTuple_Pack(9, __pyx_n_s_flat, __pyx_n_s_M, __pyx_n_s_N, __pyx_n_s_D, __pyx_n_s_count, __pyx_n_s_ret, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); - __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_flat_to_triang, 9, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_flat_to_triang, 10, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "GPy/util/choleskies_cython.pyx":28 + /* "GPy/util/choleskies_cython.pyx":30 * return ret * * def triang_to_flat(np.ndarray[double, ndim=3] L): # <<<<<<<<<<<<<< * cdef int M = L.shape[0] * cdef int D = L.shape[2] */ - __pyx_tuple__9 = PyTuple_Pack(9, __pyx_n_s_L, __pyx_n_s_M, __pyx_n_s_D, __pyx_n_s_N, __pyx_n_s_count, __pyx_n_s_flat, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__9 = PyTuple_Pack(9, __pyx_n_s_L, __pyx_n_s_M, __pyx_n_s_D, __pyx_n_s_N, __pyx_n_s_count, __pyx_n_s_flat, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); - __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_triang_to_flat, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_triang_to_flat, 30, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "GPy/util/choleskies_cython.pyx":43 + /* "GPy/util/choleskies_cython.pyx":46 * * * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): # <<<<<<<<<<<<<< * cdef np.ndarray[double, ndim=2] dL_dK = np.tril(dL).copy() * cdef int N = L.shape[0] */ - __pyx_tuple__11 = PyTuple_Pack(7, __pyx_n_s_dL, __pyx_n_s_L, __pyx_n_s_dL_dK, __pyx_n_s_N, __pyx_n_s_k, __pyx_n_s_j, __pyx_n_s_i); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__11 = PyTuple_Pack(7, __pyx_n_s_dL, __pyx_n_s_L, __pyx_n_s_dL_dK, __pyx_n_s_N, __pyx_n_s_k, __pyx_n_s_j, __pyx_n_s_i); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); - __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_backprop_gradient, 43, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_backprop_gradient, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -4837,7 +4421,6 @@ static int __Pyx_InitCachedConstants(void) { static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -4940,58 +4523,58 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) /*--- Function import code ---*/ /*--- Execution code ---*/ - /* "GPy/util/choleskies_cython.pyx":6 - * #cython: nonecheck(False) + /* "GPy/util/choleskies_cython.pyx":7 + * # Copyright James Hensman and Alan Saul 2015 * * import numpy as np # <<<<<<<<<<<<<< * cimport numpy as np * */ - __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":9 + /* "GPy/util/choleskies_cython.pyx":10 * cimport numpy as np * * def flat_to_triang(np.ndarray[double, ndim=2] flat, int M): # <<<<<<<<<<<<<< * """take a matrix N x D and return a M X M x D array where * */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_1flat_to_triang, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_1flat_to_triang, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_flat_to_triang, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_flat_to_triang, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":28 + /* "GPy/util/choleskies_cython.pyx":30 * return ret * * def triang_to_flat(np.ndarray[double, ndim=3] L): # <<<<<<<<<<<<<< * cdef int M = L.shape[0] * cdef int D = L.shape[2] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_3triang_to_flat, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_3triang_to_flat, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_triang_to_flat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_triang_to_flat, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "GPy/util/choleskies_cython.pyx":43 + /* "GPy/util/choleskies_cython.pyx":46 * * * def backprop_gradient(np.ndarray[double, ndim=2] dL, np.ndarray[double, ndim=2] L): # <<<<<<<<<<<<<< * cdef np.ndarray[double, ndim=2] dL_dK = np.tril(dL).copy() * cdef int N = L.shape[0] */ - __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_5backprop_gradient, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_4util_17choleskies_cython_5backprop_gradient, NULL, __pyx_n_s_GPy_util_choleskies_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_backprop_gradient, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_d, __pyx_n_s_backprop_gradient, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "GPy/util/choleskies_cython.pyx":1 - * # Copyright James Hensman and Alan Saul 2015 # <<<<<<<<<<<<<< - * #cython: wraparaound(False) - * #cython: boundscheck(False) + * #cython: wraparaound=False # <<<<<<<<<<<<<< + * #cython: boundscheck=False + * #cython: nonecheck=False */ __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); @@ -5870,11 +5453,6 @@ static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { return 0; } -static void __Pyx_RaiseBufferIndexError(int axis) { - PyErr_Format(PyExc_IndexError, - "Out of bounds on buffer access (axis %d)", axis); -} - static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { #if CYTHON_COMPILING_IN_CPYTHON PyObject *tmp_type, *tmp_value, *tmp_tb; diff --git a/GPy/util/choleskies_cython.pyx b/GPy/util/choleskies_cython.pyx index 6cfba53d..7217f962 100644 --- a/GPy/util/choleskies_cython.pyx +++ b/GPy/util/choleskies_cython.pyx @@ -1,7 +1,8 @@ +#cython: wraparaound=False +#cython: boundscheck=False +#cython: nonecheck=False + # Copyright James Hensman and Alan Saul 2015 -#cython: wraparaound(False) -#cython: boundscheck(False) -#cython: nonecheck(False) import numpy as np cimport numpy as np @@ -17,6 +18,7 @@ def flat_to_triang(np.ndarray[double, ndim=2] flat, int M): cdef int D = flat.shape[1] cdef int count = 0 cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D)) + cdef int d, m, mm for d in range(D): count = 0 for m in range(M): @@ -31,6 +33,7 @@ def triang_to_flat(np.ndarray[double, ndim=3] L): cdef int N = M*(M+1)/2 cdef int count = 0 cdef np.ndarray[double, ndim=2] flat = np.empty((N, D)) + cdef int d, m, mm for d in range(D): count = 0 for m in range(M):