diff --git a/.coveragerc b/.coveragerc index eac8d014..512c99c4 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,27 +2,23 @@ [run] branch = True source = GPy -omit = ./GPy/testing/*.py, travis_tests.py, setup.py, ./GPy/__version__.py, ./GPy/plotting/* +omit = ./GPy/examples/*.py, ./GPy/testing/*.py, travis_tests.py, setup.py, ./GPy/__version__.py [report] # Regexes for lines to exclude from consideration exclude_lines = # Have to re-enable the standard pragma pragma: no cover - + verbose # Don't complain about missing debug-only code: if self\.debug # Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - raise NotImplemented - except NotImplementedError - except NotImplemented - except AssertionError - except ImportError + raise + except pass + Not implemented # Don't complain if non-runnable code isn't run: if 0: @@ -31,4 +27,4 @@ exclude_lines = # Don't fail on python3 catch clauses: python3 -ignore_errors = True \ No newline at end of file +ignore_errors = True diff --git a/.travis.yml b/.travis.yml index b236d515..7897b009 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ addons: env: - PYTHON_VERSION=2.7 - - PYTHON_VERSION=3.3 + #- PYTHON_VERSION=3.3 - PYTHON_VERSION=3.4 - PYTHON_VERSION=3.5 @@ -29,9 +29,11 @@ install: - echo $PATH - source install_retry.sh - pip install codecov +- pip install coveralls - pip install pypandoc - pip install git+git://github.com/BRML/climin.git - pip install autograd +- pip install nose-show-skipped - python setup.py develop script: @@ -39,6 +41,7 @@ script: after_success: - codecov + - coveralls before_deploy: - cd doc @@ -47,9 +50,11 @@ before_deploy: - make html - cd ../ - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; - then export DIST='sdist'; + then + export DIST='sdist'; elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; - then export DIST='bdist_wheel'; + then + export DIST='bdist_wheel'; fi; deploy: @@ -58,8 +63,6 @@ deploy: password: secure: "vMEOlP7DQhFJ7hQAKtKC5hrJXFl5BkUt4nXdosWWiw//Kg8E+PPLg88XPI2gqIosir9wwgtbSBBbbwCxkM6uxRNMpoNR8Ixyv9fmSXp4rLl7bbBY768W7IRXKIBjpuEy2brQjoT+CwDDSzUkckHvuUjJDNRvUv8ab4P/qYO1LG4=" on: - tags: false - branch: devel - server: https://testpypi.python.org/pypi + branch: deploy distributions: $DIST skip_cleanup: true diff --git a/AUTHORS.txt b/AUTHORS.txt index 08ee8401..5a2a154c 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -1 +1 @@ -[GPy Authors](https://github.com/SheffieldML/GPy/graphs/contributors) \ No newline at end of file +GPy Authors: https://github.com/SheffieldML/GPy/graphs/contributors \ No newline at end of file diff --git a/GPy/__init__.py b/GPy/__init__.py index f27ce81d..9ee3d935 100644 --- a/GPy/__init__.py +++ b/GPy/__init__.py @@ -14,6 +14,8 @@ from . import testing from . import kern from . import plotting +from .util import normalizer + # backwards compatibility import sys backwards_compatibility = ['lists_and_dicts', 'observable_array', 'ties_and_remappings', 'index_operations'] @@ -28,16 +30,18 @@ from .core.parameterization import Param, Parameterized, ObsAr, transformations from .__version__ import __version__ from numpy.testing import Tester -#@nottest -try: - #Get rid of nose dependency by only ignoring if you have nose installed - from nose.tools import nottest - @nottest - def tests(verbose=10): - Tester(testing).test(verbose=verbose) -except: - def tests(verbose=10): - Tester(testing).test(verbose=verbose) + +with warnings.catch_warnings(): + warnings.simplefilter('ignore') + try: + #Get rid of nose dependency by only ignoring if you have nose installed + from nose.tools import nottest + @nottest + def tests(verbose=10): + Tester(testing).test(verbose=verbose) + except: + def tests(verbose=10): + Tester(testing).test(verbose=verbose) def load(file_or_path): """ diff --git a/GPy/__version__.py b/GPy/__version__.py index f5b77301..3e8d9f94 100644 --- a/GPy/__version__.py +++ b/GPy/__version__.py @@ -1 +1 @@ -__version__ = "0.9.7" +__version__ = "1.4.0" diff --git a/GPy/core/gp.py b/GPy/core/gp.py index d9db66ef..f0910d9d 100644 --- a/GPy/core/gp.py +++ b/GPy/core/gp.py @@ -2,17 +2,17 @@ # Licensed under the BSD 3-clause license (see LICENSE.txt) import numpy as np -from .. import kern -from GPy.core.model import Model -from paramz import ObsAr +from .model import Model +from .parameterization.variational import VariationalPosterior from .mapping import Mapping from .. import likelihoods +from .. import kern from ..inference.latent_function_inference import exact_gaussian_inference, expectation_propagation -from GPy.core.parameterization.variational import VariationalPosterior +from ..util.normalizer import Standardize +from paramz import ObsAr import logging import warnings -from GPy.util.normalizer import MeanNorm logger = logging.getLogger("GP") class GP(Model): @@ -28,7 +28,7 @@ class GP(Model): :param Norm normalizer: normalize the outputs Y. Prediction will be un-normalized using this normalizer. - If normalizer is None, we will normalize using MeanNorm. + If normalizer is None, we will normalize using Standardize. If normalizer is False, no normalization will be done. .. Note:: Multiple independent outputs are allowed using columns of Y @@ -49,7 +49,7 @@ class GP(Model): logger.info("initializing Y") if normalizer is True: - self.normalizer = MeanNorm() + self.normalizer = Standardize() elif normalizer is False: self.normalizer = None else: @@ -64,6 +64,7 @@ class GP(Model): self.Y_normalized = self.Y else: self.Y = Y + self.Y_normalized = self.Y if Y.shape[0] != self.num_data: #There can be cases where we want inputs than outputs, for example if we have multiple latent @@ -148,14 +149,16 @@ class GP(Model): # LVM models if isinstance(self.X, VariationalPosterior): assert isinstance(X, type(self.X)), "The given X must have the same type as the X in the model!" + index = self.X._parent_index_ self.unlink_parameter(self.X) self.X = X - self.link_parameter(self.X) + self.link_parameter(self.X, index=index) else: + index = self.X._parent_index_ self.unlink_parameter(self.X) from ..core import Param - self.X = Param('latent mean',X) - self.link_parameter(self.X) + self.X = Param('latent mean', X) + self.link_parameter(self.X, index=index) else: self.X = ObsAr(X) self.update_model(True) @@ -217,9 +220,13 @@ class GP(Model): mu += self.mean_function.f(Xnew) return mu, var - def predict(self, Xnew, full_cov=False, Y_metadata=None, kern=None, likelihood=None): + def predict(self, Xnew, full_cov=False, Y_metadata=None, kern=None, likelihood=None, include_likelihood=True): """ - Predict the function(s) at the new point(s) Xnew. + Predict the function(s) at the new point(s) Xnew. This includes the likelihood + variance added to the predicted underlying function (usually referred to as f). + + In order to predict without adding in the likelihood give + `include_likelihood=False`, or refer to self.predict_noiseless(). :param Xnew: The points at which to make a prediction :type Xnew: np.ndarray (Nnew x self.input_dim) @@ -229,6 +236,8 @@ class GP(Model): :param Y_metadata: metadata about the predicting point to pass to the likelihood :param kern: The kernel to use for prediction (defaults to the model kern). this is useful for examining e.g. subprocesses. + :param bool include_likelihood: Whether or not to add likelihood noise to the predicted underlying latent function f. + :returns: (mean, var): mean: posterior mean, a Numpy array, Nnew x self.input_dim var: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise @@ -240,14 +249,45 @@ class GP(Model): """ #predict the latent function values mu, var = self._raw_predict(Xnew, full_cov=full_cov, kern=kern) + + if include_likelihood: + # now push through likelihood + if likelihood is None: + likelihood = self.likelihood + mu, var = likelihood.predictive_values(mu, var, full_cov, Y_metadata=Y_metadata) + if self.normalizer is not None: mu, var = self.normalizer.inverse_mean(mu), self.normalizer.inverse_variance(var) - # now push through likelihood - if likelihood is None: - likelihood = self.likelihood - mean, var = likelihood.predictive_values(mu, var, full_cov, Y_metadata=Y_metadata) - return mean, var + return mu, var + + def predict_noiseless(self, Xnew, full_cov=False, Y_metadata=None, kern=None): + """ + Convenience function to predict the underlying function of the GP (often + referred to as f) without adding the likelihood variance on the + prediction function. + + This is most likely what you want to use for your predictions. + + :param Xnew: The points at which to make a prediction + :type Xnew: np.ndarray (Nnew x self.input_dim) + :param full_cov: whether to return the full covariance matrix, or just + the diagonal + :type full_cov: bool + :param Y_metadata: metadata about the predicting point to pass to the likelihood + :param kern: The kernel to use for prediction (defaults to the model + kern). this is useful for examining e.g. subprocesses. + + :returns: (mean, var): + mean: posterior mean, a Numpy array, Nnew x self.input_dim + var: posterior variance, a Numpy array, Nnew x 1 if full_cov=False, Nnew x Nnew otherwise + + If full_cov and self.input_dim > 1, the return shape of var is Nnew x Nnew x self.input_dim. If self.input_dim == 1, the return shape is Nnew x Nnew. + This is to allow for different normalizations of the output dimensions. + + Note: If you want the predictive quantiles (e.g. 95% confidence interval) use :py:func:"~GPy.core.gp.GP.predict_quantiles". + """ + return self.predict(Xnew, full_cov, Y_metadata, kern, None, False) def predict_quantiles(self, X, quantiles=(2.5, 97.5), Y_metadata=None, kern=None, likelihood=None): """ @@ -263,11 +303,14 @@ class GP(Model): :rtype: [np.ndarray (Xnew x self.output_dim), np.ndarray (Xnew x self.output_dim)] """ m, v = self._raw_predict(X, full_cov=False, kern=kern) - if self.normalizer is not None: - m, v = self.normalizer.inverse_mean(m), self.normalizer.inverse_variance(v) if likelihood is None: likelihood = self.likelihood - return likelihood.predictive_quantiles(m, v, quantiles, Y_metadata=Y_metadata) + + quantiles = likelihood.predictive_quantiles(m, v, quantiles, Y_metadata=Y_metadata) + + if self.normalizer is not None: + quantiles = [self.normalizer.inverse_mean(q) for q in quantiles] + return quantiles def predictive_gradients(self, Xnew, kern=None): """ @@ -300,8 +343,7 @@ class GP(Model): dv_dX += kern.gradients_X(alpha, Xnew, self._predictive_variable) return mean_jac, dv_dX - - def predict_jacobian(self, Xnew, kern=None, full_cov=True): + def predict_jacobian(self, Xnew, kern=None, full_cov=False): """ Compute the derivatives of the posterior of the GP. @@ -319,15 +361,11 @@ class GP(Model): :param X: The points at which to get the predictive gradients. :type X: np.ndarray (Xnew x self.input_dim) :param kern: The kernel to compute the jacobian for. - :param boolean full_cov: whether to return the full covariance of the jacobian. + :param boolean full_cov: whether to return the cross-covariance terms between + the N* Jacobian vectors :returns: dmu_dX, dv_dX :rtype: [np.ndarray (N*, Q ,D), np.ndarray (N*,Q,(D)) ] - - Note: We always return sum in input_dim gradients, as the off-diagonals - in the input_dim are not needed for further calculations. - This is a compromise for increase in speed. Mathematically the jacobian would - have another dimension in Q. """ if kern is None: kern = self.kern @@ -346,24 +384,26 @@ class GP(Model): dK2_dXdX = kern.gradients_XX(one, Xnew) else: dK2_dXdX = kern.gradients_XX_diag(one, Xnew) + #dK2_dXdX = np.zeros((Xnew.shape[0], Xnew.shape[1], Xnew.shape[1])) + #for i in range(Xnew.shape[0]): + # dK2_dXdX[i:i+1,:,:] = kern.gradients_XX(one, Xnew[i:i+1,:]) def compute_cov_inner(wi): if full_cov: - # full covariance gradients: - var_jac = dK2_dXdX - np.einsum('qnm,miq->niq', dK_dXnew_full.T.dot(wi), dK_dXnew_full) + var_jac = dK2_dXdX - np.einsum('qnm,msr->nsqr', dK_dXnew_full.T.dot(wi), dK_dXnew_full) # n,s = Xnew.shape[0], m = pred_var.shape[0] else: - var_jac = dK2_dXdX - np.einsum('qim,miq->iq', dK_dXnew_full.T.dot(wi), dK_dXnew_full) + var_jac = dK2_dXdX - np.einsum('qnm,mnr->nqr', dK_dXnew_full.T.dot(wi), dK_dXnew_full) return var_jac if self.posterior.woodbury_inv.ndim == 3: # Missing data: if full_cov: - var_jac = np.empty((Xnew.shape[0],Xnew.shape[0],Xnew.shape[1],self.output_dim)) + var_jac = np.empty((Xnew.shape[0],Xnew.shape[0],Xnew.shape[1],Xnew.shape[1],self.output_dim)) + for d in range(self.posterior.woodbury_inv.shape[2]): + var_jac[:, :, :, :, d] = compute_cov_inner(self.posterior.woodbury_inv[:, :, d]) + else: + var_jac = np.empty((Xnew.shape[0],Xnew.shape[1],Xnew.shape[1],self.output_dim)) for d in range(self.posterior.woodbury_inv.shape[2]): var_jac[:, :, :, d] = compute_cov_inner(self.posterior.woodbury_inv[:, :, d]) - else: - var_jac = np.empty((Xnew.shape[0],Xnew.shape[1],self.output_dim)) - for d in range(self.posterior.woodbury_inv.shape[2]): - var_jac[:, :, d] = compute_cov_inner(self.posterior.woodbury_inv[:, :, d]) else: var_jac = compute_cov_inner(self.posterior.woodbury_inv) return mean_jac, var_jac @@ -387,10 +427,11 @@ class GP(Model): mu_jac, var_jac = self.predict_jacobian(Xnew, kern, full_cov=False) mumuT = np.einsum('iqd,ipd->iqp', mu_jac, mu_jac) Sigma = np.zeros(mumuT.shape) - if var_jac.ndim == 3: - Sigma[(slice(None), )+np.diag_indices(Xnew.shape[1], 2)] = var_jac.sum(-1) + if var_jac.ndim == 4: # Missing data + Sigma = var_jac.sum(-1) else: - Sigma[(slice(None), )+np.diag_indices(Xnew.shape[1], 2)] = self.output_dim*var_jac + Sigma = self.output_dim*var_jac + G = 0. if mean: G += mumuT @@ -402,15 +443,22 @@ class GP(Model): warnings.warn("Wrong naming, use predict_wishart_embedding instead. Will be removed in future versions!", DeprecationWarning) return self.predict_wishart_embedding(Xnew, kern, mean, covariance) - def predict_magnification(self, Xnew, kern=None, mean=True, covariance=True): + def predict_magnification(self, Xnew, kern=None, mean=True, covariance=True, dimensions=None): """ Predict the magnification factor as sqrt(det(G)) - for each point N in Xnew + for each point N in Xnew. + + :param bool mean: whether to include the mean of the wishart embedding. + :param bool covariance: whether to include the covariance of the wishart embedding. + :param array-like dimensions: which dimensions of the input space to use [defaults to self.get_most_significant_input_dimensions()[:2]] """ - G = self.predict_wishard_embedding(Xnew, kern, mean, covariance) + G = self.predict_wishart_embedding(Xnew, kern, mean, covariance) + if dimensions is None: + dimensions = self.get_most_significant_input_dimensions()[:2] + G = G[:, dimensions][:,:,dimensions] from ..util.linalg import jitchol mag = np.empty(Xnew.shape[0]) for n in range(Xnew.shape[0]): @@ -490,21 +538,23 @@ class GP(Model): def get_most_significant_input_dimensions(self, which_indices=None): return self.kern.get_most_significant_input_dimensions(which_indices) - def optimize(self, optimizer=None, start=None, **kwargs): + def optimize(self, optimizer=None, start=None, messages=False, max_iters=1000, ipython_notebook=True, clear_after_finish=False, **kwargs): """ Optimize the model using self.log_likelihood and self.log_likelihood_gradient, as well as self.priors. kwargs are passed to the optimizer. They can be: - :param max_f_eval: maximum number of function evaluations - :type max_f_eval: int + :param max_iters: maximum number of function evaluations + :type max_iters: int :messages: whether to display during optimisation :type messages: bool :param optimizer: which optimizer to use (defaults to self.preferred optimizer), a range of optimisers can be found in :module:`~GPy.inference.optimization`, they include 'scg', 'lbfgs', 'tnc'. :type optimizer: string + :param bool ipython_notebook: whether to use ipython notebook widgets or not. + :param bool clear_after_finish: if in ipython notebook, we can clear the widgets after optimization. """ self.inference_method.on_optimization_start() try: - super(GP, self).optimize(optimizer, start, **kwargs) + super(GP, self).optimize(optimizer, start, messages, max_iters, ipython_notebook, clear_after_finish, **kwargs) except KeyboardInterrupt: print("KeyboardInterrupt caught, calling on_optimization_end() to round things up") self.inference_method.on_optimization_end() diff --git a/GPy/core/parameterization/priorizable.py b/GPy/core/parameterization/priorizable.py index 1d1153c7..eb82e862 100644 --- a/GPy/core/parameterization/priorizable.py +++ b/GPy/core/parameterization/priorizable.py @@ -16,7 +16,7 @@ class Priorizable(Parameterizable): def __setstate__(self, state): super(Priorizable, self).__setstate__(state) - self._index_operations['priors'] = self.priors + #self._index_operations['priors'] = self.priors #=========================================================================== diff --git a/GPy/core/parameterization/priors.py b/GPy/core/parameterization/priors.py index cb7699eb..71b9833e 100644 --- a/GPy/core/parameterization/priors.py +++ b/GPy/core/parameterization/priors.py @@ -773,7 +773,7 @@ class DGPLVM_Lamda(Prior, Parameterized): def compute_cls(self, x): cls = {} # Appending each data point to its proper class - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in cls: cls[class_label] = [] @@ -792,7 +792,7 @@ class DGPLVM_Lamda(Prior, Parameterized): # Adding data points as tuple to the dictionary so that we can access indices def compute_indices(self, x): data_idx = {} - for j in xrange(self.datanum): + for j in range(self.datanum): class_label = self.get_class_label(self.lbl[j]) if class_label not in data_idx: data_idx[class_label] = [] @@ -811,7 +811,7 @@ class DGPLVM_Lamda(Prior, Parameterized): else: lst_idx = [] # Here we put indices of each class in to the list called lst_idx_all - for m in xrange(len(data_idx[i])): + for m in range(len(data_idx[i])): lst_idx.append(data_idx[i][m][0]) lst_idx_all.append(lst_idx) return lst_idx_all @@ -847,7 +847,7 @@ class DGPLVM_Lamda(Prior, Parameterized): # pdb.set_trace() # Calculating Bi B_i[i] = (M_i[i] - M_0).reshape(1, self.dim) - for k in xrange(self.datanum): + for k in range(self.datanum): for i in data_idx: N_i = float(len(data_idx[i])) if k in lst_idx_all[i]: @@ -1309,3 +1309,52 @@ class Exponential(Prior): def rvs(self, n): return np.random.exponential(scale=self.l, size=n) + +class StudentT(Prior): + """ + Implementation of the student t probability function, coupled with random variables. + + :param mu: mean + :param sigma: standard deviation + :param nu: degrees of freedom + + .. Note:: Bishop 2006 notation is used throughout the code + + """ + domain = _REAL + _instances = [] + + def __new__(cls, mu=0, sigma=1, nu=4): # Singleton: + if cls._instances: + cls._instances[:] = [instance for instance in cls._instances if instance()] + for instance in cls._instances: + if instance().mu == mu and instance().sigma == sigma and instance().nu == nu: + return instance() + newfunc = super(Prior, cls).__new__ + if newfunc is object.__new__: + o = newfunc(cls) + else: + o = newfunc(cls, mu, sigma, nu) + cls._instances.append(weakref.ref(o)) + return cls._instances[-1]() + + def __init__(self, mu, sigma, nu): + self.mu = float(mu) + self.sigma = float(sigma) + self.sigma2 = np.square(self.sigma) + self.nu = float(nu) + + def __str__(self): + return "St({:.2g}, {:.2g}, {:.2g})".format(self.mu, self.sigma, self.nu) + + def lnpdf(self, x): + from scipy.stats import t + return t.logpdf(x,self.nu,self.mu,self.sigma) + + def lnpdf_grad(self, x): + return -(self.nu + 1.)*(x - self.mu)/( self.nu*self.sigma2 + np.square(x - self.mu) ) + + def rvs(self, n): + from scipy.stats import t + ret = t.rvs(self.nu, loc=self.mu, scale=self.sigma, size=n) + return ret diff --git a/GPy/core/symbolic.py b/GPy/core/symbolic.py index 4a9fcb76..c4261e24 100644 --- a/GPy/core/symbolic.py +++ b/GPy/core/symbolic.py @@ -111,8 +111,8 @@ class Symbolic_core(): # rows = func['function'].shape[0] # cols = func['function'].shape[1] # self.expressions[key]['derivative'] = sym.zeros(rows, cols) - # for i in xrange(rows): - # for j in xrange(cols): + # for i in range(rows): + # for j in range(cols): # self.expressions[key]['derivative'][i, j] = extract_derivative(func['function'][i, j], derivative_arguments) # else: self.expressions[key]['derivative'] = extract_derivative(func['function'], derivative_arguments) @@ -123,7 +123,7 @@ class Symbolic_core(): val = 1.0 # TODO: improve approach for initializing parameters. if parameters is not None: - if parameters.has_key(theta.name): + if theta.name in parameters: val = parameters[theta.name] # Add parameter. @@ -176,7 +176,7 @@ class Symbolic_core(): return gradient def eval_gradients_X(self, function, partial, **kwargs): - if kwargs.has_key('X'): + if 'X' in kwargs: gradients_X = np.zeros_like(kwargs['X']) self.eval_update_cache(**kwargs) for i, theta in enumerate(self.variables['X']): @@ -405,7 +405,7 @@ class Symbolic_core(): if var_name == var.name: expr = expr.subs(var, sub) break - for m, r in function_substitutes.iteritems(): + for m, r in function_substitutes.items(): expr = expr.replace(m, r)#normcdfln, lambda arg : sym.log(normcdf(arg))) return expr.simplify() @@ -417,4 +417,4 @@ class Symbolic_core(): else: return x[0] - return sorted(var_dict.iteritems(), key=sort_key, reverse=reverse) + return sorted(var_dict.items(), key=sort_key, reverse=reverse) diff --git a/GPy/examples/dimensionality_reduction.py b/GPy/examples/dimensionality_reduction.py index ce1c89e8..81e1b773 100644 --- a/GPy/examples/dimensionality_reduction.py +++ b/GPy/examples/dimensionality_reduction.py @@ -184,7 +184,7 @@ def bgplvm_oil(optimize=True, verbose=1, plot=True, N=200, Q=7, num_inducing=40, data_show = GPy.plotting.matplot_dep.visualize.vector_show((m.Y[0, :])) lvm_visualizer = GPy.plotting.matplot_dep.visualize.lvm_dimselect(m.X.mean.values[0:1, :], # @UnusedVariable m, data_show, latent_axes=latent_axes, sense_axes=sense_axes, labels=m.data_labels) - raw_input('Press enter to finish') + input('Press enter to finish') plt.close(fig) return m @@ -210,7 +210,7 @@ def ssgplvm_oil(optimize=True, verbose=1, plot=True, N=200, Q=7, num_inducing=40 data_show = GPy.plotting.matplot_dep.visualize.vector_show((m.Y[0, :])) lvm_visualizer = GPy.plotting.matplot_dep.visualize.lvm_dimselect(m.X.mean.values[0:1, :], # @UnusedVariable m, data_show, latent_axes=latent_axes, sense_axes=sense_axes, labels=m.data_labels) - raw_input('Press enter to finish') + input('Press enter to finish') plt.close(fig) return m @@ -242,7 +242,7 @@ def _simulate_matern(D1, D2, D3, N, num_inducing, plot_sim=False): fig.clf() ax = fig.add_subplot(2, 1, 1) labls = slist_names - for S, lab in itertools.izip(slist, labls): + for S, lab in zip(slist, labls): ax.plot(S, label=lab) ax.legend() for i, Y in enumerate(Ylist): @@ -288,7 +288,7 @@ def _simulate_sincos(D1, D2, D3, N, num_inducing, plot_sim=False): fig.clf() ax = fig.add_subplot(2, 1, 1) labls = slist_names - for S, lab in itertools.izip(slist, labls): + for S, lab in zip(slist, labls): ax.plot(S, label=lab) ax.legend() for i, Y in enumerate(Ylist): @@ -340,7 +340,7 @@ def bgplvm_simulation(optimize=True, verbose=1, gtol=.05) if plot: m.X.plot("BGPLVM Latent Space 1D") - m.kern.plot_ARD('BGPLVM Simulation ARD Parameters') + m.kern.plot_ARD() return m def gplvm_simulation(optimize=True, verbose=1, @@ -364,7 +364,7 @@ def gplvm_simulation(optimize=True, verbose=1, gtol=.05) if plot: m.X.plot("BGPLVM Latent Space 1D") - m.kern.plot_ARD('BGPLVM Simulation ARD Parameters') + m.kern.plot_ARD() return m def ssgplvm_simulation(optimize=True, verbose=1, plot=True, plot_sim=False, @@ -388,7 +388,7 @@ def ssgplvm_simulation(optimize=True, verbose=1, gtol=.05) if plot: m.X.plot("SSGPLVM Latent Space 1D") - m.kern.plot_ARD('SSGPLVM Simulation ARD Parameters') + m.kern.plot_ARD() return m def bgplvm_simulation_missing_data(optimize=True, verbose=1, @@ -418,7 +418,7 @@ def bgplvm_simulation_missing_data(optimize=True, verbose=1, gtol=.05) if plot: m.X.plot("BGPLVM Latent Space 1D") - m.kern.plot_ARD('BGPLVM Simulation ARD Parameters') + m.kern.plot_ARD() return m def bgplvm_simulation_missing_data_stochastics(optimize=True, verbose=1, @@ -448,7 +448,7 @@ def bgplvm_simulation_missing_data_stochastics(optimize=True, verbose=1, gtol=.05) if plot: m.X.plot("BGPLVM Latent Space 1D") - m.kern.plot_ARD('BGPLVM Simulation ARD Parameters') + m.kern.plot_ARD() return m @@ -469,7 +469,7 @@ def mrd_simulation(optimize=True, verbose=True, plot=True, plot_sim=True, **kw): m.optimize(messages=verbose, max_iters=8e3) if plot: m.X.plot("MRD Latent Space 1D") - m.plot_scales("MRD Scales") + m.plot_scales() return m def mrd_simulation_missing_data(optimize=True, verbose=True, plot=True, plot_sim=True, **kw): @@ -496,7 +496,7 @@ def mrd_simulation_missing_data(optimize=True, verbose=True, plot=True, plot_sim m.optimize('bfgs', messages=verbose, max_iters=8e3, gtol=.1) if plot: m.X.plot("MRD Latent Space 1D") - m.plot_scales("MRD Scales") + m.plot_scales() return m def brendan_faces(optimize=True, verbose=True, plot=True): @@ -520,7 +520,7 @@ def brendan_faces(optimize=True, verbose=True, plot=True): y = m.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.image_show(y[None, :], dimensions=(20, 28), transpose=True, order='F', invert=False, scale=False) lvm = GPy.plotting.matplot_dep.visualize.lvm(m.X.mean[0, :].copy(), m, data_show, ax) - raw_input('Press enter to finish') + input('Press enter to finish') return m @@ -542,7 +542,7 @@ def olivetti_faces(optimize=True, verbose=True, plot=True): y = m.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.image_show(y[None, :], dimensions=(112, 92), transpose=False, invert=False, scale=False) lvm = GPy.plotting.matplot_dep.visualize.lvm(m.X.mean[0, :].copy(), m, data_show, ax) - raw_input('Press enter to finish') + input('Press enter to finish') return m @@ -577,7 +577,7 @@ def stick(kernel=None, optimize=True, verbose=True, plot=True): y = m.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.stick_show(y[None, :], connect=data['connect']) lvm_visualizer = GPy.plotting.matplot_dep.visualize.lvm(m.X[:1, :].copy(), m, data_show, latent_axes=ax) - raw_input('Press enter to finish') + input('Press enter to finish') lvm_visualizer.close() data_show.close() return m @@ -598,7 +598,7 @@ def bcgplvm_linear_stick(kernel=None, optimize=True, verbose=True, plot=True): y = m.likelihood.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.stick_show(y[None, :], connect=data['connect']) GPy.plotting.matplot_dep.visualize.lvm(m.X[0, :].copy(), m, data_show, ax) - raw_input('Press enter to finish') + input('Press enter to finish') return m @@ -619,7 +619,7 @@ def bcgplvm_stick(kernel=None, optimize=True, verbose=True, plot=True): y = m.likelihood.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.stick_show(y[None, :], connect=data['connect']) GPy.plotting.matplot_dep.visualize.lvm(m.X[0, :].copy(), m, data_show, ax) - # raw_input('Press enter to finish') + # input('Press enter to finish') return m @@ -669,7 +669,7 @@ def stick_bgplvm(model=None, optimize=True, verbose=True, plot=True): fig.canvas.draw() # Canvas.show doesn't work on OSX. #fig.canvas.show() - raw_input('Press enter to finish') + input('Press enter to finish') return m @@ -693,7 +693,7 @@ def cmu_mocap(subject='35', motion=['01'], in_place=True, optimize=True, verbose y = m.Y[0, :] data_show = GPy.plotting.matplot_dep.visualize.skeleton_show(y[None, :], data['skel']) lvm_visualizer = GPy.plotting.matplot_dep.visualize.lvm(m.X[0].copy(), m, data_show, latent_axes=ax) - raw_input('Press enter to finish') + input('Press enter to finish') lvm_visualizer.close() data_show.close() diff --git a/GPy/examples/regression.py b/GPy/examples/regression.py index 11734564..19919f97 100644 --- a/GPy/examples/regression.py +++ b/GPy/examples/regression.py @@ -550,3 +550,34 @@ def parametric_mean_function(max_iters=100, optimize=True, plot=True): return m +def warped_gp_cubic_sine(max_iters=100): + """ + A test replicating the cubic sine regression problem from + Snelson's paper. + """ + X = (2 * np.pi) * np.random.random(151) - np.pi + Y = np.sin(X) + np.random.normal(0,0.2,151) + Y = np.array([np.power(abs(y),float(1)/3) * (1,-1)[y<0] for y in Y]) + X = X[:, None] + Y = Y[:, None] + + warp_k = GPy.kern.RBF(1) + warp_f = GPy.util.warping_functions.TanhFunction(n_terms=2) + warp_m = GPy.models.WarpedGP(X, Y, kernel=warp_k, warping_function=warp_f) + warp_m['.*\.d'].constrain_fixed(1.0) + m = GPy.models.GPRegression(X, Y) + m.optimize_restarts(parallel=False, robust=True, num_restarts=5, max_iters=max_iters) + warp_m.optimize_restarts(parallel=False, robust=True, num_restarts=5, max_iters=max_iters) + #m.optimize(max_iters=max_iters) + #warp_m.optimize(max_iters=max_iters) + + print(warp_m) + print(warp_m['.*warp.*']) + + warp_m.predict_in_warped_space = False + warp_m.plot(title="Warped GP - Latent space") + warp_m.predict_in_warped_space = True + warp_m.plot(title="Warped GP - Warped space") + m.plot(title="Standard GP") + warp_m.plot_warping() + pb.show() diff --git a/GPy/examples/state_space.py b/GPy/examples/state_space.py new file mode 100644 index 00000000..5a213f45 --- /dev/null +++ b/GPy/examples/state_space.py @@ -0,0 +1,26 @@ +import GPy +import numpy as np +import matplotlib.pyplot as plt + +import GPy.models.state_space_model as SS_model + +X = np.linspace(0, 10, 2000)[:, None] +Y = np.sin(X) + np.random.randn(*X.shape)*0.1 + +kernel1 = GPy.kern.Matern32(X.shape[1]) +m1 = GPy.models.GPRegression(X,Y, kernel1) + +print(m1) +m1.optimize(optimizer='bfgs',messages=True) + +print(m1) + +kernel2 = GPy.kern.sde_Matern32(X.shape[1]) +#m2 = SS_model.StateSpace(X,Y, kernel2) +m2 = GPy.models.StateSpace(X,Y, kernel2) +print(m2) + +m2.optimize(optimizer='bfgs',messages=True) + +print(m2) + diff --git a/GPy/inference/latent_function_inference/exact_gaussian_inference.py b/GPy/inference/latent_function_inference/exact_gaussian_inference.py index 74f66fe6..a5519774 100644 --- a/GPy/inference/latent_function_inference/exact_gaussian_inference.py +++ b/GPy/inference/latent_function_inference/exact_gaussian_inference.py @@ -21,7 +21,7 @@ class ExactGaussianInference(LatentFunctionInference): def __init__(self): pass#self._YYTfactor_cache = caching.cache() - def inference(self, kern, X, likelihood, Y, mean_function=None, Y_metadata=None, K=None, precision=None, Z_tilde=None): + def inference(self, kern, X, likelihood, Y, mean_function=None, Y_metadata=None, K=None, variance=None, Z_tilde=None): """ Returns a Posterior class containing essential quantities of the posterior """ @@ -31,8 +31,8 @@ class ExactGaussianInference(LatentFunctionInference): else: m = mean_function.f(X) - if precision is None: - precision = likelihood.gaussian_variance(Y_metadata) + if variance is None: + variance = likelihood.gaussian_variance(Y_metadata) YYT_factor = Y-m @@ -40,7 +40,7 @@ class ExactGaussianInference(LatentFunctionInference): K = kern.K(X) Ky = K.copy() - diag.add(Ky, precision+1e-8) + diag.add(Ky, variance+1e-8) Wi, LW, LWi, W_logdet = pdinv(Ky) diff --git a/GPy/inference/latent_function_inference/expectation_propagation.py b/GPy/inference/latent_function_inference/expectation_propagation.py index b2a3d4b6..01560b3c 100644 --- a/GPy/inference/latent_function_inference/expectation_propagation.py +++ b/GPy/inference/latent_function_inference/expectation_propagation.py @@ -40,6 +40,14 @@ class EPBase(object): # TODO: update approximation in the end as well? Maybe even with a switch? pass + def __setstate__(self, state): + super(EPBase, self).__setstate__(state[0]) + self.epsilon, self.eta, self.delta = state[1] + self.reset() + + def __getstate__(self): + return [super(EPBase, self).__getstate__() , [self.epsilon, self.eta, self.delta]] + class EP(EPBase, ExactGaussianInference): def inference(self, kern, X, likelihood, Y, mean_function=None, Y_metadata=None, precision=None, K=None): if self.always_reset: @@ -51,14 +59,14 @@ class EP(EPBase, ExactGaussianInference): if K is None: K = kern.K(X) - if self._ep_approximation is None: + if getattr(self, '_ep_approximation', None) is None: #if we don't yet have the results of runnign EP, run EP and store the computed factors in self._ep_approximation mu, Sigma, mu_tilde, tau_tilde, Z_tilde = self._ep_approximation = self.expectation_propagation(K, Y, likelihood, Y_metadata) else: #if we've already run EP, just use the existing approximation stored in self._ep_approximation mu, Sigma, mu_tilde, tau_tilde, Z_tilde = self._ep_approximation - return super(EP, self).inference(kern, X, likelihood, mu_tilde[:,None], mean_function=mean_function, Y_metadata=Y_metadata, precision=1./tau_tilde, K=K, Z_tilde=np.log(Z_tilde).sum()) + return super(EP, self).inference(kern, X, likelihood, mu_tilde[:,None], mean_function=mean_function, Y_metadata=Y_metadata, variance=1./tau_tilde, K=K, Z_tilde=np.log(Z_tilde).sum()) def expectation_propagation(self, K, Y, likelihood, Y_metadata): @@ -159,7 +167,7 @@ class EPDTC(EPBase, VarDTC): else: Kmn = psi1.T - if self._ep_approximation is None: + if getattr(self, '_ep_approximation', None) is None: mu, Sigma, mu_tilde, tau_tilde, Z_tilde = self._ep_approximation = self.expectation_propagation(Kmm, Kmn, Y, likelihood, Y_metadata) else: mu, Sigma, mu_tilde, tau_tilde, Z_tilde = self._ep_approximation diff --git a/GPy/inference/latent_function_inference/var_dtc.py b/GPy/inference/latent_function_inference/var_dtc.py index dc334059..ec055120 100644 --- a/GPy/inference/latent_function_inference/var_dtc.py +++ b/GPy/inference/latent_function_inference/var_dtc.py @@ -22,7 +22,7 @@ class VarDTC(LatentFunctionInference): """ const_jitter = 1e-8 - def __init__(self, limit=3): + def __init__(self, limit=1): from paramz.caching import Cacher self.limit = limit self.get_trYYT = Cacher(self._get_trYYT, limit) diff --git a/GPy/kern/__init__.py b/GPy/kern/__init__.py index 62796d93..c9304f39 100644 --- a/GPy/kern/__init__.py +++ b/GPy/kern/__init__.py @@ -10,7 +10,7 @@ from .src.add import Add from .src.prod import Prod from .src.rbf import RBF from .src.linear import Linear, LinearFull -from .src.static import Bias, White, Fixed, WhiteHeteroscedastic +from .src.static import Bias, White, Fixed, WhiteHeteroscedastic, Precomputed from .src.brownian import Brownian from .src.stationary import Exponential, OU, Matern32, Matern52, ExpQuad, RatQuad, Cosine from .src.mlp import MLP @@ -24,8 +24,20 @@ from .src.ODE_st import ODE_st from .src.ODE_t import ODE_t from .src.poly import Poly from .src.eq_ode2 import EQ_ODE2 +from .src.integral import Integral +from .src.integral_limits import Integral_Limits +from .src.multidimensional_integral_limits import Multidimensional_Integral_Limits +from .src.eq_ode1 import EQ_ODE1 from .src.trunclinear import TruncLinear,TruncLinear_inf from .src.splitKern import SplitKern,DEtime from .src.splitKern import DEtime as DiffGenomeKern from .src.spline import Spline from .src.basis_funcs import LogisticBasisFuncKernel, LinearSlopeBasisFuncKernel, BasisFuncKernel, ChangePointBasisFuncKernel, DomainKernel + +from .src.sde_matern import sde_Matern32 +from .src.sde_matern import sde_Matern52 +from .src.sde_linear import sde_Linear +from .src.sde_standard_periodic import sde_StdPeriodic +from .src.sde_static import sde_White, sde_Bias +from .src.sde_stationary import sde_RBF,sde_Exponential,sde_RatQuad +from .src.sde_brownian import sde_Brownian diff --git a/GPy/kern/_src/sde_brownian.py b/GPy/kern/_src/sde_brownian.py new file mode 100644 index 00000000..55950143 --- /dev/null +++ b/GPy/kern/_src/sde_brownian.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance Brownian motion covariance function with the +Stochastic Differential Equation (SDE) functionality. +""" + +from .brownian import Brownian + +import numpy as np + +class sde_Brownian(Brownian): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Linear kernel: + + .. math:: + + k(x,y) = \sigma^2 min(x,y) + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) # this is initial variancve in Bayesian linear regression + + F = np.array( ((0,1.0),(0,0) )) + L = np.array( ((1.0,),(0,)) ) + Qc = np.array( ((variance,),) ) + H = np.array( ((1.0,0),) ) + + Pinf = np.array( ( (0, -0.5*variance ), (-0.5*variance, 0) ) ) + #P0 = Pinf.copy() + P0 = np.zeros((2,2)) + #Pinf = np.array( ( (t0, 1.0), (1.0, 1.0/t0) ) ) * variance + dF = np.zeros((2,2,1)) + dQc = np.ones( (1,1,1) ) + + dPinf = np.zeros((2,2,1)) + dPinf[:,:,0] = np.array( ( (0, -0.5), (-0.5, 0) ) ) + #dP0 = dPinf.copy() + dP0 = np.zeros((2,2,1)) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) diff --git a/GPy/kern/_src/sde_linear.py b/GPy/kern/_src/sde_linear.py new file mode 100644 index 00000000..031f0f5f --- /dev/null +++ b/GPy/kern/_src/sde_linear.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance Linear covariance function with the +Stochastic Differential Equation (SDE) functionality. +""" +from .linear import Linear + +import numpy as np + +class sde_Linear(Linear): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Linear kernel: + + .. math:: + + k(x,y) = \sum_{i=1}^{input dim} \sigma^2_i x_iy_i + + """ + def __init__(self, input_dim, X, variances=None, ARD=False, active_dims=None, name='linear'): + """ + Modify the init method, because one extra parameter is required. X - points + on the X axis. + """ + + super(sde_Linear, self).__init__(input_dim, variances, ARD, active_dims, name) + + self.t0 = np.min(X) + + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variances.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variances.values) # this is initial variancve in Bayesian linear regression + t0 = float(self.t0) + + F = np.array( ((0,1.0),(0,0) )) + L = np.array( ((0,),(1.0,)) ) + Qc = np.zeros((1,1)) + H = np.array( ((1.0,0),) ) + + Pinf = np.zeros((2,2)) + P0 = np.array( ( (t0**2, t0), (t0, 1) ) ) * variance + dF = np.zeros((2,2,1)) + dQc = np.zeros( (1,1,1) ) + + dPinf = np.zeros((2,2,1)) + dP0 = np.zeros((2,2,1)) + dP0[:,:,0] = P0 / variance + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) diff --git a/GPy/kern/_src/sde_matern.py b/GPy/kern/_src/sde_matern.py new file mode 100644 index 00000000..0ce1cf98 --- /dev/null +++ b/GPy/kern/_src/sde_matern.py @@ -0,0 +1,135 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance Matern covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .stationary import Matern32 +from .stationary import Matern52 +import numpy as np + +class sde_Matern32(Matern32): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Matern 3/2 kernel: + + .. math:: + + k(r) = \sigma^2 (1 + \sqrt{3} r) \exp(- \sqrt{3} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + lengthscale = float(self.lengthscale.values) + + foo = np.sqrt(3.)/lengthscale + F = np.array(((0, 1.0), (-foo**2, -2*foo))) + L = np.array(( (0,), (1.0,) )) + Qc = np.array(((12.*np.sqrt(3) / lengthscale**3 * variance,),)) + H = np.array(((1.0, 0),)) + Pinf = np.array(((variance, 0.0), (0.0, 3.*variance/(lengthscale**2)))) + P0 = Pinf.copy() + + # Allocate space for the derivatives + dF = np.empty([F.shape[0],F.shape[1],2]) + dQc = np.empty([Qc.shape[0],Qc.shape[1],2]) + dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2]) + # The partial derivatives + dFvariance = np.zeros((2,2)) + dFlengthscale = np.array(((0,0), (6./lengthscale**3,2*np.sqrt(3)/lengthscale**2))) + dQcvariance = np.array((12.*np.sqrt(3)/lengthscale**3)) + dQclengthscale = np.array((-3*12*np.sqrt(3)/lengthscale**4*variance)) + dPinfvariance = np.array(((1,0),(0,3./lengthscale**2))) + dPinflengthscale = np.array(((0,0), (0,-6*variance/lengthscale**3))) + # Combine the derivatives + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinfvariance + dPinf[:,:,1] = dPinflengthscale + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_Matern52(Matern52): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Matern 5/2 kernel: + + .. math:: + + k(r) = \sigma^2 (1 + \sqrt{5} r + \frac{5}{3}r^2) \exp(- \sqrt{5} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + lengthscale = float(self.lengthscale.values) + + lamda = np.sqrt(5.0)/lengthscale + kappa = 5.0/3.0*variance/lengthscale**2 + + F = np.array(((0, 1,0), (0, 0, 1), (-lamda**3, -3.0*lamda**2, -3*lamda))) + L = np.array(((0,),(0,),(1,))) + Qc = np.array((((variance*400.0*np.sqrt(5.0)/3.0/lengthscale**5),),)) + H = np.array(((1,0,0),)) + + Pinf = np.array(((variance,0,-kappa), (0, kappa, 0), (-kappa, 0, 25.0*variance/lengthscale**4))) + P0 = Pinf.copy() + # Allocate space for the derivatives + dF = np.empty((3,3,2)) + dQc = np.empty((1,1,2)) + dPinf = np.empty((3,3,2)) + + # The partial derivatives + dFvariance = np.zeros((3,3)) + dFlengthscale = np.array(((0,0,0),(0,0,0),(15.0*np.sqrt(5.0)/lengthscale**4, + 30.0/lengthscale**3, 3*np.sqrt(5.0)/lengthscale**2))) + dQcvariance = np.array((((400*np.sqrt(5)/3/lengthscale**5,),))) + dQclengthscale = np.array((((-variance*2000*np.sqrt(5)/3/lengthscale**6,),))) + + dPinf_variance = Pinf/variance + kappa2 = -2.0*kappa/lengthscale + dPinf_lengthscale = np.array(((0,0,-kappa2),(0,kappa2,0),(-kappa2, + 0,-100*variance/lengthscale**5))) + # Combine the derivatives + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinf_variance + dPinf[:,:,1] = dPinf_lengthscale + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) \ No newline at end of file diff --git a/GPy/kern/_src/sde_standard_periodic.py b/GPy/kern/_src/sde_standard_periodic.py new file mode 100644 index 00000000..c3df7d92 --- /dev/null +++ b/GPy/kern/_src/sde_standard_periodic.py @@ -0,0 +1,178 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance Matern covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .standard_periodic import StdPeriodic + +import numpy as np +import scipy as sp + +from scipy import special as special + +class sde_StdPeriodic(StdPeriodic): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Standard Periodic kernel: + + .. math:: + + k(x,y) = \theta_1 \exp \left[ - \frac{1}{2} {}\sum_{i=1}^{input\_dim} + \left( \frac{\sin(\frac{\pi}{\lambda_i} (x_i - y_i) )}{l_i} \right)^2 \right] } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.wavelengths.gradient = gradients[1] + self.lengthscales.gradient = gradients[2] + + def sde(self): + """ + Return the state space representation of the covariance. + + + ! Note: one must constrain lengthscale not to drop below 0.25. + After this bessel functions of the first kind grows to very high. + + ! Note: one must keep wevelength also not very low. Because then + the gradients wrt wavelength become ustable. + However this might depend on the data. For test example with + 300 data points the low limit is 0.15. + """ + + # Params to use: (in that order) + #self.variance + #self.wavelengths + #self.lengthscales + N = 7 # approximation order + + + w0 = 2*np.pi/self.wavelengths # frequency + lengthscales = 2*self.lengthscales + + [q2,dq2l] = seriescoeff(N,lengthscales,self.variance) + # lengthscale is multiplied by 2 because of slightly different + # formula for periodic covariance function. + # For the same reason: + + dq2l = 2*dq2l + + if np.any( np.isfinite(q2) == False): + raise ValueError("SDE periodic covariance error 1") + + if np.any( np.isfinite(dq2l) == False): + raise ValueError("SDE periodic covariance error 2") + + F = np.kron(np.diag(range(0,N+1)),np.array( ((0, -w0), (w0, 0)) ) ) + L = np.eye(2*(N+1)) + Qc = np.zeros((2*(N+1), 2*(N+1))) + P_inf = np.kron(np.diag(q2),np.eye(2)) + H = np.kron(np.ones((1,N+1)),np.array((1,0)) ) + P0 = P_inf.copy() + + # Derivatives + dF = np.empty((F.shape[0], F.shape[1], 3)) + dQc = np.empty((Qc.shape[0], Qc.shape[1], 3)) + dP_inf = np.empty((P_inf.shape[0], P_inf.shape[1], 3)) + + # Derivatives wrt self.variance + dF[:,:,0] = np.zeros(F.shape) + dQc[:,:,0] = np.zeros(Qc.shape) + dP_inf[:,:,0] = P_inf / self.variance + + # Derivatives self.wavelengths + dF[:,:,1] = np.kron(np.diag(range(0,N+1)),np.array( ((0, w0), (-w0, 0)) ) / self.wavelengths ); + dQc[:,:,1] = np.zeros(Qc.shape) + dP_inf[:,:,1] = np.zeros(P_inf.shape) + + # Derivatives self.lengthscales + dF[:,:,2] = np.zeros(F.shape) + dQc[:,:,2] = np.zeros(Qc.shape) + dP_inf[:,:,2] = np.kron(np.diag(dq2l),np.eye(2)) + dP0 = dP_inf.copy() + + return (F, L, Qc, H, P_inf, P0, dF, dQc, dP_inf, dP0) + + + + +def seriescoeff(m=6,lengthScale=1.0,magnSigma2=1.0, true_covariance=False): + """ + Calculate the coefficients q_j^2 for the covariance function + approximation: + + k(\tau) = \sum_{j=0}^{+\infty} q_j^2 \cos(j\omega_0 \tau) + + Reference is: + + [1] Arno Solin and Simo Särkkä (2014). Explicit link between periodic + covariance functions and state space models. In Proceedings of the + Seventeenth International Conference on Artifcial Intelligence and + Statistics (AISTATS 2014). JMLR: W&CP, volume 33. + + Note! Only the infinite approximation (through Bessel function) + is currently implemented. + + Input: + ---------------- + + m: int + Degree of approximation. Default 6. + lengthScale: float + Length scale parameter in the kerenl + magnSigma2:float + Multiplier in front of the kernel. + + + Output: + ----------------- + + coeffs: array(m+1) + Covariance series coefficients + + coeffs_dl: array(m+1) + Derivatives of the coefficients with respect to lengthscale. + + """ + + if true_covariance: + + bb = lambda j,m: (1.0 + np.array((j != 0), dtype=np.float64) ) / (2**(j)) *\ + sp.special.binom(j, sp.floor( (j-m)/2.0 * np.array(m<=j, dtype=np.float64) ))*\ + np.array(m<=j, dtype=np.float64) *np.array(sp.mod(j-m,2)==0, dtype=np.float64) + + M,J = np.meshgrid(range(0,m+1),range(0,m+1)) + + coeffs = bb(J,M) / sp.misc.factorial(J) * sp.exp( -lengthScale**(-2) ) *\ + (lengthScale**(-2))**J *magnSigma2 + + coeffs_dl = np.sum( coeffs*lengthScale**(-3)*(2.0-2.0*J*lengthScale**2),0) + + coeffs = np.sum(coeffs,0) + + else: + coeffs = 2*magnSigma2*sp.exp( -lengthScale**(-2) ) * special.iv(range(0,m+1),1.0/lengthScale**(2)) + if np.any( np.isfinite(coeffs) == False): + raise ValueError("sde_standard_periodic: Coefficients are not finite!") + #import pdb; pdb.set_trace() + coeffs[0] = 0.5*coeffs[0] + + # Derivatives wrt (lengthScale) + coeffs_dl = np.zeros(m+1) + coeffs_dl[1:] = magnSigma2*lengthScale**(-3) * sp.exp(-lengthScale**(-2))*\ + (-4*special.iv(range(0,m),lengthScale**(-2)) + 4*(1+np.arange(1,m+1)*lengthScale**(2))*special.iv(range(1,m+1),lengthScale**(-2)) ) + + # The first element + coeffs_dl[0] = magnSigma2*lengthScale**(-3) * np.exp(-lengthScale**(-2))*\ + (2*special.iv(0,lengthScale**(-2)) - 2*special.iv(1,lengthScale**(-2)) ) + + + return coeffs, coeffs_dl diff --git a/GPy/kern/_src/sde_static.py b/GPy/kern/_src/sde_static.py new file mode 100644 index 00000000..ae8ed194 --- /dev/null +++ b/GPy/kern/_src/sde_static.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance Static covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .static import White +from .static import Bias + +import numpy as np + +class sde_White(White): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + White kernel: + + .. math:: + + k(x,y) = \alpha*\delta(x-y) + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + + F = np.array( ((-np.inf,),) ) + L = np.array( ((1.0,),) ) + Qc = np.array( ((variance,),) ) + H = np.array( ((1.0,),) ) + + Pinf = np.array( ((variance,),) ) + P0 = Pinf.copy() + + dF = np.zeros((1,1,1)) + dQc = np.zeros((1,1,1)) + dQc[:,:,0] = np.array( ((1.0,),) ) + + dPinf = np.zeros((1,1,1)) + dPinf[:,:,0] = np.array( ((1.0,),) ) + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + + +class sde_Bias(Bias): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Bias kernel: + + .. math:: + + k(x,y) = \alpha + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + variance = float(self.variance.values) + + F = np.array( ((0.0,),)) + L = np.array( ((1.0,),)) + Qc = np.zeros((1,1)) + H = np.array( ((1.0,),)) + + Pinf = np.zeros((1,1)) + P0 = np.array( ((variance,),) ) + + dF = np.zeros((1,1,1)) + dQc = np.zeros((1,1,1)) + + dPinf = np.zeros((1,1,1)) + dP0 = np.zeros((1,1,1)) + dP0[:,:,0] = np.array( ((1.0,),) ) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) \ No newline at end of file diff --git a/GPy/kern/_src/sde_stationary.py b/GPy/kern/_src/sde_stationary.py new file mode 100644 index 00000000..9504c5c3 --- /dev/null +++ b/GPy/kern/_src/sde_stationary.py @@ -0,0 +1,190 @@ +# -*- coding: utf-8 -*- +""" +Classes in this module enhance several stationary covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .rbf import RBF +from .stationary import Exponential +from .stationary import RatQuad + +import numpy as np +import scipy as sp + +class sde_RBF(RBF): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Radial Basis Function kernel: + + .. math:: + + k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + N = 10# approximation order ( number of terms in exponent series expansion) + roots_rounding_decimals = 6 + + fn = np.math.factorial(N) + + kappa = 1.0/2.0/self.lengthscale**2 + + Qc = np.array((self.variance*np.sqrt(np.pi/kappa)*fn*(4*kappa)**N,),) + + pp = np.zeros((2*N+1,)) # array of polynomial coefficients from higher power to lower + + for n in range(0, N+1): # (2N+1) - number of polynomial coefficients + pp[2*(N-n)] = fn*(4.0*kappa)**(N-n)/np.math.factorial(n)*(-1)**n + + pp = sp.poly1d(pp) + roots = sp.roots(pp) + + neg_real_part_roots = roots[np.round(np.real(roots) ,roots_rounding_decimals) < 0] + aa = sp.poly1d(neg_real_part_roots, r=True).coeffs + + F = np.diag(np.ones((N-1,)),1) + F[-1,:] = -aa[-1:0:-1] + + L= np.zeros((N,1)) + L[N-1,0] = 1 + + H = np.zeros((1,N)) + H[0,0] = 1 + + # Infinite covariance: + Pinf = sp.linalg.solve_lyapunov(F, -np.dot(L,np.dot( Qc[0,0],L.T))) + Pinf = 0.5*(Pinf + Pinf.T) + # Allocating space for derivatives + dF = np.empty([F.shape[0],F.shape[1],2]) + dQc = np.empty([Qc.shape[0],Qc.shape[1],2]) + dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2]) + + # Derivatives: + dFvariance = np.zeros(F.shape) + dFlengthscale = np.zeros(F.shape) + dFlengthscale[-1,:] = -aa[-1:0:-1]/self.lengthscale * np.arange(-N,0,1) + + dQcvariance = Qc/self.variance + dQclengthscale = np.array(((self.variance*np.sqrt(2*np.pi)*fn*2**N*self.lengthscale**(-2*N)*(1-2*N,),))) + + dPinf_variance = Pinf/self.variance + + lp = Pinf.shape[0] + coeff = np.arange(1,lp+1).reshape(lp,1) + np.arange(1,lp+1).reshape(1,lp) - 2 + coeff[np.mod(coeff,2) != 0] = 0 + dPinf_lengthscale = -1/self.lengthscale*Pinf*coeff + + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinf_variance + dPinf[:,:,1] = dPinf_lengthscale + + P0 = Pinf.copy() + dP0 = dPinf.copy() + + # Benefits of this are not very sound. Helps only in one case: + # SVD Kalman + RBF kernel + import GPy.models.state_space_main as ssm + (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf,dP0, T) = ssm.balance_ss_model(F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0 ) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_Exponential(Exponential): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Exponential kernel: + + .. math:: + + k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + variance = float(self.variance.values) + lengthscale = float(self.lengthscale) + + F = np.array(((-1.0/lengthscale,),)) + L = np.array(((1.0,),)) + Qc = np.array( ((2.0*variance/lengthscale,),) ) + H = np.array(((1.0,),)) + Pinf = np.array(((variance,),)) + P0 = Pinf.copy() + + dF = np.zeros((1,1,2)); + dQc = np.zeros((1,1,2)); + dPinf = np.zeros((1,1,2)); + + dF[:,:,0] = 0.0 + dF[:,:,1] = 1.0/lengthscale**2 + + dQc[:,:,0] = 2.0/lengthscale + dQc[:,:,1] = -2.0*variance/lengthscale**2 + + dPinf[:,:,0] = 1.0 + dPinf[:,:,1] = 0.0 + + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_RatQuad(RatQuad): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Rational Quadratic kernel: + + .. math:: + + k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \alpha} \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + assert False, 'Not Implemented' + + # Params to use: + + # self.lengthscale + # self.variance + #self.power + + #return (F, L, Qc, H, Pinf, dF, dQc, dPinf) diff --git a/GPy/kern/src/add.py b/GPy/kern/src/add.py index 8f91d639..ca20e5a9 100644 --- a/GPy/kern/src/add.py +++ b/GPy/kern/src/add.py @@ -13,15 +13,21 @@ class Add(CombinationKernel): propagates gradients through. This kernel will take over the active dims of it's subkernels passed in. + + NOTE: The subkernels will be copies of the original kernels, to prevent + unexpected behavior. """ def __init__(self, subkerns, name='sum'): - for i, kern in enumerate(subkerns[:]): + _newkerns = [] + for kern in subkerns: if isinstance(kern, Add): - del subkerns[i] - for part in kern.parts[::-1]: + for part in kern.parts: #kern.unlink_parameter(part) - subkerns.insert(i, part.copy()) - super(Add, self).__init__(subkerns, name) + _newkerns.append(part.copy()) + else: + _newkerns.append(kern.copy()) + + super(Add, self).__init__(_newkerns, name) self._exact_psicomp = self._check_exact_psicomp() def _check_exact_psicomp(self): @@ -87,14 +93,19 @@ class Add(CombinationKernel): def gradients_XX(self, dL_dK, X, X2): if X2 is None: - target = np.zeros((X.shape[0], X.shape[0], X.shape[1])) + target = np.zeros((X.shape[0], X.shape[0], X.shape[1], X.shape[1])) else: - target = np.zeros((X.shape[0], X2.shape[0], X.shape[1])) + target = np.zeros((X.shape[0], X2.shape[0], X.shape[1], X.shape[1])) + #else: # diagonal covariance + # if X2 is None: + # target = np.zeros((X.shape[0], X.shape[0], X.shape[1])) + # else: + # target = np.zeros((X.shape[0], X2.shape[0], X.shape[1])) [target.__iadd__(p.gradients_XX(dL_dK, X, X2)) for p in self.parts] return target def gradients_XX_diag(self, dL_dKdiag, X): - target = np.zeros(X.shape) + target = np.zeros(X.shape+(X.shape[1],)) [target.__iadd__(p.gradients_XX_diag(dL_dKdiag, X)) for p in self.parts] return target @@ -182,7 +193,7 @@ class Add(CombinationKernel): def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior): tmp = dL_dpsi2.sum(0)+ dL_dpsi2.sum(1) if len(dL_dpsi2.shape)==2 else dL_dpsi2.sum(2)+ dL_dpsi2.sum(1) - + if not self._exact_psicomp: return Kern.update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior) from .static import White, Bias for p1 in self.parts: @@ -194,9 +205,9 @@ class Add(CombinationKernel): if isinstance(p2, White): continue elif isinstance(p2, Bias): - eff_dL_dpsi1 += tmp * p2.variance + eff_dL_dpsi1 += tmp * p2.variance else:# np.setdiff1d(p1._all_dims_active, ar2, assume_unique): # TODO: Careful, not correct for overlapping _all_dims_active - eff_dL_dpsi1 += tmp * p2.psi1(Z, variational_posterior) + eff_dL_dpsi1 += tmp * p2.psi1(Z, variational_posterior) p1.update_gradients_expectations(dL_dpsi0, eff_dL_dpsi1, dL_dpsi2, Z, variational_posterior) def gradients_Z_expectations(self, dL_psi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior): @@ -213,7 +224,7 @@ class Add(CombinationKernel): if isinstance(p2, White): continue elif isinstance(p2, Bias): - eff_dL_dpsi1 += tmp * p2.variance + eff_dL_dpsi1 += tmp * p2.variance else: eff_dL_dpsi1 += tmp * p2.psi1(Z, variational_posterior) target += p1.gradients_Z_expectations(dL_psi0, eff_dL_dpsi1, dL_dpsi2, Z, variational_posterior) @@ -221,7 +232,7 @@ class Add(CombinationKernel): def gradients_qX_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior): tmp = dL_dpsi2.sum(0)+ dL_dpsi2.sum(1) if len(dL_dpsi2.shape)==2 else dL_dpsi2.sum(2)+ dL_dpsi2.sum(1) - + if not self._exact_psicomp: return Kern.gradients_qX_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior) from .static import White, Bias target_grads = [np.zeros(v.shape) for v in variational_posterior.parameters] @@ -234,9 +245,9 @@ class Add(CombinationKernel): if isinstance(p2, White): continue elif isinstance(p2, Bias): - eff_dL_dpsi1 += tmp * p2.variance + eff_dL_dpsi1 += tmp * p2.variance else: - eff_dL_dpsi1 += tmp * p2.psi1(Z, variational_posterior) + eff_dL_dpsi1 += tmp * p2.psi1(Z, variational_posterior) grads = p1.gradients_qX_expectations(dL_dpsi0, eff_dL_dpsi1, dL_dpsi2, Z, variational_posterior) [np.add(target_grads[i],grads[i],target_grads[i]) for i in range(len(grads))] return target_grads @@ -249,7 +260,7 @@ class Add(CombinationKernel): # other.unlink_parameter(p) # parts.extend(other.parts) # #self.link_parameters(*other_params) - # + # # else: # #self.link_parameter(other) # parts.append(other) @@ -263,4 +274,94 @@ class Add(CombinationKernel): i_s[k._all_dims_active] += k.input_sensitivity(summarize) return i_s else: + return super(Add, self).input_sensitivity(summarize) + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + part_start_param_index = 0 + for p in self.parts: + if not p.is_fixed: + part_param_num = len(p.param_array) # number of parameters in the part + p.sde_update_gradient_full(gradients[part_start_param_index:(part_start_param_index+part_param_num)]) + part_start_param_index += part_param_num + + def sde(self): + """ + Support adding kernels for sde representation + """ + + import scipy.linalg as la + + F = None + L = None + Qc = None + H = None + Pinf = None + P0 = None + dF = None + dQc = None + dPinf = None + dP0 = None + n = 0 + nq = 0 + nd = 0 + + # Assign models + for p in self.parts: + (Ft,Lt,Qct,Ht,Pinft,P0t,dFt,dQct,dPinft,dP0t) = p.sde() + F = la.block_diag(F,Ft) if (F is not None) else Ft + L = la.block_diag(L,Lt) if (L is not None) else Lt + Qc = la.block_diag(Qc,Qct) if (Qc is not None) else Qct + H = np.hstack((H,Ht)) if (H is not None) else Ht + + Pinf = la.block_diag(Pinf,Pinft) if (Pinf is not None) else Pinft + P0 = la.block_diag(P0,P0t) if (P0 is not None) else P0t + + if dF is not None: + dF = np.pad(dF,((0,dFt.shape[0]),(0,dFt.shape[1]),(0,dFt.shape[2])), + 'constant', constant_values=0) + dF[-dFt.shape[0]:,-dFt.shape[1]:,-dFt.shape[2]:] = dFt + else: + dF = dFt + + if dQc is not None: + dQc = np.pad(dQc,((0,dQct.shape[0]),(0,dQct.shape[1]),(0,dQct.shape[2])), + 'constant', constant_values=0) + dQc[-dQct.shape[0]:,-dQct.shape[1]:,-dQct.shape[2]:] = dQct + else: + dQc = dQct + + if dPinf is not None: + dPinf = np.pad(dPinf,((0,dPinft.shape[0]),(0,dPinft.shape[1]),(0,dPinft.shape[2])), + 'constant', constant_values=0) + dPinf[-dPinft.shape[0]:,-dPinft.shape[1]:,-dPinft.shape[2]:] = dPinft + else: + dPinf = dPinft + + if dP0 is not None: + dP0 = np.pad(dP0,((0,dP0t.shape[0]),(0,dP0t.shape[1]),(0,dP0t.shape[2])), + 'constant', constant_values=0) + dP0[-dP0t.shape[0]:,-dP0t.shape[1]:,-dP0t.shape[2]:] = dP0t + else: + dP0 = dP0t + + n += Ft.shape[0] + nq += Qct.shape[0] + nd += dFt.shape[2] + + assert (F.shape[0] == n and F.shape[1]==n), "SDE add: Check of F Dimensions failed" + assert (L.shape[0] == n and L.shape[1]==nq), "SDE add: Check of L Dimensions failed" + assert (Qc.shape[0] == nq and Qc.shape[1]==nq), "SDE add: Check of Qc Dimensions failed" + assert (H.shape[0] == 1 and H.shape[1]==n), "SDE add: Check of H Dimensions failed" + assert (Pinf.shape[0] == n and Pinf.shape[1]==n), "SDE add: Check of Pinf Dimensions failed" + assert (P0.shape[0] == n and P0.shape[1]==n), "SDE add: Check of P0 Dimensions failed" + assert (dF.shape[0] == n and dF.shape[1]==n and dF.shape[2]==nd), "SDE add: Check of dF Dimensions failed" + assert (dQc.shape[0] == nq and dQc.shape[1]==nq and dQc.shape[2]==nd), "SDE add: Check of dQc Dimensions failed" + assert (dPinf.shape[0] == n and dPinf.shape[1]==n and dPinf.shape[2]==nd), "SDE add: Check of dPinf Dimensions failed" + assert (dP0.shape[0] == n and dP0.shape[1]==n and dP0.shape[2]==nd), "SDE add: Check of dP0 Dimensions failed" + + return (F,L,Qc,H,Pinf,P0,dF,dQc,dPinf,dP0) diff --git a/GPy/kern/src/basis_funcs.py b/GPy/kern/src/basis_funcs.py index 7a5f84dd..5d589aa6 100644 --- a/GPy/kern/src/basis_funcs.py +++ b/GPy/kern/src/basis_funcs.py @@ -15,6 +15,7 @@ class BasisFuncKernel(Kern): This class does NOT automatically add an offset to the design matrix phi! """ super(BasisFuncKernel, self).__init__(input_dim, active_dims, name) + assert self.input_dim==1, "Basis Function Kernel only implemented for one dimension. Use one kernel per dimension (and add them together) for more dimensions" self.ARD = ARD if self.ARD: phi_test = self._phi(np.random.normal(0, 1, (1, self.input_dim))) @@ -60,6 +61,11 @@ class BasisFuncKernel(Kern): self.variance.gradient = np.einsum('i,i', dL_dKdiag, self.Kdiag(X)) * self.beta def concatenate_offset(self, X): + """ + Convenience function to add an offset column to phi. + You can use this function to add an offset (bias on y axis) + to phi in your custom self._phi(X). + """ return np.c_[np.ones((X.shape[0], 1)), X] def posterior_inf(self, X=None, posterior=None): @@ -120,6 +126,12 @@ class LinearSlopeBasisFuncKernel(BasisFuncKernel): return ((phi-(self.stop+self.start)/2.))#/(.5*(self.stop-self.start)))-1. class ChangePointBasisFuncKernel(BasisFuncKernel): + """ + The basis function has a changepoint. That is, it is constant, jumps at a + single point (given as changepoint) and is constant again. You can + give multiple changepoints. The changepoints are calculated using + np.where(self.X < self.changepoint), -1, 1) + """ def __init__(self, input_dim, changepoint, variance=1., active_dims=None, ARD=False, name='changepoint'): self.changepoint = np.array(changepoint) super(ChangePointBasisFuncKernel, self).__init__(input_dim, variance, active_dims, ARD, name) @@ -129,6 +141,11 @@ class ChangePointBasisFuncKernel(BasisFuncKernel): return np.where((X < self.changepoint), -1, 1) class DomainKernel(LinearSlopeBasisFuncKernel): + """ + Create a constant plateou of correlation between start and stop and zero + elsewhere. This is a constant shift of the outputs along the yaxis + in the range from start to stop. + """ def __init__(self, input_dim, start, stop, variance=1., active_dims=None, ARD=False, name='constant_domain'): super(DomainKernel, self).__init__(input_dim, start, stop, variance, active_dims, ARD, name) @@ -138,19 +155,25 @@ class DomainKernel(LinearSlopeBasisFuncKernel): return phi#((phi-self.start)/(self.stop-self.start))-.5 class LogisticBasisFuncKernel(BasisFuncKernel): + """ + Create a series of logistic basis functions with centers given. The + slope gets computed by datafit. The number of centers determines the + number of logistic functions. + """ def __init__(self, input_dim, centers, variance=1., slope=1., active_dims=None, ARD=False, ARD_slope=True, name='logistic'): self.centers = np.atleast_2d(centers) + if ARD: + assert ARD_slope, "If we have one variance per center, we want also one slope per center." self.ARD_slope = ARD_slope if self.ARD_slope: - self.slope = Param('slope', slope * np.ones(self.centers.size), Logexp()) + self.slope = Param('slope', slope * np.ones(self.centers.size)) else: - self.slope = Param('slope', slope, Logexp()) + self.slope = Param('slope', slope) super(LogisticBasisFuncKernel, self).__init__(input_dim, variance, active_dims, ARD, name) self.link_parameter(self.slope) @Cache_this(limit=3, ignore_args=()) def _phi(self, X): - import scipy as sp phi = 1/(1+np.exp(-((X-self.centers)*self.slope))) return np.where(np.isnan(phi), 0, phi)#((phi-self.start)/(self.stop-self.start))-.5 @@ -167,7 +190,7 @@ class LogisticBasisFuncKernel(BasisFuncKernel): if self.ARD_slope: self.slope.gradient = self.variance * 2 * np.einsum('ij,iq,jq->q', dL_dK, phi1, dphi1_dl) else: - self.slope.gradient = self.variance * 2 * (dL_dK * phi1.dot(dphi1_dl.T)).sum() + self.slope.gradient = np.sum(self.variance * 2 * (dL_dK * phi1.dot(dphi1_dl.T)).sum()) else: phi1 = self.phi(X) phi2 = self.phi(X2) @@ -179,5 +202,5 @@ class LogisticBasisFuncKernel(BasisFuncKernel): if self.ARD_slope: self.slope.gradient = (self.variance * np.einsum('ij,iq,jq->q', dL_dK, phi1, dphi2_dl) + np.einsum('ij,iq,jq->q', dL_dK, phi2, dphi1_dl)) else: - self.slope.gradient = self.variance * (dL_dK * phi1.dot(dphi2_dl.T)).sum() + (dL_dK * phi2.dot(dphi1_dl.T)).sum() + self.slope.gradient = np.sum(self.variance * (dL_dK * phi1.dot(dphi2_dl.T)).sum() + (dL_dK * phi2.dot(dphi1_dl.T)).sum()) self.slope.gradient = np.where(np.isnan(self.slope.gradient), 0, self.slope.gradient) diff --git a/GPy/kern/src/eq_ode1.py b/GPy/kern/src/eq_ode1.py new file mode 100644 index 00000000..9c19bead --- /dev/null +++ b/GPy/kern/src/eq_ode1.py @@ -0,0 +1,649 @@ +# Copyright (c) 2014, Cristian Guarnizo. +# Licensed under the BSD 3-clause license (see LICENSE.txt) + +import numpy as np +from scipy.special import erf, erfcx +from .kern import Kern +from ...core.parameterization import Param +from paramz.transformations import Logexp +from paramz.caching import Cache_this + +class EQ_ODE1(Kern): + """ + Covariance function for first order differential equation driven by an exponentiated quadratic covariance. + + This outputs of this kernel have the form + .. math:: + \frac{\text{d}y_j}{\text{d}t} = \sum_{i=1}^R w_{j,i} u_i(t-\delta_j) - d_jy_j(t) + + where :math:`R` is the rank of the system, :math:`w_{j,i}` is the sensitivity of the :math:`j`th output to the :math:`i`th latent function, :math:`d_j` is the decay rate of the :math:`j`th output and :math:`u_i(t)` are independent latent Gaussian processes goverened by an exponentiated quadratic covariance. + + :param output_dim: number of outputs driven by latent function. + :type output_dim: int + :param W: sensitivities of each output to the latent driving function. + :type W: ndarray (output_dim x rank). + :param rank: If rank is greater than 1 then there are assumed to be a total of rank latent forces independently driving the system, each with identical covariance. + :type rank: int + :param decay: decay rates for the first order system. + :type decay: array of length output_dim. + :param delay: delay between latent force and output response. + :type delay: array of length output_dim. + :param kappa: diagonal term that allows each latent output to have an independent component to the response. + :type kappa: array of length output_dim. + + .. Note: see first order differential equation examples in GPy.examples.regression for some usage. + """ + def __init__(self, input_dim=2, output_dim=1, rank=1, W = None, lengthscale=None, decay=None, active_dims=None, name='eq_ode1'): + assert input_dim == 2, "only defined for 1 input dims" + super(EQ_ODE1, self).__init__(input_dim=input_dim, active_dims=active_dims, name=name) + + self.rank = rank + self.output_dim = output_dim + + if lengthscale is None: + lengthscale = .5 + np.random.rand(self.rank) + else: + lengthscale = np.asarray(lengthscale) + assert lengthscale.size in [1, self.rank], "Bad number of lengthscales" + if lengthscale.size != self.rank: + lengthscale = np.ones(self.rank)*lengthscale + + if W is None: + W = .5*np.random.randn(self.output_dim, self.rank)/np.sqrt(self.rank) + else: + assert W.shape == (self.output_dim, self.rank) + + if decay is None: + decay = np.ones(self.output_dim) + else: + decay = np.asarray(decay) + assert decay.size in [1, self.output_dim], "Bad number of decay" + if decay.size != self.output_dim: + decay = np.ones(self.output_dim)*decay + +# if kappa is None: +# self.kappa = np.ones(self.output_dim) +# else: +# kappa = np.asarray(kappa) +# assert kappa.size in [1, self.output_dim], "Bad number of kappa" +# if decay.size != self.output_dim: +# decay = np.ones(self.output_dim)*kappa + + #self.kappa = Param('kappa', kappa, Logexp()) + #self.delay = Param('delay', delay, Logexp()) + #self.is_normalized = True + #self.is_stationary = False + #self.gaussian_initial = False + + self.lengthscale = Param('lengthscale', lengthscale, Logexp()) + self.decay = Param('decay', decay, Logexp()) + self.W = Param('W', W) + self.link_parameters(self.lengthscale, self.decay, self.W) + + @Cache_this(limit=3) + def K(self, X, X2=None): + #This way is not working, indexes are lost after using k._slice_X + #index = np.asarray(X, dtype=np.int) + #index = index.reshape(index.size,) + if hasattr(X, 'values'): + X = X.values + index = np.int_(np.round(X[:, 1])) + index = index.reshape(index.size,) + X_flag = index[0] >= self.output_dim + if X2 is None: + if X_flag: + #Calculate covariance function for the latent functions + index -= self.output_dim + return self._Kuu(X, index) + else: + raise NotImplementedError + else: + #This way is not working, indexes are lost after using k._slice_X + #index2 = np.asarray(X2, dtype=np.int) + #index2 = index2.reshape(index2.size,) + if hasattr(X2, 'values'): + X2 = X2.values + index2 = np.int_(np.round(X2[:, 1])) + index2 = index2.reshape(index2.size,) + X2_flag = index2[0] >= self.output_dim + #Calculate cross-covariance function + if not X_flag and X2_flag: + index2 -= self.output_dim + return self._Kfu(X, index, X2, index2) #Kfu + elif X_flag and not X2_flag: + index -= self.output_dim + return self._Kfu(X2, index2, X, index).T #Kuf + elif X_flag and X2_flag: + index -= self.output_dim + index2 -= self.output_dim + return self._Kusu(X, index, X2, index2) #Ku_s u + else: + raise NotImplementedError #Kf_s f + + #Calculate the covariance function for diag(Kff(X,X)) + def Kdiag(self, X): + if hasattr(X, 'values'): + index = np.int_(np.round(X[:, 1].values)) + else: + index = np.int_(np.round(X[:, 1])) + index = index.reshape(index.size,) + X_flag = index[0] >= self.output_dim + + if X_flag: #Kuudiag + return np.ones(X[:,0].shape) + else: #Kffdiag + kdiag = self._Kdiag(X) + return np.sum(kdiag, axis=1) + + def _Kdiag(self, X): + #This way is not working, indexes are lost after using k._slice_X + #index = np.asarray(X, dtype=np.int) + #index = index.reshape(index.size,) + if hasattr(X, 'values'): + X = X.values + index = np.int_(X[:, 1]) + index = index.reshape(index.size,) + + #terms that move along t + t = X[:, 0].reshape(X.shape[0], 1) + d = np.unique(index) #Output Indexes + B = self.decay.values[d] + S = self.W.values[d, :] + #Index transformation + indd = np.arange(self.output_dim) + indd[d] = np.arange(d.size) + index = indd[index] + + B = B.reshape(B.size, 1) + #Terms that move along q + lq = self.lengthscale.values.reshape(1, self.rank) + S2 = S*S + kdiag = np.empty((t.size, )) + + #Dx1 terms + c0 = (S2/B)*((.5*np.sqrt(np.pi))*lq) + + #DxQ terms + nu = lq*(B*.5) + nu2 = nu*nu + #Nx1 terms + gamt = -2.*B + gamt = gamt[index]*t + + #NxQ terms + t_lq = t/lq + + # Upsilon Calculations + # Using wofz + #erfnu = erf(nu) + + upm = np.exp(nu2[index, :] + lnDifErf( nu[index, :] ,t_lq+nu[index,:] )) + upm[t[:, 0] == 0, :] = 0. + + + upv = np.exp(nu2[index, :] + gamt + lnDifErf( -t_lq+nu[index,:], nu[index, :] ) ) + upv[t[:, 0] == 0, :] = 0. + + #Covariance calculation + #kdiag = np.sum(c0[index, :]*(upm-upv), axis=1) + kdiag = c0[index, :]*(upm-upv) + return kdiag + + def update_gradients_full(self, dL_dK, X, X2 = None): + #index = np.asarray(X, dtype=np.int) + #index = index.reshape(index.size,) + if hasattr(X, 'values'): + X = X.values + self.decay.gradient = np.zeros(self.decay.shape) + self.W.gradient = np.zeros(self.W.shape) + self.lengthscale.gradient = np.zeros(self.lengthscale.shape) + index = np.int_(np.round(X[:, 1])) + index = index.reshape(index.size,) + X_flag = index[0] >= self.output_dim + if X2 is None: + if X_flag: #Kuu or Kmm + index -= self.output_dim + tmp = dL_dK*self._gkuu_lq(X, index) + for q in np.unique(index): + ind = np.where(index == q) + self.lengthscale.gradient[q] = tmp[np.ix_(ind[0], ind[0])].sum() + else: + raise NotImplementedError + else: #Kfu or Knm + #index2 = np.asarray(X2, dtype=np.int) + #index2 = index2.reshape(index2.size,) + if hasattr(X2, 'values'): + X2 = X2.values + index2 = np.int_(np.round(X2[:, 1])) + index2 = index2.reshape(index2.size,) + X2_flag = index2[0] >= self.output_dim + if not X_flag and X2_flag: #Kfu + index2 -= self.output_dim + else: #Kuf + dL_dK = dL_dK.T #so we obtaing dL_Kfu + indtemp = index - self.output_dim + Xtemp = X + X = X2 + X2 = Xtemp + index = index2 + index2 = indtemp + glq, gSdq, gB = self._gkfu(X, index, X2, index2) + tmp = dL_dK*glq + for q in np.unique(index2): + ind = np.where(index2 == q) + self.lengthscale.gradient[q] = tmp[:, ind].sum() + tmpB = dL_dK*gB + tmp = dL_dK*gSdq + for d in np.unique(index): + ind = np.where(index == d) + self.decay.gradient[d] = tmpB[ind, :].sum() + for q in np.unique(index2): + ind2 = np.where(index2 == q) + self.W.gradient[d, q] = tmp[np.ix_(ind[0], ind2[0])].sum() + + def update_gradients_diag(self, dL_dKdiag, X): + #index = np.asarray(X, dtype=np.int) + #index = index.reshape(index.size,) + if hasattr(X, 'values'): + X = X.values + self.decay.gradient = np.zeros(self.decay.shape) + self.W.gradient = np.zeros(self.W.shape) + self.lengthscale.gradient = np.zeros(self.lengthscale.shape) + index = np.int_(X[:, 1]) + index = index.reshape(index.size,) + + glq, gS, gB = self._gkdiag(X, index) + if dL_dKdiag.size == X.shape[0]: + dL_dKdiag = np.reshape(dL_dKdiag, (index.size, 1)) + tmp = dL_dKdiag*glq + self.lengthscale.gradient = tmp.sum(0) + tmpB = dL_dKdiag*gB + tmp = dL_dKdiag*gS + for d in np.unique(index): + ind = np.where(index == d) + self.decay.gradient[d] = tmpB[ind, :].sum() + self.W.gradient[d, :] = tmp[ind].sum(0) + + def gradients_X(self, dL_dK, X, X2=None): + #index = np.asarray(X, dtype=np.int) + #index = index.reshape(index.size,) + if hasattr(X, 'values'): + X = X.values + index = np.int_(np.round(X[:, 1])) + index = index.reshape(index.size,) + X_flag = index[0] >= self.output_dim + #If input_dim == 1, use this + #gX = np.zeros((X.shape[0], 1)) + #Cheat to allow gradient for input_dim==2 + gX = np.zeros(X.shape) + if X2 is None: #Kuu or Kmm + if X_flag: + index -= self.output_dim + gX[:, 0] = 2.*(dL_dK*self._gkuu_X(X, index)).sum(0) + return gX + else: + raise NotImplementedError + else: #Kuf or Kmn + #index2 = np.asarray(X2, dtype=np.int) + #index2 = index2.reshape(index2.size,) + if hasattr(X2, 'values'): + X2 = X2.values + index2 = np.int_(np.round(X2[:, 1])) + index2 = index2.reshape(index2.size,) + X2_flag = index2[0] >= self.output_dim + if X_flag and not X2_flag: #gradient of Kuf(Z, X) wrt Z + index -= self.output_dim + gX[:, 0] = (dL_dK*self._gkfu_z(X2, index2, X, index).T).sum(1) + return gX + else: + raise NotImplementedError + + #---------------------------------------# + # Helper functions # + #---------------------------------------# + + #Evaluation of squared exponential for LFM + def _Kuu(self, X, index): + index = index.reshape(index.size,) + t = X[:, 0].reshape(X.shape[0],) + lq = self.lengthscale.values.reshape(self.rank,) + lq2 = lq*lq + #Covariance matrix initialization + kuu = np.zeros((t.size, t.size)) + #Assign 1. to diagonal terms + kuu[np.diag_indices(t.size)] = 1. + #Upper triangular indices + indtri1, indtri2 = np.triu_indices(t.size, 1) + #Block Diagonal indices among Upper Triangular indices + ind = np.where(index[indtri1] == index[indtri2]) + indr = indtri1[ind] + indc = indtri2[ind] + r = t[indr] - t[indc] + r2 = r*r + #Calculation of covariance function + kuu[indr, indc] = np.exp(-r2/lq2[index[indr]]) + #Completion of lower triangular part + kuu[indc, indr] = kuu[indr, indc] + return kuu + + def _Kusu(self, X, index, X2, index2): + index = index.reshape(index.size,) + index2 = index2.reshape(index2.size,) + t = X[:, 0].reshape(X.shape[0],1) + t2 = X2[:, 0].reshape(1,X2.shape[0]) + lq = self.lengthscale.values.reshape(self.rank,) + #Covariance matrix initialization + kuu = np.zeros((t.size, t2.size)) + for q in range(self.rank): + ind1 = index == q + ind2 = index2 == q + r = t[ind1]/lq[q] - t2[0,ind2]/lq[q] + r2 = r*r + #Calculation of covariance function + kuu[np.ix_(ind1, ind2)] = np.exp(-r2) + return kuu + + #Evaluation of cross-covariance function + def _Kfu(self, X, index, X2, index2): + #terms that move along t + t = X[:, 0].reshape(X.shape[0], 1) + d = np.unique(index) #Output Indexes + B = self.decay.values[d] + S = self.W.values[d, :] + #Index transformation + indd = np.arange(self.output_dim) + indd[d] = np.arange(d.size) + index = indd[index] + #Output related variables must be column-wise + B = B.reshape(B.size, 1) + #Input related variables must be row-wise + z = X2[:, 0].reshape(1, X2.shape[0]) + lq = self.lengthscale.values.reshape((1, self.rank)) + + kfu = np.empty((t.size, z.size)) + + #DxQ terms + c0 = S*((.5*np.sqrt(np.pi))*lq) + nu = B*(.5*lq) + nu2 = nu**2 + #1xM terms + z_lq = z/lq[0, index2] + #NxM terms + tz = t-z + tz_lq = tz/lq[0, index2] + + # Upsilon Calculations + fullind = np.ix_(index, index2) + + upsi = np.exp(nu2[fullind] - B[index]*tz + lnDifErf( -tz_lq + nu[fullind], z_lq+nu[fullind])) + upsi[t[:, 0] == 0, :] = 0. + #Covariance calculation + kfu = c0[fullind]*upsi + + return kfu + + #Gradient of Kuu wrt lengthscale + def _gkuu_lq(self, X, index): + t = X[:, 0].reshape(X.shape[0],) + index = index.reshape(X.shape[0],) + lq = self.lengthscale.values.reshape(self.rank,) + lq2 = lq*lq + #Covariance matrix initialization + glq = np.zeros((t.size, t.size)) + #Upper triangular indices + indtri1, indtri2 = np.triu_indices(t.size, 1) + #Block Diagonal indices among Upper Triangular indices + ind = np.where(index[indtri1] == index[indtri2]) + indr = indtri1[ind] + indc = indtri2[ind] + r = t[indr] - t[indc] + r2 = r*r + r2_lq2 = r2/lq2[index[indr]] + #Calculation of covariance function + er2_lq2 = np.exp(-r2_lq2) + #Gradient wrt lq + c = 2.*r2_lq2/lq[index[indr]] + glq[indr, indc] = er2_lq2*c + #Complete the lower triangular + glq[indc, indr] = glq[indr, indc] + return glq + + #Be careful this derivative should be transpose it + def _gkuu_X(self, X, index): #Diagonal terms are always zero + t = X[:, 0].reshape(X.shape[0],) + index = index.reshape(index.size,) + lq = self.lengthscale.values.reshape(self.rank,) + lq2 = lq*lq + #Covariance matrix initialization + gt = np.zeros((t.size, t.size)) + #Upper triangular indices + indtri1, indtri2 = np.triu_indices(t.size, 1) #Offset of 1 from the diagonal + #Block Diagonal indices among Upper Triangular indices + ind = np.where(index[indtri1] == index[indtri2]) + indr = indtri1[ind] + indc = indtri2[ind] + r = t[indr] - t[indc] + r2 = r*r + r2_lq2 = r2/(-lq2[index[indr]]) + #Calculation of covariance function + er2_lq2 = np.exp(r2_lq2) + #Gradient wrt t + c = 2.*r/lq2[index[indr]] + gt[indr, indc] = er2_lq2*c + #Complete the lower triangular + gt[indc, indr] = -gt[indr, indc] + return gt + + #Gradients for Diagonal Kff + def _gkdiag(self, X, index): + index = index.reshape(index.size,) + #terms that move along t + d = np.unique(index) + B = self.decay[d].values + S = self.W[d, :].values + #Index transformation + indd = np.arange(self.output_dim) + indd[d] = np.arange(d.size) + index = indd[index] + #Output related variables must be column-wise + t = X[:, 0].reshape(X.shape[0], 1) + B = B.reshape(B.size, 1) + S2 = S*S + + #Input related variables must be row-wise + lq = self.lengthscale.values.reshape(1, self.rank) + + gB = np.empty((t.size,)) + glq = np.empty((t.size, lq.size)) + gS = np.empty((t.size, lq.size)) + + #Dx1 terms + c0 = S2*lq*np.sqrt(np.pi) + + #DxQ terms + nu = (.5*lq)*B + nu2 = nu*nu + + #Nx1 terms + gamt = -B[index]*t + egamt = np.exp(gamt) + e2gamt = egamt*egamt + + #NxQ terms + t_lq = t/lq + t2_lq2 = -t_lq*t_lq + + etlq2gamt = np.exp(t2_lq2 + gamt) #NXQ + + ##Upsilon calculations + #erfnu = erf(nu) #TODO: This can be improved + + upm = np.exp(nu2[index, :] + lnDifErf( nu[index, :], t_lq + nu[index, :]) ) + upm[t[:, 0] == 0, :] = 0. + + upv = np.exp(nu2[index, :] + 2.*gamt + lnDifErf(-t_lq + nu[index, :], nu[index, :]) ) #egamt*upv + upv[t[:, 0] == 0, :] = 0. + + #Gradient wrt S + c0_S = (S/B)*(lq*np.sqrt(np.pi)) + + gS = c0_S[index]*(upm - upv) + + #For B + CB1 = (.5*lq)**2 - .5/B**2 #DXQ + lq2_2B = (.5*lq**2)*(S2/B) #DXQ + CB2 = 2.*etlq2gamt - e2gamt - 1. #NxQ + + # gradient wrt B NxZ + gB = c0[index, :]*(CB1[index, :]*upm - (CB1[index, :] - t/B[index])*upv) + \ + lq2_2B[index, :]*CB2 + + #Gradient wrt lengthscale + #DxQ terms + c0 = (.5*np.sqrt(np.pi))*(S2/B)*(1.+.5*(lq*B)**2) + Clq1 = S2*(lq*.5) + glq = c0[index]*(upm - upv) + Clq1[index]*CB2 + + return glq, gS, gB + + def _gkfu(self, X, index, Z, index2): + index = index.reshape(index.size,) + #TODO: reduce memory usage + #terms that move along t + d = np.unique(index) + B = self.decay[d].values + S = self.W[d, :].values + + #Index transformation + indd = np.arange(self.output_dim) + indd[d] = np.arange(d.size) + index = indd[index] + #t column + t = X[:, 0].reshape(X.shape[0], 1) + B = B.reshape(B.size, 1) + #z row + z = Z[:, 0].reshape(1, Z.shape[0]) + index2 = index2.reshape(index2.size,) + lq = self.lengthscale.values.reshape((1, self.rank)) + + #kfu = np.empty((t.size, z.size)) + glq = np.empty((t.size, z.size)) + gSdq = np.empty((t.size, z.size)) + gB = np.empty((t.size, z.size)) + + #Dx1 terms + B_2 = B*.5 + S_pi = S*(.5*np.sqrt(np.pi)) + #DxQ terms + c0 = S_pi*lq #lq*Sdq*sqrt(pi) + nu = B*lq*.5 + nu2 = nu*nu + + #1xM terms + z_lq = z/lq[0, index2] + + #NxM terms + tz = t-z + tz_lq = tz/lq[0, index2] + etz_lq2 = -np.exp(-tz_lq*tz_lq) + ez_lq_Bt = np.exp(-z_lq*z_lq -B[index]*t) + + # Upsilon calculations + fullind = np.ix_(index, index2) + upsi = np.exp(nu2[fullind] - B[index]*tz + lnDifErf( -tz_lq + nu[fullind], z_lq+nu[fullind] ) ) + upsi[t[:, 0] == 0., :] = 0. + + #Gradient wrt S + #DxQ term + Sa1 = lq*(.5*np.sqrt(np.pi)) + + gSdq = Sa1[0,index2]*upsi + + #Gradient wrt lq + la1 = S_pi*(1. + 2.*nu2) + Slq = S*lq + uplq = etz_lq2*(tz_lq/lq[0, index2] + B_2[index]) + uplq += ez_lq_Bt*(-z_lq/lq[0, index2] + B_2[index]) + + glq = la1[fullind]*upsi + glq += Slq[fullind]*uplq + + #Gradient wrt B + Slq = Slq*lq + nulq = nu*lq + upBd = etz_lq2 + ez_lq_Bt + gB = c0[fullind]*(nulq[fullind] - tz)*upsi + .5*Slq[fullind]*upBd + + return glq, gSdq, gB + + #TODO: reduce memory usage + def _gkfu_z(self, X, index, Z, index2): #Kfu(t,z) + index = index.reshape(index.size,) + #terms that move along t + d = np.unique(index) + B = self.decay[d].values + S = self.W[d, :].values + #Index transformation + indd = np.arange(self.output_dim) + indd[d] = np.arange(d.size) + index = indd[index] + + #t column + t = X[:, 0].reshape(X.shape[0], 1) + B = B.reshape(B.size, 1) + #z row + z = Z[:, 0].reshape(1, Z.shape[0]) + index2 = index2.reshape(index2.size,) + lq = self.lengthscale.values.reshape((1, self.rank)) + + #kfu = np.empty((t.size, z.size)) + gz = np.empty((t.size, z.size)) + + #Dx1 terms + S_pi =S*(.5*np.sqrt(np.pi)) + #DxQ terms + #Slq = S*lq + c0 = S_pi*lq #lq*Sdq*sqrt(pi) + nu = (.5*lq)*B + nu2 = nu*nu + + #1xM terms + z_lq = z/lq[0, index2] + z_lq2 = -z_lq*z_lq + #NxQ terms + t_lq = t/lq + #NxM terms + zt_lq = z_lq - t_lq[:, index2] + zt_lq2 = -zt_lq*zt_lq + + # Upsilon calculations + fullind = np.ix_(index, index2) + z2 = z_lq + nu[fullind] + z1 = z2 - t_lq[:, index2] + upsi = np.exp(nu2[fullind] - B[index]*(t-z) + lnDifErf(z1,z2) ) + upsi[t[:, 0] == 0., :] = 0. + + #Gradient wrt z + za1 = c0*B + #za2 = S_w + gz = za1[fullind]*upsi + S[fullind]*( np.exp(z_lq2 - B[index]*t) -np.exp(zt_lq2) ) + + return gz + +def lnDifErf(z1,z2): + #Z2 is always positive + logdiferf = np.zeros(z1.shape) + ind = np.where(z1>0.) + ind2 = np.where(z1<=0.) + if ind[0].shape > 0: + z1i = z1[ind] + z12 = z1i*z1i + z2i = z2[ind] + logdiferf[ind] = -z12 + np.log(erfcx(z1i) - erfcx(z2i)*np.exp(z12-z2i**2)) + + if ind2[0].shape > 0: + z1i = z1[ind2] + z2i = z2[ind2] + logdiferf[ind2] = np.log(erf(z2i) - erf(z1i)) + + return logdiferf \ No newline at end of file diff --git a/GPy/kern/src/eq_ode2.py b/GPy/kern/src/eq_ode2.py index 8e735248..0166c511 100644 --- a/GPy/kern/src/eq_ode2.py +++ b/GPy/kern/src/eq_ode2.py @@ -44,7 +44,7 @@ class EQ_ODE2(Kern): lengthscale = np.asarray(lengthscale) assert lengthscale.size in [1, self.rank], "Bad number of lengthscales" if lengthscale.size != self.rank: - lengthscale = np.ones(self.input_dim)*lengthscale + lengthscale = np.ones(self.rank)*lengthscale if W is None: #W = 0.5*np.random.randn(self.output_dim, self.rank)/np.sqrt(self.rank) @@ -71,7 +71,7 @@ class EQ_ODE2(Kern): #index = index.reshape(index.size,) if hasattr(X, 'values'): X = X.values - index = np.int_(X[:, 1]) + index = np.int_(np.round(X[:, 1])) index = index.reshape(index.size,) X_flag = index[0] >= self.output_dim if X2 is None: @@ -79,7 +79,7 @@ class EQ_ODE2(Kern): #Calculate covariance function for the latent functions index -= self.output_dim return self._Kuu(X, index) - else: + else: #Kff full raise NotImplementedError else: #This way is not working, indexes are lost after using k._slice_X @@ -87,19 +87,40 @@ class EQ_ODE2(Kern): #index2 = index2.reshape(index2.size,) if hasattr(X2, 'values'): X2 = X2.values - index2 = np.int_(X2[:, 1]) + index2 = np.int_(np.round(X2[:, 1])) index2 = index2.reshape(index2.size,) X2_flag = index2[0] >= self.output_dim #Calculate cross-covariance function if not X_flag and X2_flag: index2 -= self.output_dim return self._Kfu(X, index, X2, index2) #Kfu - else: + elif X_flag and not X2_flag: index -= self.output_dim return self._Kfu(X2, index2, X, index).T #Kuf + elif X_flag and X2_flag: + index -= self.output_dim + index2 -= self.output_dim + return self._Kusu(X, index, X2, index2) #Ku_s u + else: + raise NotImplementedError #Kf_s f #Calculate the covariance function for diag(Kff(X,X)) def Kdiag(self, X): + if hasattr(X, 'values'): + index = np.int_(np.round(X[:, 1].values)) + else: + index = np.int_(np.round(X[:, 1])) + index = index.reshape(index.size,) + X_flag = index[0] >= self.output_dim + + if X_flag: #Kuudiag + return np.ones(X[:,0].shape) + else: #Kffdiag + kdiag = self._Kdiag(X) + return np.sum(kdiag, axis=1) + + #Calculate the covariance function for diag(Kff(X,X)) + def _Kdiag(self, X): #This way is not working, indexes are lost after using k._slice_X #index = np.asarray(X, dtype=np.int) #index = index.reshape(index.size,) @@ -132,7 +153,7 @@ class EQ_ODE2(Kern): #Terms that move along q lq = self.lengthscale.values.reshape(1, self.lengthscale.size) S2 = S*S - kdiag = np.empty((t.size, )) + kdiag = np.empty((t.size, lq.size)) indD = np.arange(B.size) #(1) When wd is real @@ -187,8 +208,8 @@ class EQ_ODE2(Kern): upv[t1[:, 0] == 0, :] = 0. #Covariance calculation - kdiag[ind3t] = np.sum(np.real(K01[ind]*upm), axis=1) - kdiag[ind3t] += np.sum(np.real((c0[ind]*ec)*upv), axis=1) + kdiag[ind3t] = np.real(K01[ind]*upm) + kdiag[ind3t] += np.real((c0[ind]*ec)*upv) #(2) When w_d is complex if np.any(wbool): @@ -265,7 +286,7 @@ class EQ_ODE2(Kern): upvc[t1[:, 0] == 0, :] = 0. #Covariance calculation - kdiag[ind2t] = np.sum(K011[ind]*upm + K012[ind]*upmc + (c0[ind]*ec)*upv + (c0[ind]*ec2)*upvc, axis=1) + kdiag[ind2t] = K011[ind]*upm + K012[ind]*upmc + (c0[ind]*ec)*upv + (c0[ind]*ec2)*upvc return kdiag def update_gradients_full(self, dL_dK, X, X2 = None): @@ -336,16 +357,17 @@ class EQ_ODE2(Kern): index = index.reshape(index.size,) glq, gS, gB, gC = self._gkdiag(X, index) - tmp = dL_dKdiag.reshape(index.size, 1)*glq + if dL_dKdiag.size == X.shape[0]: + dL_dKdiag = np.reshape(dL_dKdiag, (index.size, 1)) + tmp = dL_dKdiag*glq self.lengthscale.gradient = tmp.sum(0) - #TODO: Avoid the reshape by a priori knowing the shape of dL_dKdiag - tmpB = dL_dKdiag*gB.reshape(dL_dKdiag.shape) - tmpC = dL_dKdiag*gC.reshape(dL_dKdiag.shape) - tmp = dL_dKdiag.reshape(index.size, 1)*gS + tmpB = dL_dKdiag*gB + tmpC = dL_dKdiag*gC + tmp = dL_dKdiag*gS for d in np.unique(index): ind = np.where(index == d) - self.B.gradient[d] = tmpB[ind].sum() - self.C.gradient[d] = tmpC[ind].sum() + self.B.gradient[d] = tmpB[ind, :].sum() + self.C.gradient[d] = tmpC[ind, :].sum() self.W.gradient[d, :] = tmp[ind].sum(0) def gradients_X(self, dL_dK, X, X2=None): @@ -410,6 +432,23 @@ class EQ_ODE2(Kern): kuu[indc, indr] = kuu[indr, indc] return kuu + def _Kusu(self, X, index, X2, index2): + index = index.reshape(index.size,) + index2 = index2.reshape(index2.size,) + t = X[:, 0].reshape(X.shape[0],1) + t2 = X2[:, 0].reshape(1,X2.shape[0]) + lq = self.lengthscale.values.reshape(self.rank,) + #Covariance matrix initialization + kuu = np.zeros((t.size, t2.size)) + for q in range(self.rank): + ind1 = index == q + ind2 = index2 == q + r = t[ind1]/lq[q] - t2[0,ind2]/lq[q] + r2 = r*r + #Calculation of covariance function + kuu[np.ix_(ind1, ind2)] = np.exp(-r2) + return kuu + #Evaluation of cross-covariance function def _Kfu(self, X, index, X2, index2): #terms that move along t @@ -632,8 +671,8 @@ class EQ_ODE2(Kern): lq = self.lengthscale.values.reshape(1, self.rank) lq2 = lq*lq - gB = np.empty((t.size,)) - gC = np.empty((t.size,)) + gB = np.empty((t.size, lq.size)) + gC = np.empty((t.size, lq.size)) glq = np.empty((t.size, lq.size)) gS = np.empty((t.size, lq.size)) @@ -723,8 +762,8 @@ class EQ_ODE2(Kern): Ba4_1 = (S2lq*lq)*dgam_dB/w2 Ba4 = Ba4_1*c - gB[ind3t] = np.sum(np.real(Ba1[ind]*upm) - np.real(((Ba2_1[ind] + Ba2_2[ind]*t1)*egamt - Ba3[ind]*egamct)*upv)\ - + np.real(Ba4[ind]*upmd) + np.real((Ba4_1[ind]*ec)*upvd), axis=1) + gB[ind3t] = np.real(Ba1[ind]*upm) - np.real(((Ba2_1[ind] + Ba2_2[ind]*t1)*egamt - Ba3[ind]*egamct)*upv)\ + + np.real(Ba4[ind]*upmd) + np.real((Ba4_1[ind]*ec)*upvd) # gradient wrt C dw_dC = - alphad*dw_dB @@ -738,8 +777,8 @@ class EQ_ODE2(Kern): Ca4_1 = (S2lq*lq)*dgam_dC/w2 Ca4 = Ca4_1*c - gC[ind3t] = np.sum(np.real(Ca1[ind]*upm) - np.real(((Ca2_1[ind] + Ca2_2[ind]*t1)*egamt - (Ca3_1[ind] + Ca3_2[ind]*t1)*egamct)*upv)\ - + np.real(Ca4[ind]*upmd) + np.real((Ca4_1[ind]*ec)*upvd), axis=1) + gC[ind3t] = np.real(Ca1[ind]*upm) - np.real(((Ca2_1[ind] + Ca2_2[ind]*t1)*egamt - (Ca3_1[ind] + Ca3_2[ind]*t1)*egamct)*upv)\ + + np.real(Ca4[ind]*upmd) + np.real((Ca4_1[ind]*ec)*upvd) #Gradient wrt lengthscale #DxQ terms @@ -868,10 +907,10 @@ class EQ_ODE2(Kern): Ba2_1c = c0*(dgamc_dB*(0.5/gamc2 - 0.25*lq2) + 0.5/(w2*gamc)) Ba2_2c = c0*dgamc_dB/gamc - gB[ind2t] = np.sum(Ba1[ind]*upm - ((Ba2_1[ind] + Ba2_2[ind]*t1)*egamt - Ba3[ind]*egamct)*upv\ + gB[ind2t] = Ba1[ind]*upm - ((Ba2_1[ind] + Ba2_2[ind]*t1)*egamt - Ba3[ind]*egamct)*upv\ + Ba4[ind]*upmd + (Ba4_1[ind]*ec)*upvd\ + Ba1c[ind]*upmc - ((Ba2_1c[ind] + Ba2_2c[ind]*t1)*egamct - Ba3c[ind]*egamt)*upvc\ - + Ba4c[ind]*upmdc + (Ba4_1c[ind]*ec2)*upvdc, axis=1) + + Ba4c[ind]*upmdc + (Ba4_1c[ind]*ec2)*upvdc ##Gradient wrt C dw_dC = 0.5*alphad/w @@ -895,10 +934,10 @@ class EQ_ODE2(Kern): Ca4_1c = S2lq2*(dgamc_dC/w2) Ca4c = Ca4_1c*c2 - gC[ind2t] = np.sum(Ca1[ind]*upm - ((Ca2_1[ind] + Ca2_2[ind]*t1)*egamt - (Ca3_1[ind] + Ca3_2[ind]*t1)*egamct)*upv\ + gC[ind2t] = Ca1[ind]*upm - ((Ca2_1[ind] + Ca2_2[ind]*t1)*egamt - (Ca3_1[ind] + Ca3_2[ind]*t1)*egamct)*upv\ + Ca4[ind]*upmd + (Ca4_1[ind]*ec)*upvd\ + Ca1c[ind]*upmc - ((Ca2_1c[ind] + Ca2_2c[ind]*t1)*egamct - (Ca3_1c[ind] + Ca3_2c[ind]*t1)*egamt)*upvc\ - + Ca4c[ind]*upmdc + (Ca4_1c[ind]*ec2)*upvdc, axis=1) + + Ca4c[ind]*upmdc + (Ca4_1c[ind]*ec2)*upvdc #Gradient wrt lengthscale #DxQ terms diff --git a/GPy/kern/src/independent_outputs.py b/GPy/kern/src/independent_outputs.py index 5fd22b15..db6f9d37 100644 --- a/GPy/kern/src/independent_outputs.py +++ b/GPy/kern/src/independent_outputs.py @@ -56,14 +56,18 @@ class IndependentOutputs(CombinationKernel): self.single_kern = False self.kern = kernels super(IndependentOutputs, self).__init__(kernels=kernels, extra_dims=[index_dim], name=name) - self.index_dim = index_dim + # The combination kernel ALLWAYS puts the extra dimension last. + # Thus, the index dimension of this kernel is always the last dimension + # after slicing. This is why the index_dim is just the last column: + self.index_dim = -1 def K(self,X ,X2=None): slices = index_to_slices(X[:,self.index_dim]) kerns = itertools.repeat(self.kern) if self.single_kern else self.kern if X2 is None: target = np.zeros((X.shape[0], X.shape[0])) - [[target.__setitem__((s,ss), kern.K(X[s,:], X[ss,:])) for s,ss in itertools.product(slices_i, slices_i)] for kern, slices_i in zip(kerns, slices)] + #[[target.__setitem__((s,ss), kern.K(X[s,:], X[ss,:])) for s,ss in itertools.product(slices_i, slices_i)] for kern, slices_i in zip(kerns, slices)] + [[target.__setitem__((s,ss), kern.K(X[s,:]) if s==ss else kern.K(X[s,:], X[ss,:])) for s,ss in itertools.product(slices_i, slices_i)] for kern, slices_i in zip(kerns, slices)] else: slices2 = index_to_slices(X2[:,self.index_dim]) target = np.zeros((X.shape[0], X2.shape[0])) @@ -103,13 +107,10 @@ class IndependentOutputs(CombinationKernel): target = np.zeros(X.shape) kerns = itertools.repeat(self.kern) if self.single_kern else self.kern if X2 is None: - # TODO: make use of index_to_slices - # FIXME: Broken as X is already sliced out - # print("Warning, gradients_X may not be working, I believe X has already been sliced out by the slicer!") values = np.unique(X[:,self.index_dim]) slices = [X[:,self.index_dim]==i for i in values] - [target.__setitem__(s, kern.gradients_X(dL_dK[s,s],X[s],None)) - for kern, s in zip(kerns, slices)] + for kern, s in zip(kerns, slices): + target[s] += kern.gradients_X(dL_dK[s, :][:, s],X[s], None) #slices = index_to_slices(X[:,self.index_dim]) #[[np.add(target[s], kern.gradients_X(dL_dK[s,s], X[s]), out=target[s]) # for s in slices_i] for kern, slices_i in zip(kerns, slices)] @@ -121,8 +122,8 @@ class IndependentOutputs(CombinationKernel): values = np.unique(X[:,self.index_dim]) slices = [X[:,self.index_dim]==i for i in values] slices2 = [X2[:,self.index_dim]==i for i in values] - [target.__setitem__(s, kern.gradients_X(dL_dK[s, :][:, s2],X[s],X2[s2])) - for kern, s, s2 in zip(kerns, slices, slices2)] + for kern, s, s2 in zip(kerns, slices, slices2): + target[s] += kern.gradients_X(dL_dK[s, :][:, s2],X[s],X2[s2]) # TODO: make work with index_to_slices #slices = index_to_slices(X[:,self.index_dim]) #slices2 = index_to_slices(X2[:,self.index_dim]) @@ -133,7 +134,9 @@ class IndependentOutputs(CombinationKernel): slices = index_to_slices(X[:,self.index_dim]) kerns = itertools.repeat(self.kern) if self.single_kern else self.kern target = np.zeros(X.shape) - [[target.__setitem__(s, kern.gradients_X_diag(dL_dKdiag[s],X[s])) for s in slices_i] for kern, slices_i in zip(kerns, slices)] + for kern, slices_i in zip(kerns, slices): + for s in slices_i: + target[s] += kern.gradients_X_diag(dL_dKdiag[s],X[s]) return target def update_gradients_diag(self, dL_dKdiag, X): diff --git a/GPy/kern/src/integral.py b/GPy/kern/src/integral.py new file mode 100644 index 00000000..6febf203 --- /dev/null +++ b/GPy/kern/src/integral.py @@ -0,0 +1,82 @@ +# Written by Mike Smith michaeltsmith.org.uk + +from __future__ import division +import numpy as np +from .kern import Kern +from ...core.parameterization import Param +from paramz.transformations import Logexp +import math + +class Integral(Kern): #todo do I need to inherit from Stationary + """ + Integral kernel between... + """ + + def __init__(self, input_dim, variances=None, lengthscale=None, ARD=False, active_dims=None, name='integral'): + super(Integral, self).__init__(input_dim, active_dims, name) + + if lengthscale is None: + lengthscale = np.ones(1) + else: + lengthscale = np.asarray(lengthscale) + + self.lengthscale = Param('lengthscale', lengthscale, Logexp()) #Logexp - transforms to allow positive only values... + self.variances = Param('variances', variances, Logexp()) #and here. + self.link_parameters(self.variances, self.lengthscale) #this just takes a list of parameters we need to optimise. + + def h(self, z): + return 0.5 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + def dk_dl(self, t, tprime, l): #derivative of the kernel wrt lengthscale + return l * ( self.h(t/l) - self.h((t - tprime)/l) + self.h(tprime/l) - 1) + + def update_gradients_full(self, dL_dK, X, X2=None): + if X2 is None: #we're finding dK_xx/dTheta + dK_dl = np.zeros([X.shape[0],X.shape[0]]) + dK_dv = np.zeros([X.shape[0],X.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X): + dK_dl[i,j] = self.variances[0]*self.dk_dl(x[0],x2[0],self.lengthscale[0]) #TODO Multiple length scales + dK_dv[i,j] = self.k_xx(x[0],x2[0],self.lengthscale[0]) #the gradient wrt the variance is k_xx. + self.lengthscale.gradient = np.sum(dK_dl * dL_dK) + self.variances.gradient = np.sum(dK_dv * dL_dK) + else: #we're finding dK_xf/Dtheta + raise NotImplementedError("Currently this function only handles finding the gradient of a single vector of inputs (X) not a pair of vectors (X and X2)") + + #useful little function to help calculate the covariances. + def g(self,z): + return 1.0 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + #covariance between gradients (it's the gradients that we want out... maybe we should have a way of getting K_ff too? Currently you get the diag of K_ff from Kdiag) + def k_xx(self,t,tprime,l): + return 0.5 * (l**2) * ( self.g(t/l) - self.g((t - tprime)/l) + self.g(tprime/l) - 1) + + def k_ff(self,t,tprime,l): + return np.exp(-((t-tprime)**2)/(l**2)) #rbf + + #covariance between the gradient and the actual value + def k_xf(self,t,tprime,l): + return 0.5 * np.sqrt(math.pi) * l * (math.erf((t-tprime)/l) + math.erf(tprime/l)) + + def K(self, X, X2=None): + if X2 is None: + K_xx = np.zeros([X.shape[0],X.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X): + K_xx[i,j] = self.k_xx(x[0],x2[0],self.lengthscale[0]) + return K_xx * self.variances[0] + else: + K_xf = np.zeros([X.shape[0],X2.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X2): + K_xf[i,j] = self.k_xf(x[0],x2[0],self.lengthscale[0]) + return K_xf * self.variances[0] + + def Kdiag(self, X): + """I've used the fact that we call this method for K_ff when finding the covariance as a hack so + I know if I should return K_ff or K_xx. In this case we're returning K_ff!! + $K_{ff}^{post} = K_{ff} - K_{fx} K_{xx}^{-1} K_{xf}$""" + K_ff = np.zeros(X.shape[0]) + for i,x in enumerate(X): + K_ff[i] = self.k_ff(x[0],x[0],self.lengthscale[0]) + return K_ff * self.variances[0] diff --git a/GPy/kern/src/integral_limits.py b/GPy/kern/src/integral_limits.py new file mode 100644 index 00000000..10370328 --- /dev/null +++ b/GPy/kern/src/integral_limits.py @@ -0,0 +1,115 @@ +# Written by Mike Smith michaeltsmith.org.uk + +from __future__ import division +import math +import numpy as np +from .kern import Kern +from ...core.parameterization import Param +from paramz.transformations import Logexp + + +class Integral_Limits(Kern): + """ + Integral kernel. This kernel allows 1d histogram or binned data to be modelled. + The outputs are the counts in each bin. The inputs (on two dimensions) are the start and end points of each bin. + The kernel's predictions are the latent function which might have generated those binned results. + """ + + def __init__(self, input_dim, variances=None, lengthscale=None, ARD=False, active_dims=None, name='integral'): + """ + """ + super(Integral_Limits, self).__init__(input_dim, active_dims, name) + + if lengthscale is None: + lengthscale = np.ones(1) + else: + lengthscale = np.asarray(lengthscale) + + self.lengthscale = Param('lengthscale', lengthscale, Logexp()) #Logexp - transforms to allow positive only values... + self.variances = Param('variances', variances, Logexp()) #and here. + self.link_parameters(self.variances, self.lengthscale) #this just takes a list of parameters we need to optimise. + + def h(self, z): + return 0.5 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + def dk_dl(self, t, tprime, s, sprime, l): #derivative of the kernel wrt lengthscale + return l * ( self.h((t-sprime)/l) - self.h((t - tprime)/l) + self.h((tprime-s)/l) - self.h((s-sprime)/l)) + + def update_gradients_full(self, dL_dK, X, X2=None): + if X2 is None: #we're finding dK_xx/dTheta + dK_dl = np.zeros([X.shape[0],X.shape[0]]) + dK_dv = np.zeros([X.shape[0],X.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X): + dK_dl[i,j] = self.variances[0]*self.dk_dl(x[0],x2[0],x[1],x2[1],self.lengthscale[0]) + dK_dv[i,j] = self.k_xx(x[0],x2[0],x[1],x2[1],self.lengthscale[0]) #the gradient wrt the variance is k_xx. + self.lengthscale.gradient = np.sum(dK_dl * dL_dK) + self.variances.gradient = np.sum(dK_dv * dL_dK) + else: #we're finding dK_xf/Dtheta + raise NotImplementedError("Currently this function only handles finding the gradient of a single vector of inputs (X) not a pair of vectors (X and X2)") + + #useful little function to help calculate the covariances. + def g(self,z): + return 1.0 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + def k_xx(self,t,tprime,s,sprime,l): + """Covariance between observed values. + + s and t are one domain of the integral (i.e. the integral between s and t) + sprime and tprime are another domain of the integral (i.e. the integral between sprime and tprime) + + We're interested in how correlated these two integrals are. + + Note: We've not multiplied by the variance, this is done in K.""" + return 0.5 * (l**2) * ( self.g((t-sprime)/l) + self.g((tprime-s)/l) - self.g((t - tprime)/l) - self.g((s-sprime)/l)) + + def k_ff(self,t,tprime,l): + """Doesn't need s or sprime as we're looking at the 'derivatives', so no domains over which to integrate are required""" + return np.exp(-((t-tprime)**2)/(l**2)) #rbf + + def k_xf(self,t,tprime,s,l): + """Covariance between the gradient (latent value) and the actual (observed) value. + + Note that sprime isn't actually used in this expression, presumably because the 'primes' are the gradient (latent) values which don't + involve an integration, and thus there is no domain over which they're integrated, just a single value that we want.""" + return 0.5 * np.sqrt(math.pi) * l * (math.erf((t-tprime)/l) + math.erf((tprime-s)/l)) + + def K(self, X, X2=None): + """Note: We have a latent function and an output function. We want to be able to find: + - the covariance between values of the output function + - the covariance between values of the latent function + - the "cross covariance" between values of the output function and the latent function + This method is used by GPy to either get the covariance between the outputs (K_xx) or + is used to get the cross covariance (between the latent function and the outputs (K_xf). + We take advantage of the places where this function is used: + - if X2 is none, then we know that the items being compared (to get the covariance for) + are going to be both from the OUTPUT FUNCTION. + - if X2 is not none, then we know that the items being compared are from two different + sets (the OUTPUT FUNCTION and the LATENT FUNCTION). + + If we want the covariance between values of the LATENT FUNCTION, we take advantage of + the fact that we only need that when we do prediction, and this only calls Kdiag (not K). + So the covariance between LATENT FUNCTIONS is available from Kdiag. + """ + if X2 is None: + K_xx = np.zeros([X.shape[0],X.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X): + K_xx[i,j] = self.k_xx(x[0],x2[0],x[1],x2[1],self.lengthscale[0]) + return K_xx * self.variances[0] + else: + K_xf = np.zeros([X.shape[0],X2.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X2): + K_xf[i,j] = self.k_xf(x[0],x2[0],x[1],self.lengthscale[0]) #x2[1] unused, see k_xf docstring for explanation. + return K_xf * self.variances[0] + + def Kdiag(self, X): + """I've used the fact that we call this method during prediction (instead of K). When we + do prediction we want to know the covariance between LATENT FUNCTIONS (K_ff) (as that's probably + what the user wants). + $K_{ff}^{post} = K_{ff} - K_{fx} K_{xx}^{-1} K_{xf}$""" + K_ff = np.zeros(X.shape[0]) + for i,x in enumerate(X): + K_ff[i] = self.k_ff(x[0],x[0],self.lengthscale[0]) + return K_ff * self.variances[0] diff --git a/GPy/kern/src/kern.py b/GPy/kern/src/kern.py index ad6ed7db..c6f62bd9 100644 --- a/GPy/kern/src/kern.py +++ b/GPy/kern/src/kern.py @@ -15,10 +15,10 @@ class Kern(Parameterized): # This adds input slice support. The rather ugly code for slicing can be # found in kernel_slice_operations # __meataclass__ is ignored in Python 3 - needs to be put in the function definiton - #__metaclass__ = KernCallsViaSlicerMeta - #Here, we use the Python module six to support Py3 and Py2 simultaneously + # __metaclass__ = KernCallsViaSlicerMeta + # Here, we use the Python module six to support Py3 and Py2 simultaneously #=========================================================================== - _support_GPU=False + _support_GPU = False def __init__(self, input_dim, active_dims, name, useGPU=False, *a, **kw): """ The base class for a kernel: a positive definite function @@ -48,11 +48,11 @@ class Kern(Parameterized): if active_dims is None: active_dims = np.arange(input_dim) - + self.active_dims = np.asarray(active_dims, np.int_) - + self._all_dims_active = np.atleast_1d(self.active_dims).astype(int) - + assert self.active_dims.size == self.input_dim, "input_dim={} does not match len(active_dim)={}".format(self.input_dim, self._all_dims_active.size) self._sliced_X = 0 @@ -62,7 +62,7 @@ class Kern(Parameterized): self.psicomp = PSICOMP_GH() def __setstate__(self, state): - self._all_dims_active = np.arange(0, max(state['active_dims'])+1) + self._all_dims_active = np.arange(0, max(state['active_dims']) + 1) super(Kern, self).__setstate__(state) @property @@ -132,18 +132,18 @@ class Kern(Parameterized): raise NotImplementedError def gradients_X_X2(self, dL_dK, X, X2): return self.gradients_X(dL_dK, X, X2), self.gradients_X(dL_dK.T, X2, X) - def gradients_XX(self, dL_dK, X, X2): + def gradients_XX(self, dL_dK, X, X2, cov=True): """ .. math:: \\frac{\partial^2 L}{\partial X\partial X_2} = \\frac{\partial L}{\partial K}\\frac{\partial^2 K}{\partial X\partial X_2} """ - raise(NotImplementedError, "This is the second derivative of K wrt X and X2, and not implemented for this kernel") - def gradients_XX_diag(self, dL_dKdiag, X): + raise NotImplementedError("This is the second derivative of K wrt X and X2, and not implemented for this kernel") + def gradients_XX_diag(self, dL_dKdiag, X, cov=True): """ The diagonal of the second derivative w.r.t. X and X2 """ - raise(NotImplementedError, "This is the diagonal of the second derivative of K wrt X and X2, and not implemented for this kernel") + raise NotImplementedError("This is the diagonal of the second derivative of K wrt X and X2, and not implemented for this kernel") def gradients_X_diag(self, dL_dKdiag, X): """ The diagonal of the derivative w.r.t. X @@ -211,6 +211,12 @@ class Kern(Parameterized): def input_sensitivity(self, summarize=True): """ Returns the sensitivity for each dimension of this kernel. + + This is an arbitrary measurement based on the parameters + of the kernel per dimension and scaling in general. + + Use this as relative measurement, not for absolute comparison between + kernels. """ return np.zeros(self.input_dim) @@ -292,20 +298,19 @@ class Kern(Parameterized): """ assert isinstance(other, Kern), "only kernels can be multiplied to kernels..." from .prod import Prod - #kernels = [] - #if isinstance(self, Prod): kernels.extend(self.parameters) - #else: kernels.append(self) - #if isinstance(other, Prod): kernels.extend(other.parameters) - #else: kernels.append(other) + # kernels = [] + # if isinstance(self, Prod): kernels.extend(self.parameters) + # else: kernels.append(self) + # if isinstance(other, Prod): kernels.extend(other.parameters) + # else: kernels.append(other) return Prod([self, other], name) def _check_input_dim(self, X): - assert X.shape[1] == self.input_dim, "{} did not specify _all_dims_active and X has wrong shape: X_dim={}, whereas input_dim={}".format(self.name, X.shape[1], self.input_dim) + assert X.shape[1] == self.input_dim, "{} did not specify active_dims and X has wrong shape: X_dim={}, whereas input_dim={}".format(self.name, X.shape[1], self.input_dim) def _check_active_dims(self, X): assert X.shape[1] >= len(self._all_dims_active), "At least {} dimensional X needed, X.shape={!s}".format(len(self._all_dims_active), X.shape) - class CombinationKernel(Kern): """ Abstract super class for combination kernels. @@ -324,19 +329,17 @@ class CombinationKernel(Kern): """ assert all([isinstance(k, Kern) for k in kernels]) extra_dims = np.asarray(extra_dims, dtype=int) - - active_dims = reduce(np.union1d, (np.r_[x.active_dims] for x in kernels), np.array([], dtype=int)) - + + active_dims = reduce(np.union1d, (np.r_[x.active_dims] for x in kernels), extra_dims) + input_dim = active_dims.size - if extra_dims is not None: - input_dim += extra_dims.size # initialize the kernel with the full input_dim super(CombinationKernel, self).__init__(input_dim, active_dims, name) effective_input_dim = reduce(max, (k._all_dims_active.max() for k in kernels)) + 1 self._all_dims_active = np.array(np.concatenate((np.arange(effective_input_dim), extra_dims if extra_dims is not None else [])), dtype=int) - + self.extra_dims = extra_dims self.link_parameters(*kernels) @@ -345,7 +348,7 @@ class CombinationKernel(Kern): return self.parameters def _set_all_dims_ative(self): - self._all_dims_active = np.atleast_1d(self.active_dims).astype(int) + self._all_dims_active = np.atleast_1d(self.active_dims).astype(int) def input_sensitivity(self, summarize=True): """ diff --git a/GPy/kern/src/kernel_slice_operations.py b/GPy/kern/src/kernel_slice_operations.py index 57b34de9..327436e7 100644 --- a/GPy/kern/src/kernel_slice_operations.py +++ b/GPy/kern/src/kernel_slice_operations.py @@ -13,19 +13,20 @@ from paramz.parameterized import ParametersChangedMeta def put_clean(dct, name, func): if name in dct: - #dct['_clean_{}'.format(name)] = dct[name] + dct['_clean_{}'.format(name)] = dct[name] dct[name] = func(dct[name]) class KernCallsViaSlicerMeta(ParametersChangedMeta): def __new__(cls, name, bases, dct): put_clean(dct, 'K', _slice_K) put_clean(dct, 'Kdiag', _slice_Kdiag) + put_clean(dct, 'phi', _slice_Kdiag) put_clean(dct, 'update_gradients_full', _slice_update_gradients_full) put_clean(dct, 'update_gradients_diag', _slice_update_gradients_diag) put_clean(dct, 'gradients_X', _slice_gradients_X) put_clean(dct, 'gradients_X_X2', _slice_gradients_X) put_clean(dct, 'gradients_XX', _slice_gradients_XX) - put_clean(dct, 'gradients_XX_diag', _slice_gradients_X_diag) + put_clean(dct, 'gradients_XX_diag', _slice_gradients_XX_diag) put_clean(dct, 'gradients_X_diag', _slice_gradients_X_diag) put_clean(dct, 'psi0', _slice_psi) @@ -38,15 +39,16 @@ class KernCallsViaSlicerMeta(ParametersChangedMeta): return super(KernCallsViaSlicerMeta, cls).__new__(cls, name, bases, dct) class _Slice_wrap(object): - def __init__(self, k, X, X2=None, ret_shape=None): + def __init__(self, k, X, X2=None, diag=False, ret_shape=None): self.k = k + self.diag = diag if ret_shape is None: self.shape = X.shape else: self.shape = ret_shape - assert X.ndim == 2, "only matrices are allowed as inputs to kernels for now, given X.shape={!s}".format(X.shape) + assert X.ndim == 2, "need at least column vectors as inputs to kernels for now, given X.shape={!s}".format(X.shape) if X2 is not None: - assert X2.ndim == 2, "only matrices are allowed as inputs to kernels for now, given X2.shape={!s}".format(X2.shape) + assert X2.ndim == 2, "need at least column vectors as inputs to kernels for now, given X2.shape={!s}".format(X2.shape) if (self.k._all_dims_active is not None) and (self.k._sliced_X == 0): self.k._check_active_dims(X) self.X = self.k._slice_X(X) @@ -67,8 +69,13 @@ class _Slice_wrap(object): ret = np.zeros(self.shape) if len(self.shape) == 2: ret[:, self.k._all_dims_active] = return_val - elif len(self.shape) == 3: - ret[:, :, self.k._all_dims_active] = return_val + elif len(self.shape) == 3: # derivative for X2!=None + if self.diag: + ret.T[np.ix_(self.k._all_dims_active, self.k._all_dims_active)] = return_val.T + else: + ret[:, :, self.k._all_dims_active] = return_val + elif len(self.shape) == 4: # second order derivative + ret.T[np.ix_(self.k._all_dims_active, self.k._all_dims_active)] = return_val.T return ret return return_val @@ -112,23 +119,34 @@ def _slice_gradients_X(f): return ret return wrap +def _slice_gradients_X_diag(f): + @wraps(f) + def wrap(self, dL_dKdiag, X): + with _Slice_wrap(self, X, None) as s: + ret = s.handle_return_array(f(self, dL_dKdiag, s.X)) + return ret + return wrap + def _slice_gradients_XX(f): @wraps(f) def wrap(self, dL_dK, X, X2=None): if X2 is None: N, M = X.shape[0], X.shape[0] + Q1 = Q2 = X.shape[1] else: N, M = X.shape[0], X2.shape[0] - with _Slice_wrap(self, X, X2, ret_shape=(N, M, X.shape[1])) as s: + Q1, Q2 = X.shape[1], X2.shape[1] #with _Slice_wrap(self, X, X2, ret_shape=None) as s: + with _Slice_wrap(self, X, X2, ret_shape=(N, M, Q1, Q2)) as s: ret = s.handle_return_array(f(self, dL_dK, s.X, s.X2)) return ret return wrap -def _slice_gradients_X_diag(f): +def _slice_gradients_XX_diag(f): @wraps(f) def wrap(self, dL_dKdiag, X): - with _Slice_wrap(self, X, None) as s: + N, Q = X.shape + with _Slice_wrap(self, X, None, diag=True, ret_shape=(N, Q, Q)) as s: ret = s.handle_return_array(f(self, dL_dKdiag, s.X)) return ret return wrap diff --git a/GPy/kern/src/linear.py b/GPy/kern/src/linear.py index fa412c1d..e7089fe1 100644 --- a/GPy/kern/src/linear.py +++ b/GPy/kern/src/linear.py @@ -102,17 +102,39 @@ class Linear(Kern): return dL_dK.dot(X2)*self.variances #np.einsum('jq,q,ij->iq', X2, self.variances, dL_dK) def gradients_XX(self, dL_dK, X, X2=None): - if X2 is None: dL_dK = (dL_dK+dL_dK.T)/2 + """ + Given the derivative of the objective K(dL_dK), compute the second derivative of K wrt X and X2: + + returns the full covariance matrix [QxQ] of the input dimensionfor each pair or vectors, thus + the returned array is of shape [NxNxQxQ]. + + ..math: + \frac{\partial^2 K}{\partial X2 ^2} = - \frac{\partial^2 K}{\partial X\partial X2} + + ..returns: + dL2_dXdX2: [NxMxQxQ] for X [NxQ] and X2[MxQ] (X2 is X if, X2 is None) + Thus, we return the second derivative in X2. + """ if X2 is None: - return 2*np.ones(X.shape)*self.variances - else: - return np.ones(X.shape)*self.variances + X2 = X + return np.zeros((X.shape[0], X2.shape[0], X.shape[1], X.shape[1])) + #if X2 is None: dL_dK = (dL_dK+dL_dK.T)/2 + #if X2 is None: + # return np.ones(np.repeat(X.shape, 2)) * (self.variances[None,:] + self.variances[:, None])[None, None, :, :] + #else: + # return np.ones((X.shape[0], X2.shape[0], X.shape[1], X.shape[1])) * (self.variances[None,:] + self.variances[:, None])[None, None, :, :] + def gradients_X_diag(self, dL_dKdiag, X): return 2.*self.variances*dL_dKdiag[:,None]*X def gradients_XX_diag(self, dL_dKdiag, X): - return 2*np.ones(X.shape)*self.variances + return np.zeros((X.shape[0], X.shape[1], X.shape[1])) + + #dims = X.shape + #if cov: + # dims += (X.shape[1],) + #return 2*np.ones(dims)*self.variances def input_sensitivity(self, summarize=True): return np.ones(self.input_dim) * self.variances diff --git a/GPy/kern/src/multidimensional_integral_limits.py b/GPy/kern/src/multidimensional_integral_limits.py new file mode 100644 index 00000000..8a07595b --- /dev/null +++ b/GPy/kern/src/multidimensional_integral_limits.py @@ -0,0 +1,120 @@ +# Written by Mike Smith michaeltsmith.org.uk + +from __future__ import division +import numpy as np +from .kern import Kern +from ...core.parameterization import Param +from paramz.transformations import Logexp +import math + +class Multidimensional_Integral_Limits(Kern): #todo do I need to inherit from Stationary + """ + Integral kernel, can include limits on each integral value. This kernel allows an n-dimensional + histogram or binned data to be modelled. The outputs are the counts in each bin. The inputs + are the start and end points of each bin: Pairs of inputs act as the limits on each bin. So + inputs 4 and 5 provide the start and end values of each bin in the 3rd dimension. + The kernel's predictions are the latent function which might have generated those binned results. + """ + + def __init__(self, input_dim, variances=None, lengthscale=None, ARD=False, active_dims=None, name='integral'): + super(Multidimensional_Integral_Limits, self).__init__(input_dim, active_dims, name) + + if lengthscale is None: + lengthscale = np.ones(1) + else: + lengthscale = np.asarray(lengthscale) + + self.lengthscale = Param('lengthscale', lengthscale, Logexp()) #Logexp - transforms to allow positive only values... + self.variances = Param('variances', variances, Logexp()) #and here. + self.link_parameters(self.variances, self.lengthscale) #this just takes a list of parameters we need to optimise. + + def h(self, z): + return 0.5 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + def dk_dl(self, t, tprime, s, sprime, l): #derivative of the kernel wrt lengthscale + return l * ( self.h((t-sprime)/l) - self.h((t - tprime)/l) + self.h((tprime-s)/l) - self.h((s-sprime)/l)) + + def update_gradients_full(self, dL_dK, X, X2=None): + if X2 is None: #we're finding dK_xx/dTheta + dK_dl_term = np.zeros([X.shape[0],X.shape[0],self.lengthscale.shape[0]]) + k_term = np.zeros([X.shape[0],X.shape[0],self.lengthscale.shape[0]]) + dK_dl = np.zeros([X.shape[0],X.shape[0],self.lengthscale.shape[0]]) + dK_dv = np.zeros([X.shape[0],X.shape[0]]) + for il,l in enumerate(self.lengthscale): + idx = il*2 + for i,x in enumerate(X): + for j,x2 in enumerate(X): + dK_dl_term[i,j,il] = self.dk_dl(x[idx],x2[idx],x[idx+1],x2[idx+1],l) + k_term[i,j,il] = self.k_xx(x[idx],x2[idx],x[idx+1],x2[idx+1],l) + for il,l in enumerate(self.lengthscale): + dK_dl = self.variances[0] * dK_dl_term[:,:,il] + for jl, l in enumerate(self.lengthscale): + if jl!=il: + dK_dl *= k_term[:,:,jl] + self.lengthscale.gradient[il] = np.sum(dK_dl * dL_dK) + dK_dv = self.calc_K_xx_wo_variance(X) #the gradient wrt the variance is k_xx. + self.variances.gradient = np.sum(dK_dv * dL_dK) + else: #we're finding dK_xf/Dtheta + raise NotImplementedError("Currently this function only handles finding the gradient of a single vector of inputs (X) not a pair of vectors (X and X2)") + + + + #useful little function to help calculate the covariances. + def g(self,z): + return 1.0 * z * np.sqrt(math.pi) * math.erf(z) + np.exp(-(z**2)) + + def k_xx(self,t,tprime,s,sprime,l): + """Covariance between observed values. + + s and t are one domain of the integral (i.e. the integral between s and t) + sprime and tprime are another domain of the integral (i.e. the integral between sprime and tprime) + + We're interested in how correlated these two integrals are. + + Note: We've not multiplied by the variance, this is done in K.""" + return 0.5 * (l**2) * ( self.g((t-sprime)/l) + self.g((tprime-s)/l) - self.g((t - tprime)/l) - self.g((s-sprime)/l)) + + def k_ff(self,t,tprime,l): + """Doesn't need s or sprime as we're looking at the 'derivatives', so no domains over which to integrate are required""" + return np.exp(-((t-tprime)**2)/(l**2)) #rbf + + def k_xf(self,t,tprime,s,l): + """Covariance between the gradient (latent value) and the actual (observed) value. + + Note that sprime isn't actually used in this expression, presumably because the 'primes' are the gradient (latent) values which don't + involve an integration, and thus there is no domain over which they're integrated, just a single value that we want.""" + return 0.5 * np.sqrt(math.pi) * l * (math.erf((t-tprime)/l) + math.erf((tprime-s)/l)) + + def calc_K_xx_wo_variance(self,X): + """Calculates K_xx without the variance term""" + K_xx = np.ones([X.shape[0],X.shape[0]]) #ones now as a product occurs over each dimension + for i,x in enumerate(X): + for j,x2 in enumerate(X): + for il,l in enumerate(self.lengthscale): + idx = il*2 #each pair of input dimensions describe the limits on one actual dimension in the data + K_xx[i,j] *= self.k_xx(x[idx],x2[idx],x[idx+1],x2[idx+1],l) + return K_xx + + def K(self, X, X2=None): + if X2 is None: #X vs X + K_xx = self.calc_K_xx_wo_variance(X) + return K_xx * self.variances[0] + else: #X vs X2 + K_xf = np.ones([X.shape[0],X2.shape[0]]) + for i,x in enumerate(X): + for j,x2 in enumerate(X2): + for il,l in enumerate(self.lengthscale): + idx = il*2 + K_xf[i,j] *= self.k_xf(x[idx],x2[idx],x[idx+1],l) + return K_xf * self.variances[0] + + def Kdiag(self, X): + """I've used the fact that we call this method for K_ff when finding the covariance as a hack so + I know if I should return K_ff or K_xx. In this case we're returning K_ff!! + $K_{ff}^{post} = K_{ff} - K_{fx} K_{xx}^{-1} K_{xf}$""" + K_ff = np.ones(X.shape[0]) + for i,x in enumerate(X): + for il,l in enumerate(self.lengthscale): + idx = il*2 + K_ff[i] *= self.k_ff(x[idx],x[idx],l) + return K_ff * self.variances[0] diff --git a/GPy/kern/src/prod.py b/GPy/kern/src/prod.py index 1e18b405..ab3df431 100644 --- a/GPy/kern/src/prod.py +++ b/GPy/kern/src/prod.py @@ -99,9 +99,120 @@ class Prod(CombinationKernel): def input_sensitivity(self, summarize=True): if summarize: - i_s = np.zeros((self.input_dim)) + i_s = np.ones((self.input_dim)) for k in self.parts: i_s[k._all_dims_active] *= k.input_sensitivity(summarize) return i_s else: return super(Prod, self).input_sensitivity(summarize) + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + part_start_param_index = 0 + for p in self.parts: + if not p.is_fixed: + part_param_num = len(p.param_array) # number of parameters in the part + p.sde_update_gradient_full(gradients[part_start_param_index:(part_start_param_index+part_param_num)]) + part_start_param_index += part_param_num + + def sde(self): + """ + """ + F = np.array((0,), ndmin=2) + L = np.array((1,), ndmin=2) + Qc = np.array((1,), ndmin=2) + H = np.array((1,), ndmin=2) + Pinf = np.array((1,), ndmin=2) + P0 = np.array((1,), ndmin=2) + dF = None + dQc = None + dPinf = None + dP0 = None + + # Assign models + for p in self.parts: + (Ft,Lt,Qct,Ht,P_inft, P0t, dFt,dQct,dP_inft,dP0t) = p.sde() + + # check derivative dimensions -> + number_of_parameters = len(p.param_array) + assert dFt.shape[2] == number_of_parameters, "Dynamic matrix derivative shape is wrong" + assert dQct.shape[2] == number_of_parameters, "Diffusion matrix derivative shape is wrong" + assert dP_inft.shape[2] == number_of_parameters, "Infinite covariance matrix derivative shape is wrong" + # check derivative dimensions <- + + # exception for periodic kernel + if (p.name == 'std_periodic'): + Qct = P_inft + dQct = dP_inft + + dF = dkron(F,dF,Ft,dFt,'sum') + dQc = dkron(Qc,dQc,Qct,dQct,'prod') + dPinf = dkron(Pinf,dPinf,P_inft,dP_inft,'prod') + dP0 = dkron(P0,dP0,P0t,dP0t,'prod') + + F = np.kron(F,np.eye(Ft.shape[0])) + np.kron(np.eye(F.shape[0]),Ft) + L = np.kron(L,Lt) + Qc = np.kron(Qc,Qct) + Pinf = np.kron(Pinf,P_inft) + P0 = np.kron(P0,P_inft) + H = np.kron(H,Ht) + + return (F,L,Qc,H,Pinf,P0,dF,dQc,dPinf,dP0) + +def dkron(A,dA,B,dB, operation='prod'): + """ + Function computes the derivative of Kronecker product A*B + (or Kronecker sum A+B). + + Input: + ----------------------- + + A: 2D matrix + Some matrix + dA: 3D (or 2D matrix) + Derivarives of A + B: 2D matrix + Some matrix + dB: 3D (or 2D matrix) + Derivarives of B + + operation: str 'prod' or 'sum' + Which operation is considered. If the operation is 'sum' it is assumed + that A and are square matrices.s + + Output: + dC: 3D matrix + Derivative of Kronecker product A*B (or Kronecker sum A+B) + """ + + if dA is None: + dA_param_num = 0 + dA = np.zeros((A.shape[0], A.shape[1],1)) + else: + dA_param_num = dA.shape[2] + + if dB is None: + dB_param_num = 0 + dB = np.zeros((B.shape[0], B.shape[1],1)) + else: + dB_param_num = dB.shape[2] + + # Space allocation for derivative matrix + dC = np.zeros((A.shape[0]*B.shape[0], A.shape[1]*B.shape[1], dA_param_num + dB_param_num)) + + for k in range(dA_param_num): + if operation == 'prod': + dC[:,:,k] = np.kron(dA[:,:,k],B); + else: + dC[:,:,k] = np.kron(dA[:,:,k],np.eye( B.shape[0] )) + + for k in range(dB_param_num): + if operation == 'prod': + dC[:,:,dA_param_num+k] = np.kron(A,dB[:,:,k]) + else: + dC[:,:,dA_param_num+k] = np.kron(np.eye( A.shape[0] ),dB[:,:,k]) + + return dC diff --git a/GPy/kern/src/rbf.py b/GPy/kern/src/rbf.py index ff86561d..7a15abe8 100644 --- a/GPy/kern/src/rbf.py +++ b/GPy/kern/src/rbf.py @@ -39,6 +39,8 @@ class RBF(Stationary): def dK2_drdr(self, r): return (r**2-1)*self.K_of_r(r) + def dK2_drdr_diag(self): + return -self.variance # as the diagonal of r is always filled with zeros def __getstate__(self): dc = super(RBF, self).__getstate__() if self.useGPU: diff --git a/GPy/kern/src/sde_brownian.py b/GPy/kern/src/sde_brownian.py new file mode 100644 index 00000000..b76761a0 --- /dev/null +++ b/GPy/kern/src/sde_brownian.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance Brownian motion covariance function with the +Stochastic Differential Equation (SDE) functionality. +""" + +from .brownian import Brownian + +import numpy as np + +class sde_Brownian(Brownian): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Linear kernel: + + .. math:: + + k(x,y) = \sigma^2 min(x,y) + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) # this is initial variancve in Bayesian linear regression + + F = np.array( ((0,1.0),(0,0) )) + L = np.array( ((1.0,),(0,)) ) + Qc = np.array( ((variance,),) ) + H = np.array( ((1.0,0),) ) + + Pinf = np.array( ( (0, -0.5*variance ), (-0.5*variance, 0) ) ) + #P0 = Pinf.copy() + P0 = np.zeros((2,2)) + #Pinf = np.array( ( (t0, 1.0), (1.0, 1.0/t0) ) ) * variance + dF = np.zeros((2,2,1)) + dQc = np.ones( (1,1,1) ) + + dPinf = np.zeros((2,2,1)) + dPinf[:,:,0] = np.array( ( (0, -0.5), (-0.5, 0) ) ) + #dP0 = dPinf.copy() + dP0 = np.zeros((2,2,1)) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) diff --git a/GPy/kern/src/sde_linear.py b/GPy/kern/src/sde_linear.py new file mode 100644 index 00000000..943e3bd7 --- /dev/null +++ b/GPy/kern/src/sde_linear.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance Linear covariance function with the +Stochastic Differential Equation (SDE) functionality. +""" +from .linear import Linear + +import numpy as np + +class sde_Linear(Linear): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Linear kernel: + + .. math:: + + k(x,y) = \sum_{i=1}^{input dim} \sigma^2_i x_iy_i + + """ + def __init__(self, input_dim, X, variances=None, ARD=False, active_dims=None, name='linear'): + """ + Modify the init method, because one extra parameter is required. X - points + on the X axis. + """ + + super(sde_Linear, self).__init__(input_dim, variances, ARD, active_dims, name) + + self.t0 = np.min(X) + + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variances.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variances.values) # this is initial variancve in Bayesian linear regression + t0 = float(self.t0) + + F = np.array( ((0,1.0),(0,0) )) + L = np.array( ((0,),(1.0,)) ) + Qc = np.zeros((1,1)) + H = np.array( ((1.0,0),) ) + + Pinf = np.zeros((2,2)) + P0 = np.array( ( (t0**2, t0), (t0, 1) ) ) * variance + dF = np.zeros((2,2,1)) + dQc = np.zeros( (1,1,1) ) + + dPinf = np.zeros((2,2,1)) + dP0 = np.zeros((2,2,1)) + dP0[:,:,0] = P0 / variance + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) diff --git a/GPy/kern/src/sde_matern.py b/GPy/kern/src/sde_matern.py new file mode 100644 index 00000000..fe302753 --- /dev/null +++ b/GPy/kern/src/sde_matern.py @@ -0,0 +1,137 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance Matern covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .stationary import Matern32 +from .stationary import Matern52 +import numpy as np + +class sde_Matern32(Matern32): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Matern 3/2 kernel: + + .. math:: + + k(r) = \sigma^2 (1 + \sqrt{3} r) \exp(- \sqrt{3} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + lengthscale = float(self.lengthscale.values) + + foo = np.sqrt(3.)/lengthscale + F = np.array(((0, 1.0), (-foo**2, -2*foo))) + L = np.array(( (0,), (1.0,) )) + Qc = np.array(((12.*np.sqrt(3) / lengthscale**3 * variance,),)) + H = np.array(((1.0, 0),)) + Pinf = np.array(((variance, 0.0), (0.0, 3.*variance/(lengthscale**2)))) + P0 = Pinf.copy() + + # Allocate space for the derivatives + dF = np.empty([F.shape[0],F.shape[1],2]) + dQc = np.empty([Qc.shape[0],Qc.shape[1],2]) + dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2]) + # The partial derivatives + dFvariance = np.zeros((2,2)) + dFlengthscale = np.array(((0,0), (6./lengthscale**3,2*np.sqrt(3)/lengthscale**2))) + dQcvariance = np.array((12.*np.sqrt(3)/lengthscale**3)) + dQclengthscale = np.array((-3*12*np.sqrt(3)/lengthscale**4*variance)) + dPinfvariance = np.array(((1,0),(0,3./lengthscale**2))) + dPinflengthscale = np.array(((0,0), (0,-6*variance/lengthscale**3))) + # Combine the derivatives + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinfvariance + dPinf[:,:,1] = dPinflengthscale + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_Matern52(Matern52): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Matern 5/2 kernel: + + .. math:: + + k(r) = \sigma^2 (1 + \sqrt{5} r + \frac{5}{3}r^2) \exp(- \sqrt{5} r) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + lengthscale = float(self.lengthscale.values) + + lamda = np.sqrt(5.0)/lengthscale + kappa = 5.0/3.0*variance/lengthscale**2 + + F = np.array(((0, 1,0), (0, 0, 1), (-lamda**3, -3.0*lamda**2, -3*lamda))) + L = np.array(((0,),(0,),(1,))) + Qc = np.array((((variance*400.0*np.sqrt(5.0)/3.0/lengthscale**5),),)) + H = np.array(((1,0,0),)) + + Pinf = np.array(((variance,0,-kappa), (0, kappa, 0), (-kappa, 0, 25.0*variance/lengthscale**4))) + P0 = Pinf.copy() + # Allocate space for the derivatives + dF = np.empty((3,3,2)) + dQc = np.empty((1,1,2)) + dPinf = np.empty((3,3,2)) + + # The partial derivatives + dFvariance = np.zeros((3,3)) + dFlengthscale = np.array(((0,0,0),(0,0,0),(15.0*np.sqrt(5.0)/lengthscale**4, + 30.0/lengthscale**3, 3*np.sqrt(5.0)/lengthscale**2))) + dQcvariance = np.array((((400*np.sqrt(5)/3/lengthscale**5,),))) + dQclengthscale = np.array((((-variance*2000*np.sqrt(5)/3/lengthscale**6,),))) + + dPinf_variance = Pinf/variance + kappa2 = -2.0*kappa/lengthscale + dPinf_lengthscale = np.array(((0,0,-kappa2),(0,kappa2,0),(-kappa2, + 0,-100*variance/lengthscale**5))) + # Combine the derivatives + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinf_variance + dPinf[:,:,1] = dPinf_lengthscale + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) \ No newline at end of file diff --git a/GPy/kern/src/sde_standard_periodic.py b/GPy/kern/src/sde_standard_periodic.py new file mode 100644 index 00000000..3729bf57 --- /dev/null +++ b/GPy/kern/src/sde_standard_periodic.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance Matern covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .standard_periodic import StdPeriodic + +import numpy as np +import scipy as sp + +from scipy import special as special + +class sde_StdPeriodic(StdPeriodic): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Standard Periodic kernel: + + .. math:: + + k(x,y) = \theta_1 \exp \left[ - \frac{1}{2} {}\sum_{i=1}^{input\_dim} + \left( \frac{\sin(\frac{\pi}{\lambda_i} (x_i - y_i) )}{l_i} \right)^2 \right] } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.period.gradient = gradients[1] + self.lengthscale.gradient = gradients[2] + + def sde(self): + """ + Return the state space representation of the covariance. + + + ! Note: one must constrain lengthscale not to drop below 0.25. + After this bessel functions of the first kind grows to very high. + + ! Note: one must keep wevelength also not very low. Because then + the gradients wrt wavelength become ustable. + However this might depend on the data. For test example with + 300 data points the low limit is 0.15. + """ + + # Params to use: (in that order) + #self.variance + #self.period + #self.lengthscale + N = 7 # approximation order + + + w0 = 2*np.pi/self.period # frequency + lengthscale = 2*self.lengthscale + + [q2,dq2l] = seriescoeff(N,lengthscale,self.variance) + # lengthscale is multiplied by 2 because of slightly different + # formula for periodic covariance function. + # For the same reason: + + dq2l = 2*dq2l + + if np.any( np.isfinite(q2) == False): + raise ValueError("SDE periodic covariance error 1") + + if np.any( np.isfinite(dq2l) == False): + raise ValueError("SDE periodic covariance error 2") + + F = np.kron(np.diag(range(0,N+1)),np.array( ((0, -w0), (w0, 0)) ) ) + L = np.eye(2*(N+1)) + Qc = np.zeros((2*(N+1), 2*(N+1))) + P_inf = np.kron(np.diag(q2),np.eye(2)) + H = np.kron(np.ones((1,N+1)),np.array((1,0)) ) + P0 = P_inf.copy() + + # Derivatives + dF = np.empty((F.shape[0], F.shape[1], 3)) + dQc = np.empty((Qc.shape[0], Qc.shape[1], 3)) + dP_inf = np.empty((P_inf.shape[0], P_inf.shape[1], 3)) + + # Derivatives wrt self.variance + dF[:,:,0] = np.zeros(F.shape) + dQc[:,:,0] = np.zeros(Qc.shape) + dP_inf[:,:,0] = P_inf / self.variance + + # Derivatives self.period + dF[:,:,1] = np.kron(np.diag(range(0,N+1)),np.array( ((0, w0), (-w0, 0)) ) / self.period ); + dQc[:,:,1] = np.zeros(Qc.shape) + dP_inf[:,:,1] = np.zeros(P_inf.shape) + + # Derivatives self.lengthscales + dF[:,:,2] = np.zeros(F.shape) + dQc[:,:,2] = np.zeros(Qc.shape) + dP_inf[:,:,2] = np.kron(np.diag(dq2l),np.eye(2)) + dP0 = dP_inf.copy() + + return (F, L, Qc, H, P_inf, P0, dF, dQc, dP_inf, dP0) + + + + +def seriescoeff(m=6,lengthScale=1.0,magnSigma2=1.0, true_covariance=False): + """ + Calculate the coefficients q_j^2 for the covariance function + approximation: + + k(\tau) = \sum_{j=0}^{+\infty} q_j^2 \cos(j\omega_0 \tau) + + Reference is: + + [1] Arno Solin and Simo Särkkä (2014). Explicit link between periodic + covariance functions and state space models. In Proceedings of the + Seventeenth International Conference on Artifcial Intelligence and + Statistics (AISTATS 2014). JMLR: W&CP, volume 33. + + Note! Only the infinite approximation (through Bessel function) + is currently implemented. + + Input: + ---------------- + + m: int + Degree of approximation. Default 6. + lengthScale: float + Length scale parameter in the kerenl + magnSigma2:float + Multiplier in front of the kernel. + + + Output: + ----------------- + + coeffs: array(m+1) + Covariance series coefficients + + coeffs_dl: array(m+1) + Derivatives of the coefficients with respect to lengthscale. + + """ + + if true_covariance: + + bb = lambda j,m: (1.0 + np.array((j != 0), dtype=np.float64) ) / (2**(j)) *\ + sp.special.binom(j, sp.floor( (j-m)/2.0 * np.array(m<=j, dtype=np.float64) ))*\ + np.array(m<=j, dtype=np.float64) *np.array(sp.mod(j-m,2)==0, dtype=np.float64) + + M,J = np.meshgrid(range(0,m+1),range(0,m+1)) + + coeffs = bb(J,M) / sp.misc.factorial(J) * sp.exp( -lengthScale**(-2) ) *\ + (lengthScale**(-2))**J *magnSigma2 + + coeffs_dl = np.sum( coeffs*lengthScale**(-3)*(2.0-2.0*J*lengthScale**2),0) + + coeffs = np.sum(coeffs,0) + + else: + coeffs = 2*magnSigma2*sp.exp( -lengthScale**(-2) ) * special.iv(range(0,m+1),1.0/lengthScale**(2)) + if np.any( np.isfinite(coeffs) == False): + raise ValueError("sde_standard_periodic: Coefficients are not finite!") + #import pdb; pdb.set_trace() + coeffs[0] = 0.5*coeffs[0] + + # Derivatives wrt (lengthScale) + coeffs_dl = np.zeros(m+1) + coeffs_dl[1:] = magnSigma2*lengthScale**(-3) * sp.exp(-lengthScale**(-2))*\ + (-4*special.iv(range(0,m),lengthScale**(-2)) + 4*(1+np.arange(1,m+1)*lengthScale**(2))*special.iv(range(1,m+1),lengthScale**(-2)) ) + + # The first element + coeffs_dl[0] = magnSigma2*lengthScale**(-3) * np.exp(-lengthScale**(-2))*\ + (2*special.iv(0,lengthScale**(-2)) - 2*special.iv(1,lengthScale**(-2)) ) + + + return coeffs, coeffs_dl diff --git a/GPy/kern/src/sde_static.py b/GPy/kern/src/sde_static.py new file mode 100644 index 00000000..6a30c693 --- /dev/null +++ b/GPy/kern/src/sde_static.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance Static covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .static import White +from .static import Bias + +import numpy as np + +class sde_White(White): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + White kernel: + + .. math:: + + k(x,y) = \alpha*\delta(x-y) + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + variance = float(self.variance.values) + + F = np.array( ((-np.inf,),) ) + L = np.array( ((1.0,),) ) + Qc = np.array( ((variance,),) ) + H = np.array( ((1.0,),) ) + + Pinf = np.array( ((variance,),) ) + P0 = Pinf.copy() + + dF = np.zeros((1,1,1)) + dQc = np.zeros((1,1,1)) + dQc[:,:,0] = np.array( ((1.0,),) ) + + dPinf = np.zeros((1,1,1)) + dPinf[:,:,0] = np.array( ((1.0,),) ) + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + + +class sde_Bias(Bias): + """ + + Class provide extra functionality to transfer this covariance function into + SDE forrm. + + Bias kernel: + + .. math:: + + k(x,y) = \alpha + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + variance = float(self.variance.values) + + F = np.array( ((0.0,),)) + L = np.array( ((1.0,),)) + Qc = np.zeros((1,1)) + H = np.array( ((1.0,),)) + + Pinf = np.zeros((1,1)) + P0 = np.array( ((variance,),) ) + + dF = np.zeros((1,1,1)) + dQc = np.zeros((1,1,1)) + + dPinf = np.zeros((1,1,1)) + dP0 = np.zeros((1,1,1)) + dP0[:,:,0] = np.array( ((1.0,),) ) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) \ No newline at end of file diff --git a/GPy/kern/src/sde_stationary.py b/GPy/kern/src/sde_stationary.py new file mode 100644 index 00000000..3ac5f402 --- /dev/null +++ b/GPy/kern/src/sde_stationary.py @@ -0,0 +1,192 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy, Arno Solin +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Classes in this module enhance several stationary covariance functions with the +Stochastic Differential Equation (SDE) functionality. +""" +from .rbf import RBF +from .stationary import Exponential +from .stationary import RatQuad + +import numpy as np +import scipy as sp + +class sde_RBF(RBF): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Radial Basis Function kernel: + + .. math:: + + k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r^2 \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + N = 10# approximation order ( number of terms in exponent series expansion) + roots_rounding_decimals = 6 + + fn = np.math.factorial(N) + + kappa = 1.0/2.0/self.lengthscale**2 + + Qc = np.array((self.variance*np.sqrt(np.pi/kappa)*fn*(4*kappa)**N,),) + + pp = np.zeros((2*N+1,)) # array of polynomial coefficients from higher power to lower + + for n in range(0, N+1): # (2N+1) - number of polynomial coefficients + pp[2*(N-n)] = fn*(4.0*kappa)**(N-n)/np.math.factorial(n)*(-1)**n + + pp = sp.poly1d(pp) + roots = sp.roots(pp) + + neg_real_part_roots = roots[np.round(np.real(roots) ,roots_rounding_decimals) < 0] + aa = sp.poly1d(neg_real_part_roots, r=True).coeffs + + F = np.diag(np.ones((N-1,)),1) + F[-1,:] = -aa[-1:0:-1] + + L= np.zeros((N,1)) + L[N-1,0] = 1 + + H = np.zeros((1,N)) + H[0,0] = 1 + + # Infinite covariance: + Pinf = sp.linalg.solve_lyapunov(F, -np.dot(L,np.dot( Qc[0,0],L.T))) + Pinf = 0.5*(Pinf + Pinf.T) + # Allocating space for derivatives + dF = np.empty([F.shape[0],F.shape[1],2]) + dQc = np.empty([Qc.shape[0],Qc.shape[1],2]) + dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2]) + + # Derivatives: + dFvariance = np.zeros(F.shape) + dFlengthscale = np.zeros(F.shape) + dFlengthscale[-1,:] = -aa[-1:0:-1]/self.lengthscale * np.arange(-N,0,1) + + dQcvariance = Qc/self.variance + dQclengthscale = np.array(((self.variance*np.sqrt(2*np.pi)*fn*2**N*self.lengthscale**(-2*N)*(1-2*N,),))) + + dPinf_variance = Pinf/self.variance + + lp = Pinf.shape[0] + coeff = np.arange(1,lp+1).reshape(lp,1) + np.arange(1,lp+1).reshape(1,lp) - 2 + coeff[np.mod(coeff,2) != 0] = 0 + dPinf_lengthscale = -1/self.lengthscale*Pinf*coeff + + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinf_variance + dPinf[:,:,1] = dPinf_lengthscale + + P0 = Pinf.copy() + dP0 = dPinf.copy() + + # Benefits of this are not very sound. Helps only in one case: + # SVD Kalman + RBF kernel + import GPy.models.state_space_main as ssm + (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf,dP0, T) = ssm.balance_ss_model(F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0 ) + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_Exponential(Exponential): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Exponential kernel: + + .. math:: + + k(r) = \sigma^2 \exp \\bigg(- \\frac{1}{2} r \\bigg) \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + + def sde_update_gradient_full(self, gradients): + """ + Update gradient in the order in which parameters are represented in the + kernel + """ + + self.variance.gradient = gradients[0] + self.lengthscale.gradient = gradients[1] + + def sde(self): + """ + Return the state space representation of the covariance. + """ + variance = float(self.variance.values) + lengthscale = float(self.lengthscale) + + F = np.array(((-1.0/lengthscale,),)) + L = np.array(((1.0,),)) + Qc = np.array( ((2.0*variance/lengthscale,),) ) + H = np.array(((1.0,),)) + Pinf = np.array(((variance,),)) + P0 = Pinf.copy() + + dF = np.zeros((1,1,2)); + dQc = np.zeros((1,1,2)); + dPinf = np.zeros((1,1,2)); + + dF[:,:,0] = 0.0 + dF[:,:,1] = 1.0/lengthscale**2 + + dQc[:,:,0] = 2.0/lengthscale + dQc[:,:,1] = -2.0*variance/lengthscale**2 + + dPinf[:,:,0] = 1.0 + dPinf[:,:,1] = 0.0 + + dP0 = dPinf.copy() + + return (F, L, Qc, H, Pinf, P0, dF, dQc, dPinf, dP0) + +class sde_RatQuad(RatQuad): + """ + + Class provide extra functionality to transfer this covariance function into + SDE form. + + Rational Quadratic kernel: + + .. math:: + + k(r) = \sigma^2 \\bigg( 1 + \\frac{r^2}{2} \\bigg)^{- \alpha} \\ \\ \\ \\ \text{ where } r = \sqrt{\sum_{i=1}^{input dim} \frac{(x_i-y_i)^2}{\ell_i^2} } + + """ + + def sde(self): + """ + Return the state space representation of the covariance. + """ + + assert False, 'Not Implemented' + + # Params to use: + + # self.lengthscale + # self.variance + #self.power + + #return (F, L, Qc, H, Pinf, dF, dQc, dPinf) diff --git a/GPy/kern/src/static.py b/GPy/kern/src/static.py index 18f7605f..0ffd8112 100644 --- a/GPy/kern/src/static.py +++ b/GPy/kern/src/static.py @@ -6,6 +6,7 @@ from .kern import Kern import numpy as np from ...core.parameterization import Param from paramz.transformations import Logexp +from paramz.caching import Cache_this class Static(Kern): def __init__(self, input_dim, variance, active_dims, name): @@ -24,12 +25,13 @@ class Static(Kern): def gradients_X_diag(self, dL_dKdiag, X): return np.zeros(X.shape) - def gradients_XX(self, dL_dK, X, X2): + def gradients_XX(self, dL_dK, X, X2=None): if X2 is None: X2 = X - return np.zeros((X.shape[0], X2.shape[0], X.shape[1]), dtype=np.float64) - def gradients_XX_diag(self, dL_dKdiag, X): - return np.zeros(X.shape) + return np.zeros((X.shape[0], X2.shape[0], X.shape[1], X.shape[1]), dtype=np.float64) + + def gradients_XX_diag(self, dL_dKdiag, X, cov=False): + return np.zeros((X.shape[0], X.shape[1], X.shape[1]), dtype=np.float64) def gradients_Z_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior): return np.zeros(Z.shape) @@ -85,10 +87,10 @@ class WhiteHeteroscedastic(Static): def __init__(self, input_dim, num_data, variance=1., active_dims=None, name='white_hetero'): """ A heteroscedastic White kernel (nugget/noise). - It defines one variance (nugget) per input sample. - + It defines one variance (nugget) per input sample. + Prediction excludes any noise learnt by this Kernel, so be careful using this kernel. - + You can plot the errors learnt by this kernel by something similar as: plt.errorbar(m.X, m.Y, yerr=2*np.sqrt(m.kern.white.variance)) """ @@ -98,7 +100,7 @@ class WhiteHeteroscedastic(Static): def Kdiag(self, X): if X.shape[0] == self.variance.shape[0]: - # If the input has the same number of samples as + # If the input has the same number of samples as # the number of variances, we return the variances return self.variance return 0. @@ -133,9 +135,7 @@ class Bias(Static): def K(self, X, X2=None): shape = (X.shape[0], X.shape[0] if X2 is None else X2.shape[0]) - ret = np.empty(shape, dtype=np.float64) - ret[:] = self.variance - return ret + return np.full(shape, self.variance, dtype=np.float64) def update_gradients_full(self, dL_dK, X, X2=None): self.variance.gradient = dL_dK.sum() @@ -144,9 +144,7 @@ class Bias(Static): self.variance.gradient = dL_dKdiag.sum() def psi2(self, Z, variational_posterior): - ret = np.empty((Z.shape[0], Z.shape[0]), dtype=np.float64) - ret[:] = self.variance*self.variance*variational_posterior.shape[0] - return ret + return np.full((Z.shape[0], Z.shape[0]), self.variance*self.variance*variational_posterior.shape[0], dtype=np.float64) def psi2n(self, Z, variational_posterior): ret = np.empty((variational_posterior.mean.shape[0], Z.shape[0], Z.shape[0]), dtype=np.float64) @@ -172,16 +170,22 @@ class Fixed(Static): super(Fixed, self).__init__(input_dim, variance, active_dims, name) self.fixed_K = covariance_matrix def K(self, X, X2): - return self.variance * self.fixed_K + if X2 is None: + return self.variance * self.fixed_K + else: + return np.zeros((X.shape[0], X2.shape[0])) def Kdiag(self, X): return self.variance * self.fixed_K.diagonal() def update_gradients_full(self, dL_dK, X, X2=None): - self.variance.gradient = np.einsum('ij,ij', dL_dK, self.fixed_K) + if X2 is None: + self.variance.gradient = np.einsum('ij,ij', dL_dK, self.fixed_K) + else: + self.variance.gradient = 0 def update_gradients_diag(self, dL_dKdiag, X): - self.variance.gradient = np.einsum('i,i', dL_dKdiag, self.fixed_K) + self.variance.gradient = np.einsum('i,i', dL_dKdiag, np.diagonal(self.fixed_K)) def psi2(self, Z, variational_posterior): return np.zeros((Z.shape[0], Z.shape[0]), dtype=np.float64) @@ -192,3 +196,58 @@ class Fixed(Static): def update_gradients_expectations(self, dL_dpsi0, dL_dpsi1, dL_dpsi2, Z, variational_posterior): self.variance.gradient = dL_dpsi0.sum() +class Precomputed(Fixed): + def __init__(self, input_dim, covariance_matrix, variance=1., active_dims=None, name='precomputed'): + """ + Class for precomputed kernels, indexed by columns in X + + Usage example: + + import numpy as np + from GPy.models import GPClassification + from GPy.kern import Precomputed + from sklearn.cross_validation import LeaveOneOut + + n = 10 + d = 100 + X = np.arange(n).reshape((n,1)) # column vector of indices + y = 2*np.random.binomial(1,0.5,(n,1))-1 + X0 = np.random.randn(n,d) + k = np.dot(X0,X0.T) + kern = Precomputed(1,k) # k is a n x n covariance matrix + + cv = LeaveOneOut(n) + ypred = y.copy() + for train, test in cv: + m = GPClassification(X[train], y[train], kernel=kern) + m.optimize() + ypred[test] = 2*(m.predict(X[test])[0]>0.5)-1 + + :param input_dim: the number of input dimensions + :type input_dim: int + :param variance: the variance of the kernel + :type variance: float + """ + assert input_dim==1, "Precomputed only implemented in one dimension. Use multiple Precomputed kernels to have more dimensions by making use of active_dims" + super(Precomputed, self).__init__(input_dim, covariance_matrix, variance, active_dims, name) + + @Cache_this(limit=2) + def _index(self, X, X2): + if X2 is None: + i1 = i2 = X.astype('int').flat + else: + i1, i2 = X.astype('int').flat, X2.astype('int').flat + return self.fixed_K[i1,:][:,i2] + + def K(self, X, X2=None): + return self.variance * self._index(X, X2) + + def Kdiag(self, X): + return self.variance * self._index(X,None).diagonal() + + def update_gradients_full(self, dL_dK, X, X2=None): + self.variance.gradient = np.einsum('ij,ij', dL_dK, self._index(X, X2)) + + def update_gradients_diag(self, dL_dKdiag, X): + self.variance.gradient = np.einsum('i,ii', dL_dKdiag, self._index(X, None)) + diff --git a/GPy/kern/src/stationary.py b/GPy/kern/src/stationary.py index fa7c8bd3..731c791d 100644 --- a/GPy/kern/src/stationary.py +++ b/GPy/kern/src/stationary.py @@ -51,6 +51,10 @@ class Stationary(Kern): The lengthscale(s) and variance parameters are added to the structure automatically. + Thanks to @strongh: + In Stationary, a covariance function is defined in GPy as stationary when it depends only on the l2-norm |x_1 - x_2 |. + However this is the typical definition of isotropy, while stationarity is usually a bit more relaxed. + The more common version of stationarity is that the covariance is a function of x_1 - x_2 (See e.g. R&W first paragraph of section 4.1). """ def __init__(self, input_dim, variance, lengthscale, ARD, active_dims, name, useGPU=False): @@ -85,6 +89,11 @@ class Stationary(Kern): def dK2_drdr(self, r): raise NotImplementedError("implement second derivative of covariance wrt r to use this method") + @Cache_this(limit=3, ignore_args=()) + def dK2_drdr_diag(self): + "Second order derivative of K in r_{i,i}. The diagonal entries are always zero, so we do not give it here." + raise NotImplementedError("implement second derivative of covariance wrt r_diag to use this method") + @Cache_this(limit=3, ignore_args=()) def K(self, X, X2=None): """ @@ -222,54 +231,57 @@ class Stationary(Kern): """ Given the derivative of the objective K(dL_dK), compute the second derivative of K wrt X and X2: + returns the full covariance matrix [QxQ] of the input dimensionfor each pair or vectors, thus + the returned array is of shape [NxNxQxQ]. + ..math: - \frac{\partial^2 K}{\partial X\partial X2} + \frac{\partial^2 K}{\partial X2 ^2} = - \frac{\partial^2 K}{\partial X\partial X2} ..returns: - dL2_dXdX2: NxMxQ, for X [NxQ] and X2[MxQ] (X2 is X if, X2 is None) - Thus, we return the second derivative in X2. + dL2_dXdX2: [NxMxQxQ] in the cov=True case, or [NxMxQ] in the cov=False case, + for X [NxQ] and X2[MxQ] (X2 is X if, X2 is None) + Thus, we return the second derivative in X2. """ - # The off diagonals in Q are always zero, this should also be true for the Linear kernel... # According to multivariable chain rule, we can chain the second derivative through r: # d2K_dXdX2 = dK_dr*d2r_dXdX2 + d2K_drdr * dr_dX * dr_dX2: invdist = self._inv_dist(X, X2) invdist2 = invdist**2 - - dL_dr = self.dK_dr_via_X(X, X2) * dL_dK + dL_dr = self.dK_dr_via_X(X, X2) #* dL_dK # we perform this product later tmp1 = dL_dr * invdist - - dL_drdr = self.dK2_drdr_via_X(X, X2) * dL_dK - tmp2 = dL_drdr * invdist2 - - l2 = np.ones(X.shape[1]) * self.lengthscale**2 + dL_drdr = self.dK2_drdr_via_X(X, X2) #* dL_dK # we perofrm this product later + tmp2 = dL_drdr*invdist2 + l2 = np.ones(X.shape[1])*self.lengthscale**2 #np.multiply(np.ones(X.shape[1]) ,self.lengthscale**2) if X2 is None: X2 = X tmp1 -= np.eye(X.shape[0])*self.variance else: - tmp1[X==X2.T] -= self.variance + tmp1[invdist2==0.] -= self.variance - grad = np.empty((X.shape[0], X2.shape[0], X.shape[1]), dtype=np.float64) - #grad = np.empty(X.shape, dtype=np.float64) - for q in range(self.input_dim): - tmpdist2 = (X[:,[q]]-X2[:,[q]].T) ** 2 - grad[:, :, q] = ((tmp1*invdist2 - tmp2)*tmpdist2/l2[q] - tmp1)/l2[q] - #grad[:, :, q] = ((tmp1*(((tmpdist2)*invdist2/l2[q])-1)) - (tmp2*(tmpdist2))/l2[q])/l2[q] - #np.sum(((tmp1*(((tmpdist2)*invdist2/l2[q])-1)) - (tmp2*(tmpdist2))/l2[q])/l2[q], axis=1, out=grad[:,q]) - #np.sum( - (tmp2*(tmpdist**2)), axis=1, out=grad[:,q]) + #grad = np.empty((X.shape[0], X2.shape[0], X2.shape[1], X.shape[1]), dtype=np.float64) + dist = X[:,None,:] - X2[None,:,:] + dist = (dist[:,:,:,None]*dist[:,:,None,:]) + I = np.ones((X.shape[0], X2.shape[0], X2.shape[1], X.shape[1]))*np.eye((X2.shape[1])) + grad = (((dL_dK*(tmp1*invdist2 - tmp2))[:,:,None,None] * dist)/l2[None,None,:,None] + - (dL_dK*tmp1)[:,:,None,None] * I)/l2[None,None,None,:] return grad - def gradients_XX_diag(self, dL_dK, X): + def gradients_XX_diag(self, dL_dK_diag, X): """ - Given the derivative of the objective K(dL_dK), compute the second derivative of K wrt X and X2: + Given the derivative of the objective dL_dK, compute the second derivative of K wrt X: ..math: - \frac{\partial^2 K}{\partial X\partial X2} + \frac{\partial^2 K}{\partial X\partial X} ..returns: - dL2_dXdX2: NxMxQ, for X [NxQ] and X2[MxQ] + dL2_dXdX: [NxQxQ] """ - return np.ones(X.shape) * self.variance/self.lengthscale**2 + dL_dK_diag = dL_dK_diag.copy().reshape(-1, 1, 1) + assert (dL_dK_diag.size == X.shape[0]) or (dL_dK_diag.size == 1), "dL_dK_diag has to be given as row [N] or column vector [Nx1]" + + l4 = np.ones(X.shape[1])*self.lengthscale**2 + return dL_dK_diag * (np.eye(X.shape[1]) * -self.dK2_drdr_diag()/(l4))[None, :,:]# np.zeros(X.shape+(X.shape[1],)) + #return np.ones(X.shape) * d2L_dK * self.variance/self.lengthscale**2 # np.zeros(X.shape) def _gradients_X_pure(self, dL_dK, X, X2=None): invdist = self._inv_dist(X, X2) @@ -315,11 +327,23 @@ class Exponential(Stationary): super(Exponential, self).__init__(input_dim, variance, lengthscale, ARD, active_dims, name) def K_of_r(self, r): - return self.variance * np.exp(-0.5 * r) + return self.variance * np.exp(-r) def dK_dr(self, r): - return -0.5*self.K_of_r(r) + return -self.K_of_r(r) +# def sde(self): +# """ +# Return the state space representation of the covariance. +# """ +# F = np.array([[-1/self.lengthscale]]) +# L = np.array([[1]]) +# Qc = np.array([[2*self.variance/self.lengthscale]]) +# H = np.array([[1]]) +# Pinf = np.array([[self.variance]]) +# # TODO: return the derivatives as well +# +# return (F, L, Qc, H, Pinf) @@ -388,6 +412,41 @@ class Matern32(Stationary): F1lower = np.array([f(lower) for f in F1])[:, None] return(self.lengthscale ** 3 / (12.*np.sqrt(3) * self.variance) * G + 1. / self.variance * np.dot(Flower, Flower.T) + self.lengthscale ** 2 / (3.*self.variance) * np.dot(F1lower, F1lower.T)) + def sde(self): + """ + Return the state space representation of the covariance. + """ + variance = float(self.variance.values) + lengthscale = float(self.lengthscale.values) + foo = np.sqrt(3.)/lengthscale + F = np.array([[0, 1], [-foo**2, -2*foo]]) + L = np.array([[0], [1]]) + Qc = np.array([[12.*np.sqrt(3) / lengthscale**3 * variance]]) + H = np.array([[1, 0]]) + Pinf = np.array([[variance, 0], + [0, 3.*variance/(lengthscale**2)]]) + # Allocate space for the derivatives + dF = np.empty([F.shape[0],F.shape[1],2]) + dQc = np.empty([Qc.shape[0],Qc.shape[1],2]) + dPinf = np.empty([Pinf.shape[0],Pinf.shape[1],2]) + # The partial derivatives + dFvariance = np.zeros([2,2]) + dFlengthscale = np.array([[0,0], + [6./lengthscale**3,2*np.sqrt(3)/lengthscale**2]]) + dQcvariance = np.array([12.*np.sqrt(3)/lengthscale**3]) + dQclengthscale = np.array([-3*12*np.sqrt(3)/lengthscale**4*variance]) + dPinfvariance = np.array([[1,0],[0,3./lengthscale**2]]) + dPinflengthscale = np.array([[0,0], + [0,-6*variance/lengthscale**3]]) + # Combine the derivatives + dF[:,:,0] = dFvariance + dF[:,:,1] = dFlengthscale + dQc[:,:,0] = dQcvariance + dQc[:,:,1] = dQclengthscale + dPinf[:,:,0] = dPinfvariance + dPinf[:,:,1] = dPinflengthscale + + return (F, L, Qc, H, Pinf, dF, dQc, dPinf) class Matern52(Stationary): """ diff --git a/GPy/kern/src/stationary_cython.c b/GPy/kern/src/stationary_cython.c index 25351fd0..946b3031 100644 --- a/GPy/kern/src/stationary_cython.c +++ b/GPy/kern/src/stationary_cython.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.23 */ +/* Generated by Cython 0.23.3 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -7,7 +7,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else -#define CYTHON_ABI "0_23" +#define CYTHON_ABI "0_23_3" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -571,7 +571,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; #endif -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -580,7 +580,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -589,7 +589,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -598,7 +598,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -607,7 +607,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -616,7 +616,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -625,7 +625,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -634,7 +634,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -643,7 +643,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":739 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -652,7 +652,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -661,7 +661,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -670,7 +670,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -679,7 +679,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -688,7 +688,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -697,7 +697,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -706,7 +706,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -715,7 +715,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":757 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -724,7 +724,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -733,7 +733,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -742,7 +742,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -751,7 +751,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -795,7 +795,7 @@ struct __pyx_MemviewEnum_obj; struct __pyx_memoryview_obj; struct __pyx_memoryviewslice_obj; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -804,7 +804,7 @@ struct __pyx_memoryviewslice_obj; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -813,7 +813,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -822,7 +822,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -1631,10 +1631,10 @@ static char __pyx_k_Index_out_of_bounds_axis_d[] = "Index out of bounds (axis %d static char __pyx_k_Step_may_not_be_zero_axis_d[] = "Step may not be zero (axis %d)"; static char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.array"; static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static char __pyx_k_Users_james_work_GPy_GPy_kern[] = "/Users/james/work/GPy/GPy/kern/_src/stationary_cython.pyx"; static char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static char __pyx_k_strided_and_direct_or_indirect[] = ""; static char __pyx_k_GPy_kern__src_stationary_cython[] = "GPy.kern._src.stationary_cython"; -static char __pyx_k_home_david_gits_GPy_GPy_kern__s[] = "/home/david/gits/GPy/GPy/kern/_src/stationary_cython.pyx"; static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; static char __pyx_k_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced"; static char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; @@ -1677,6 +1677,7 @@ static PyObject *__pyx_n_s_Q; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; +static PyObject *__pyx_kp_s_Users_james_work_GPy_GPy_kern; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_X; static PyObject *__pyx_n_s_X2; @@ -1705,7 +1706,6 @@ static PyObject *__pyx_n_s_grad_2; static PyObject *__pyx_n_s_grad_X; static PyObject *__pyx_n_s_grad_X_cython; static PyObject *__pyx_n_s_gradq; -static PyObject *__pyx_kp_s_home_david_gits_GPy_GPy_kern__s; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; static PyObject *__pyx_n_s_itemsize; @@ -2280,19 +2280,19 @@ static PyObject *__pyx_pf_3GPy_4kern_4_src_17stationary_cython_2grad_X_cython(CY if (__pyx_t_3 > 0) { #ifdef _OPENMP - #pragma omp parallel private(__pyx_t_15, __pyx_t_11, __pyx_t_9, __pyx_t_10, __pyx_t_7, __pyx_t_8, __pyx_t_14, __pyx_t_5, __pyx_t_4, __pyx_t_13, __pyx_t_12, __pyx_t_6) + #pragma omp parallel private(__pyx_t_12, __pyx_t_5, __pyx_t_14, __pyx_t_4, __pyx_t_10, __pyx_t_7, __pyx_t_9, __pyx_t_8, __pyx_t_15, __pyx_t_11, __pyx_t_13, __pyx_t_6) #endif /* _OPENMP */ { #ifdef _OPENMP - #pragma omp for lastprivate(__pyx_v_d) lastprivate(__pyx_v_m) firstprivate(__pyx_v_nd) lastprivate(__pyx_v_nd) lastprivate(__pyx_v_n) + #pragma omp for lastprivate(__pyx_v_n) lastprivate(__pyx_v_m) lastprivate(__pyx_v_d) firstprivate(__pyx_v_nd) lastprivate(__pyx_v_nd) #endif /* _OPENMP */ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_3; __pyx_t_2++){ { __pyx_v_nd = 0 + 1 * __pyx_t_2; /* Initialize private variables to invalid values */ - __pyx_v_d = ((int)0xbad0bad0); - __pyx_v_m = ((int)0xbad0bad0); __pyx_v_n = ((int)0xbad0bad0); + __pyx_v_m = ((int)0xbad0bad0); + __pyx_v_d = ((int)0xbad0bad0); /* "GPy/kern/_src/stationary_cython.pyx":33 * cdef int n,d,nd,m @@ -2949,7 +2949,7 @@ static PyObject *__pyx_pf_3GPy_4kern_4_src_17stationary_cython_6lengthscale_grad return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -2999,7 +2999,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_GIVEREF(__pyx_v_info->obj); } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< @@ -3012,7 +3012,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L0; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -3021,7 +3021,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -3030,7 +3030,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -3039,7 +3039,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -3049,7 +3049,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -3058,7 +3058,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_copy_shape = 1; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -3068,7 +3068,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L4; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -3080,7 +3080,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L4:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3094,7 +3094,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L6_bool_binop_done; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -3105,7 +3105,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L6_bool_binop_done:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3114,7 +3114,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -3127,7 +3127,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3136,7 +3136,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3150,7 +3150,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L9_bool_binop_done; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -3161,7 +3161,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L9_bool_binop_done:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3170,7 +3170,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -3183,7 +3183,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -3192,7 +3192,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -3201,7 +3201,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -3210,7 +3210,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -3220,7 +3220,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -3229,7 +3229,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -3238,7 +3238,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -3249,7 +3249,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -3258,7 +3258,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -3268,7 +3268,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -3278,7 +3278,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L11; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -3288,7 +3288,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P /*else*/ { __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -3299,7 +3299,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L11:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -3308,7 +3308,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -3317,7 +3317,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -3326,7 +3326,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -3335,7 +3335,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< @@ -3347,7 +3347,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -3356,7 +3356,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -3374,7 +3374,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_L15_bool_binop_done:; if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":250 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -3387,7 +3387,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = Py_None; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -3397,7 +3397,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L14; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< @@ -3413,7 +3413,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L14:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -3423,7 +3423,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -3433,7 +3433,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -3453,7 +3453,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L20_next_or:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -3470,7 +3470,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -3479,7 +3479,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -3492,7 +3492,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -3501,7 +3501,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -3513,7 +3513,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_b; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -3524,7 +3524,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_B; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -3535,7 +3535,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_h; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -3546,7 +3546,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_H; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -3557,7 +3557,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_i; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -3568,7 +3568,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_I; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -3579,7 +3579,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_l; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -3590,7 +3590,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_L; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -3601,7 +3601,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_q; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -3612,7 +3612,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Q; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -3623,7 +3623,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_f; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -3634,7 +3634,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_d; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -3645,7 +3645,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_g; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -3656,7 +3656,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zf; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -3667,7 +3667,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zd; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -3678,7 +3678,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zg; break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -3690,7 +3690,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; default: - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -3716,7 +3716,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -3725,7 +3725,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -3735,7 +3735,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_r = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -3744,7 +3744,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -3752,9 +3752,9 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P * offset = 0 */ /*else*/ { - __pyx_v_info->format = ((char *)malloc(255)); + __pyx_v_info->format = ((char *)malloc(0xFF)); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -3763,7 +3763,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -3772,17 +3772,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ - __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 0xFF), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -3792,7 +3792,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -3824,7 +3824,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -3848,7 +3848,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -3858,7 +3858,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -3867,7 +3867,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ free(__pyx_v_info->format); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -3876,7 +3876,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -3886,7 +3886,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -3895,7 +3895,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ free(__pyx_v_info->strides); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -3904,7 +3904,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -3916,7 +3916,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __Pyx_RefNannyFinishContext(); } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3933,7 +3933,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -3947,7 +3947,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":770 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -3966,7 +3966,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -3983,7 +3983,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -3997,7 +3997,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":773 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -4016,7 +4016,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -4033,7 +4033,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -4047,7 +4047,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":776 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -4066,7 +4066,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -4083,7 +4083,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -4097,7 +4097,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":779 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -4116,7 +4116,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -4133,7 +4133,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -4147,7 +4147,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":782 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -4166,7 +4166,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -4198,7 +4198,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * * cdef dtype child * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -4207,7 +4207,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef dtype child * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -4216,7 +4216,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -4239,7 +4239,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< @@ -4256,7 +4256,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -4295,7 +4295,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -4312,7 +4312,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -4325,7 +4325,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< @@ -4334,7 +4334,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -4354,7 +4354,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L8_next_or:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -4371,7 +4371,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -4380,7 +4380,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (__pyx_t_6) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -4393,7 +4393,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -4402,7 +4402,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -4418,16 +4418,16 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< * f += 1 * offset[0] += 1 */ - (__pyx_v_f[0]) = 120; + (__pyx_v_f[0]) = 0x78; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -4436,7 +4436,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -4447,7 +4447,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -4457,7 +4457,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -4467,7 +4467,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< @@ -4479,7 +4479,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -4489,7 +4489,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -4502,7 +4502,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -4511,7 +4511,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< @@ -4529,7 +4529,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< @@ -4547,7 +4547,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< @@ -4561,11 +4561,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 104; + (__pyx_v_f[0]) = 0x68; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< @@ -4583,7 +4583,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< @@ -4597,11 +4597,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 105; + (__pyx_v_f[0]) = 0x69; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< @@ -4619,7 +4619,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< @@ -4633,11 +4633,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 108; + (__pyx_v_f[0]) = 0x6C; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< @@ -4655,7 +4655,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< @@ -4669,11 +4669,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 113; + (__pyx_v_f[0]) = 0x71; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< @@ -4691,7 +4691,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< @@ -4705,11 +4705,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 102; + (__pyx_v_f[0]) = 0x66; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< @@ -4723,11 +4723,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 100; + (__pyx_v_f[0]) = 0x64; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< @@ -4741,11 +4741,11 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { - (__pyx_v_f[0]) = 103; + (__pyx_v_f[0]) = 0x67; goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< @@ -4760,12 +4760,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 102; + (__pyx_v_f[1]) = 0x66; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< @@ -4780,12 +4780,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 100; + (__pyx_v_f[1]) = 0x64; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< @@ -4800,12 +4800,12 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; - (__pyx_v_f[1]) = 103; + (__pyx_v_f[1]) = 0x67; __pyx_v_f = (__pyx_v_f + 1); goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< @@ -4823,7 +4823,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< @@ -4847,7 +4847,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L15:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -4856,7 +4856,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -4866,7 +4866,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L13; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< @@ -4879,7 +4879,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __pyx_L13:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -4889,7 +4889,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -4899,7 +4899,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":785 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -4924,7 +4924,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -4939,7 +4939,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -4950,7 +4950,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< @@ -4959,7 +4959,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ __pyx_v_baseptr = NULL; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -4969,7 +4969,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a goto __pyx_L3; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< @@ -4979,7 +4979,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a /*else*/ { Py_INCREF(__pyx_v_base); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< @@ -4990,7 +4990,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } __pyx_L3:; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< @@ -4999,7 +4999,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_XDECREF(__pyx_v_arr->base); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< @@ -5008,7 +5008,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ __pyx_v_arr->base = __pyx_v_baseptr; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -5020,7 +5020,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 +/* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -5034,7 +5034,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -5044,7 +5044,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< @@ -5056,7 +5056,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_r = Py_None; goto __pyx_L0; - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -5065,7 +5065,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py */ } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< @@ -5077,7 +5077,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py goto __pyx_L0; } - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -8201,7 +8201,7 @@ static PyObject *__pyx_memoryview_setitem_slice_assignment(struct __pyx_memoryvi */ static PyObject *__pyx_memoryview_setitem_slice_assign_scalar(struct __pyx_memoryview_obj *__pyx_v_self, struct __pyx_memoryview_obj *__pyx_v_dst, PyObject *__pyx_v_value) { - int __pyx_v_array[128]; + int __pyx_v_array[0x80]; void *__pyx_v_tmp; void *__pyx_v_item; __Pyx_memviewslice *__pyx_v_dst_slice; @@ -11677,7 +11677,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ * new_ndim += 1 * else: */ - (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1; + (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1L; /* "View.MemoryView":716 * p_dst.strides[new_ndim] = 0 @@ -12410,7 +12410,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, * else: * stop = shape */ - __pyx_v_stop = -1; + __pyx_v_stop = -1L; /* "View.MemoryView":823 * stop = shape @@ -12766,7 +12766,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P * cdef Py_ssize_t itemsize = view.itemsize * cdef char *resultp */ - __pyx_v_suboffset = -1; + __pyx_v_suboffset = -1L; /* "View.MemoryView":871 * Py_ssize_t dim) except NULL: @@ -14056,7 +14056,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem if ((__pyx_v_suboffsets != 0)) { __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]); } else { - __pyx_t_4 = -1; + __pyx_t_4 = -1L; } (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4; } @@ -14367,7 +14367,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ * if mslice.shape[i] > 1: * c_stride = mslice.strides[i] */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1; /* "View.MemoryView":1081 @@ -14920,7 +14920,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ * stride = stride * shape[idx] */ /*else*/ { - for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) { + for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1L; __pyx_t_2-=1) { __pyx_v_idx = __pyx_t_2; /* "View.MemoryView":1159 @@ -15092,7 +15092,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, * * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, */ - (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1; + (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1L; } /* "View.MemoryView":1190 @@ -16137,7 +16137,7 @@ static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslic * mslice.shape[i + offset] = mslice.shape[i] * mslice.strides[i + offset] = mslice.strides[i] */ - for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { + for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1L; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1; /* "View.MemoryView":1304 @@ -16204,7 +16204,7 @@ static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslic * * */ - (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1; + (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1L; } /* "View.MemoryView":1297 @@ -17321,6 +17321,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__pyx_kp_s_Users_james_work_GPy_GPy_kern, __pyx_k_Users_james_work_GPy_GPy_kern, sizeof(__pyx_k_Users_james_work_GPy_GPy_kern), 0, 0, 1, 0}, {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1}, {&__pyx_n_s_X2, __pyx_k_X2, sizeof(__pyx_k_X2), 0, 0, 1, 1}, @@ -17349,7 +17350,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_grad_X, __pyx_k_grad_X, sizeof(__pyx_k_grad_X), 0, 0, 1, 1}, {&__pyx_n_s_grad_X_cython, __pyx_k_grad_X_cython, sizeof(__pyx_k_grad_X_cython), 0, 0, 1, 1}, {&__pyx_n_s_gradq, __pyx_k_gradq, sizeof(__pyx_k_gradq), 0, 0, 1, 1}, - {&__pyx_kp_s_home_david_gits_GPy_GPy_kern__s, __pyx_k_home_david_gits_GPy_GPy_kern__s, sizeof(__pyx_k_home_david_gits_GPy_GPy_kern__s), 0, 0, 1, 0}, {&__pyx_n_s_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, {&__pyx_n_s_itemsize, __pyx_k_itemsize, sizeof(__pyx_k_itemsize), 0, 0, 1, 1}, @@ -17412,7 +17412,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< @@ -17423,7 +17423,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< @@ -17434,7 +17434,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -17445,7 +17445,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< @@ -17456,7 +17456,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< @@ -17467,7 +17467,7 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); - /* "../../../../../.virtualenvs/py27/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< @@ -17634,7 +17634,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple__20 = PyTuple_Pack(11, __pyx_n_s_N, __pyx_n_s_D, __pyx_n_s_M, __pyx_n_s_X, __pyx_n_s_X2, __pyx_n_s_tmp, __pyx_n_s_grad, __pyx_n_s_X_2, __pyx_n_s_X2_2, __pyx_n_s_tmp_2, __pyx_n_s_grad_2); if (unlikely(!__pyx_tuple__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__20); __Pyx_GIVEREF(__pyx_tuple__20); - __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_david_gits_GPy_GPy_kern__s, __pyx_n_s_grad_X, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_kern, __pyx_n_s_grad_X, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/kern/_src/stationary_cython.pyx":30 * @@ -17646,7 +17646,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple__22 = PyTuple_Pack(11, __pyx_n_s_N, __pyx_n_s_D, __pyx_n_s_M, __pyx_n_s_X_2, __pyx_n_s_X2_2, __pyx_n_s_tmp_2, __pyx_n_s_grad_2, __pyx_n_s_n, __pyx_n_s_d, __pyx_n_s_nd, __pyx_n_s_m); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__22); __Pyx_GIVEREF(__pyx_tuple__22); - __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_david_gits_GPy_GPy_kern__s, __pyx_n_s_grad_X_cython, 30, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_kern, __pyx_n_s_grad_X_cython, 30, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/kern/_src/stationary_cython.pyx":39 * grad[n,d] += tmp[n, m] * (X[n, d] - X2[m, d]) @@ -17658,7 +17658,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple__24 = PyTuple_Pack(11, __pyx_n_s_N, __pyx_n_s_M, __pyx_n_s_Q, __pyx_n_s_tmp, __pyx_n_s_X, __pyx_n_s_X2, __pyx_n_s_grad, __pyx_n_s_tmp_2, __pyx_n_s_X_2, __pyx_n_s_X2_2, __pyx_n_s_grad_2); if (unlikely(!__pyx_tuple__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__24); __Pyx_GIVEREF(__pyx_tuple__24); - __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_david_gits_GPy_GPy_kern__s, __pyx_n_s_lengthscale_grads_in_c, 39, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(7, 0, 11, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_kern, __pyx_n_s_lengthscale_grads_in_c, 39, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/kern/_src/stationary_cython.pyx":51 * _lengthscale_grads(N, M, Q, tmp, X, X2, grad) # return nothing, work in place. @@ -17670,7 +17670,7 @@ static int __Pyx_InitCachedConstants(void) { __pyx_tuple__26 = PyTuple_Pack(12, __pyx_n_s_N, __pyx_n_s_M, __pyx_n_s_Q, __pyx_n_s_tmp_2, __pyx_n_s_X_2, __pyx_n_s_X2_2, __pyx_n_s_grad_2, __pyx_n_s_q, __pyx_n_s_n, __pyx_n_s_m, __pyx_n_s_gradq, __pyx_n_s_dist); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__26); __Pyx_GIVEREF(__pyx_tuple__26); - __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_david_gits_GPy_GPy_kern__s, __pyx_n_s_lengthscale_grads, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(7, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_kern, __pyx_n_s_lengthscale_grads, 51, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "View.MemoryView":278 * return self.name @@ -19357,7 +19357,13 @@ static CYTHON_INLINE PyObject* __Pyx_decode_c_string( PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) { Py_ssize_t length; if (unlikely((start < 0) | (stop < 0))) { - length = strlen(cstring); + size_t slen = strlen(cstring); + if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) { + PyErr_SetString(PyExc_OverflowError, + "c-string too long to convert to Python"); + return NULL; + } + length = (Py_ssize_t) slen; if (start < 0) { start += length; if (start < 0) @@ -19670,50 +19676,50 @@ static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED switch (size) { case -2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])); + a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0])); + lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } case 2: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0])); + a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | digits[0])); + lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } case -3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } case 3: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } case -4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } case 4: if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); break; } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) { - lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])); goto long_long; } default: return PyLong_Type.tp_as_number->nb_add(op1, op2); @@ -20081,27 +20087,27 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])); } } break; @@ -20135,54 +20141,54 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { case -2: if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) -(((((int)digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 2: if (8 * sizeof(int) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { - return (int) (((((int)digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -3: if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) -(((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 3: if (8 * sizeof(int) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { - return (int) (((((((int)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case -4: if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) -(((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; case 4: if (8 * sizeof(int) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) { - return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]))); } } break; @@ -20983,27 +20989,27 @@ static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { case 2: if (8 * sizeof(char) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) >= 2 * PyLong_SHIFT) { - return (char) (((((char)digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; case 3: if (8 * sizeof(char) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) >= 3 * PyLong_SHIFT) { - return (char) (((((((char)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; case 4: if (8 * sizeof(char) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) >= 4 * PyLong_SHIFT) { - return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0])); } } break; @@ -21037,54 +21043,54 @@ static CYTHON_INLINE char __Pyx_PyInt_As_char(PyObject *x) { case -2: if (8 * sizeof(char) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) -(((((char)digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((char)-1)*(((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 2: if (8 * sizeof(char) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { - return (char) (((((char)digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) ((((((char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case -3: if (8 * sizeof(char) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) -(((((((char)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((char)-1)*(((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 3: if (8 * sizeof(char) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { - return (char) (((((((char)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) ((((((((char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case -4: if (8 * sizeof(char) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) -(((((((((char)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) (((char)-1)*(((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; case 4: if (8 * sizeof(char) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(char) - 1 > 4 * PyLong_SHIFT) { - return (char) (((((((((char)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (char) ((((((((((char)digits[3]) << PyLong_SHIFT) | (char)digits[2]) << PyLong_SHIFT) | (char)digits[1]) << PyLong_SHIFT) | (char)digits[0]))); } } break; @@ -21167,27 +21173,27 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])); } } break; @@ -21221,54 +21227,54 @@ static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { case -2: if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) -(((((long)digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 2: if (8 * sizeof(long) > 1 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - return (long) (((((long)digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -3: if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) -(((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 3: if (8 * sizeof(long) > 2 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { - return (long) (((((((long)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case -4: if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) -(((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; case 4: if (8 * sizeof(long) > 3 * PyLong_SHIFT) { if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) { - __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0]))) + __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]))) } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) { - return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]))); } } break; @@ -21589,32 +21595,32 @@ static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { switch (size) { case 2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0])); + return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -2: if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | digits[0])); + return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -3: if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case 4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; case -4: if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) { - return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | digits[2]) << PyLong_SHIFT) | digits[1]) << PyLong_SHIFT) | digits[0])); + return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0])); } break; } diff --git a/GPy/likelihoods/binomial.py b/GPy/likelihoods/binomial.py index 32fab8a5..306f0a1a 100644 --- a/GPy/likelihoods/binomial.py +++ b/GPy/likelihoods/binomial.py @@ -27,9 +27,6 @@ class Binomial(Likelihood): super(Binomial, self).__init__(gp_link, 'Binomial') - def conditional_mean(self, gp, Y_metadata): - return self.gp_link(gp)*Y_metadata['trials'] - def pdf_link(self, inv_link_f, y, Y_metadata): """ Likelihood function given inverse link of f. @@ -138,7 +135,7 @@ class Binomial(Likelihood): inv_link_f2 = np.square(inv_link_f) return 2*y/inv_link_f**3 - 2*(N-y)/(1.-inv_link_f)**3 - def samples(self, gp, Y_metadata=None): + def samples(self, gp, Y_metadata=None, **kw): """ Returns a set of samples of observations based on a given value of the latent variable. @@ -152,3 +149,32 @@ class Binomial(Likelihood): def exact_inference_gradients(self, dL_dKdiag,Y_metadata=None): pass + def variational_expectations(self, Y, m, v, gh_points=None, Y_metadata=None): + if isinstance(self.gp_link, link_functions.Probit): + + if gh_points is None: + gh_x, gh_w = self._gh_points() + else: + gh_x, gh_w = gh_points + + + gh_w = gh_w / np.sqrt(np.pi) + shape = m.shape + C = np.atleast_1d(Y_metadata['trials']) + m,v,Y, C = m.flatten(), v.flatten(), Y.flatten()[:,None], C.flatten()[:,None] + X = gh_x[None,:]*np.sqrt(2.*v[:,None]) + m[:,None] + p = std_norm_cdf(X) + p = np.clip(p, 1e-9, 1.-1e-9) # for numerical stability + N = std_norm_pdf(X) + #TODO: missing nchoosek coefficient! use gammaln? + F = (Y*np.log(p) + (C-Y)*np.log(1.-p)).dot(gh_w) + NoverP = N/p + NoverP_ = N/(1.-p) + dF_dm = (Y*NoverP - (C-Y)*NoverP_).dot(gh_w) + dF_dv = -0.5* ( Y*(NoverP**2 + NoverP*X) + (C-Y)*(NoverP_**2 - NoverP_*X) ).dot(gh_w) + return F.reshape(*shape), dF_dm.reshape(*shape), dF_dv.reshape(*shape), None + else: + raise NotImplementedError + + + diff --git a/GPy/likelihoods/likelihood.py b/GPy/likelihoods/likelihood.py index 78f72d9d..c5b2094f 100644 --- a/GPy/likelihoods/likelihood.py +++ b/GPy/likelihoods/likelihood.py @@ -678,7 +678,7 @@ class Likelihood(Parameterized): burnin_cache = np.zeros(par_chains) burnin_cache[:] = starting_loc.flatten() burning_in = True - for i in xrange(burn_in+num_samples): + for i in range(burn_in+num_samples): next_ind = i-burn_in if burning_in: old_y = burnin_cache diff --git a/GPy/mappings/__init__.py b/GPy/mappings/__init__.py index 39568c9f..73390b87 100644 --- a/GPy/mappings/__init__.py +++ b/GPy/mappings/__init__.py @@ -7,4 +7,6 @@ from .mlp import MLP from .additive import Additive from .compound import Compound from .constant import Constant +from .identity import Identity +from .piecewise_linear import PiecewiseLinear diff --git a/GPy/mappings/additive.py b/GPy/mappings/additive.py index 1c86b680..0fb72ca4 100644 --- a/GPy/mappings/additive.py +++ b/GPy/mappings/additive.py @@ -23,9 +23,10 @@ class Additive(Mapping): assert(mapping1.input_dim==mapping2.input_dim) assert(mapping1.output_dim==mapping2.output_dim) input_dim, output_dim = mapping1.input_dim, mapping1.output_dim - Mapping.__init__(self, input_dim=input_dim, output_dim=output_dim) + super(Additive, self).__init__(input_dim=input_dim, output_dim=output_dim) self.mapping1 = mapping1 self.mapping2 = mapping2 + self.link_parameters(self.mapping1, self.mapping2) def f(self, X): return self.mapping1.f(X) + self.mapping2.f(X) diff --git a/GPy/mappings/linear.py b/GPy/mappings/linear.py index c105dd81..26504830 100644 --- a/GPy/mappings/linear.py +++ b/GPy/mappings/linear.py @@ -33,7 +33,7 @@ class Linear(Mapping): return np.dot(X, self.A) def update_gradients(self, dL_dF, X): - self.A.gradient = np.dot( X.T, dL_dF) + self.A.gradient = np.dot(X.T, dL_dF) def gradients_X(self, dL_dF, X): return np.dot(dL_dF, self.A.T) diff --git a/GPy/models/__init__.py b/GPy/models/__init__.py index 4d645bea..6d19d8a5 100644 --- a/GPy/models/__init__.py +++ b/GPy/models/__init__.py @@ -22,3 +22,9 @@ from .gp_var_gauss import GPVariationalGaussianApproximation from .one_vs_all_classification import OneVsAllClassification from .one_vs_all_sparse_classification import OneVsAllSparseClassification from .dpgplvm import DPBayesianGPLVM + +from .state_space_model import StateSpace + +from .ibp_lfm import IBPLFM + +from .gp_offset_regression import GPOffsetRegression diff --git a/GPy/models/gp_coregionalized_regression.py b/GPy/models/gp_coregionalized_regression.py index c8ee5f67..66edb8d7 100644 --- a/GPy/models/gp_coregionalized_regression.py +++ b/GPy/models/gp_coregionalized_regression.py @@ -17,7 +17,7 @@ class GPCoregionalizedRegression(GP): :type X_list: list of numpy arrays :param Y_list: list of observed values related to the different noise models :type Y_list: list of numpy arrays - :param kernel: a GPy kernel, defaults to RBF ** Coregionalized + :param kernel: a GPy kernel ** Coregionalized, defaults to RBF ** Coregionalized :type kernel: None | GPy.kernel defaults :likelihoods_list: a list of likelihoods, defaults to list of Gaussian likelihoods :type likelihoods_list: None | a list GPy.likelihoods diff --git a/GPy/models/gp_kronecker_gaussian_regression.py b/GPy/models/gp_kronecker_gaussian_regression.py index 37a33bef..44177b16 100644 --- a/GPy/models/gp_kronecker_gaussian_regression.py +++ b/GPy/models/gp_kronecker_gaussian_regression.py @@ -30,6 +30,7 @@ class GPKroneckerGaussianRegression(Model): """ def __init__(self, X1, X2, Y, kern1, kern2, noise_var=1., name='KGPR'): Model.__init__(self, name=name) + # accept the construction arguments self.X1 = ObsAr(X1) self.X2 = ObsAr(X2) diff --git a/GPy/models/gp_offset_regression.py b/GPy/models/gp_offset_regression.py new file mode 100644 index 00000000..b843e08d --- /dev/null +++ b/GPy/models/gp_offset_regression.py @@ -0,0 +1,95 @@ +# Copyright (c) 2012 - 2014 the GPy Austhors (see AUTHORS.txt) +# Licensed under the BSD 3-clause license (see LICENSE.txt) +# Written by Mike Smith. michaeltsmith.org.uk + +import numpy as np +from ..core import GP +from .. import likelihoods +from .. import kern +from ..core import Param + +class GPOffsetRegression(GP): + """ + Gaussian Process model for offset regression + + :param X: input observations, we assume for this class that this has one dimension of actual inputs and the last dimension should be the index of the cluster (so X should be Nx2) + :param Y: observed values (Nx1?) + :param kernel: a GPy kernel, defaults to rbf + :param Norm normalizer: [False] + :param noise_var: the noise variance for Gaussian likelhood, defaults to 1. + + Normalize Y with the norm given. + If normalizer is False, no normalization will be done + If it is None, we use GaussianNorm(alization) + + .. Note:: Multiple independent outputs are allowed using columns of Y + + """ + + def __init__(self, X, Y, kernel=None, Y_metadata=None, normalizer=None, noise_var=1., mean_function=None): + + assert X.shape[1]>1, "Need at least two input dimensions, as last dimension is the label of the cluster" + if kernel is None: + kernel = kern.RBF(X.shape[1]-1) + + #self._log_marginal_likelihood = np.nan #todo + + likelihood = likelihoods.Gaussian(variance=noise_var) + self.X_fixed = X[:,:-1] + self.selected = np.array([int(x) for x in X[:,-1]]) + + + super(GPOffsetRegression, self).__init__(X, Y, kernel, likelihood, name='GP offset regression', Y_metadata=Y_metadata, normalizer=normalizer, mean_function=mean_function) + maxcluster = np.max(self.selected) + self.offset = Param('offset', np.zeros(maxcluster)) + #self.offset.set_prior(...) + self.link_parameter(self.offset) + + #def dr_doffset(self, X, sel): #how much r changes wrt the offset hyperparameters + + #def dL_doffset(self, X, sel): + # dL_dr = self.dK_dr_via_X(X, X) * dL_dK + + + def dr_doffset(self,X,sel,delta): + #given an input matrix, X and the offsets (delta) + #finds dr/dDelta + #returns them as a list, one for each offset (delta). + #get the input values + + #a matrix G represents the effect of increasing the offset on the radius passed to the kernel for each input. For example + #what effect will increasing offset 4 have on the kernel output of inputs 5 and 8? Answer: Gs[4][5,8]... (positive or negative) + Gs = [] + for i,d in enumerate(delta): + #X[sel==(i+1)]-=d + G = np.repeat(np.array(sel==(i+1))[:,None]*1,len(X),axis=1) - np.repeat(np.array(sel==(i+1))[None,:]*1,len(X),axis=0) + Gs.append(G) + #does subtracting the two Xs end up positive or negative (if negative we need to flip the sign in G). + w = np.repeat(X,len(X),axis=1) - np.repeat(X.T,len(X),axis=0) + dr_doffsets = [] + for i,d in enumerate(delta): + dr_doffset = np.sign(w * Gs[i]) + #print "dr_doffset %d" % i + #print dr_doffset + #print Gs[i] + #print w + dr_doffsets.append(dr_doffset) + + #lastly we need to divide by the lengthscale: So far we've found d(X_i - X_j)/dOffsets + #we want dr/dOffsets. (X_i - X_j)/lengthscale = r + dr_doffsets /= self.kern.lengthscale + return dr_doffsets + + def parameters_changed(self): + offsets = np.hstack([0.0,self.offset.values])[:,None] + + self.X = self.X_fixed - offsets[self.selected] + super(GPOffsetRegression, self).parameters_changed() + + dL_dr = self.kern.dK_dr_via_X(self.X, self.X) * self.grad_dict['dL_dK'] + + dr_doff = self.dr_doffset(self.X,self.selected,self.offset.values) + for i in range(len(dr_doff)): + dL_doff = dL_dr * dr_doff[i] + self.offset.gradient[i] = -np.sum(dL_doff) + diff --git a/GPy/models/gp_var_gauss.py b/GPy/models/gp_var_gauss.py index 05c55625..4c8fa7ef 100644 --- a/GPy/models/gp_var_gauss.py +++ b/GPy/models/gp_var_gauss.py @@ -28,7 +28,7 @@ class GPVariationalGaussianApproximation(GP): self.beta = Param('beta', np.ones(num_data)) inf = VarGauss(self.alpha, self.beta) - super(GPVariationalGaussianApproximation, self).__init__(X, Y, kernel, likelihood, name='VarGP', inference_method=inf) + super(GPVariationalGaussianApproximation, self).__init__(X, Y, kernel, likelihood, name='VarGP', inference_method=inf, Y_metadata=Y_metadata) self.link_parameter(self.alpha) self.link_parameter(self.beta) diff --git a/GPy/models/ibp_lfm.py b/GPy/models/ibp_lfm.py new file mode 100644 index 00000000..c90ffa40 --- /dev/null +++ b/GPy/models/ibp_lfm.py @@ -0,0 +1,535 @@ +# Copyright (c) 2012, GPy authors (see AUTHORS.txt). +# Licensed under the BSD 3-clause license (see LICENSE.txt) + +import numpy as np + +from ..core.sparse_gp_mpi import SparseGP_MPI +from .. import kern +from ..util.linalg import jitchol, backsub_both_sides, tdot, dtrtrs, dtrtri, pdinv +from ..util import diag +from ..core.parameterization import Param +from ..likelihoods import Gaussian +from ..inference.latent_function_inference.var_dtc_parallel import VarDTC_minibatch +from ..inference.latent_function_inference.posterior import Posterior +from GPy.core.parameterization.variational import VariationalPrior +from ..core.parameterization.parameterized import Parameterized +from paramz.transformations import Logexp, Logistic, __fixed__ +log_2_pi = np.log(2*np.pi) + +class VarDTC_minibatch_IBPLFM(VarDTC_minibatch): + ''' + Modifications of VarDTC_minibatch for IBP LFM + ''' + + def __init__(self, batchsize=None, limit=3, mpi_comm=None): + super(VarDTC_minibatch_IBPLFM, self).__init__(batchsize, limit, mpi_comm) + + def gatherPsiStat(self, kern, X, Z, Y, beta, Zp): + + het_noise = beta.size > 1 + + assert beta.size == 1 + + trYYT = self.get_trYYT(Y) + if self.Y_speedup and not het_noise: + Y = self.get_YYTfactor(Y) + + num_inducing = Z.shape[0] + num_data, output_dim = Y.shape + batchsize = num_data if self.batchsize is None else self.batchsize + + psi2_full = np.zeros((num_inducing, num_inducing)) # MxM + psi1Y_full = np.zeros((output_dim, num_inducing)) # DxM + psi0_full = 0. + YRY_full = 0. + + for n_start in range(0, num_data, batchsize): + n_end = min(batchsize+n_start, num_data) + if batchsize == num_data: + Y_slice = Y + X_slice = X + else: + Y_slice = Y[n_start:n_end] + X_slice = X[n_start:n_end] + + if het_noise: + b = beta[n_start] + YRY_full += np.inner(Y_slice, Y_slice)*b + else: + b = beta + + psi0 = kern._Kdiag(X_slice) #Kff^q + psi1 = kern.K(X_slice, Z) #Kfu + + indX = X_slice.values + indX = np.int_(np.round(indX[:, -1])) + + Zp = Zp.gamma.values + # Extend Zp across columns + indZ = Z.values + indZ = np.int_(np.round(indZ[:, -1])) - Zp.shape[0] + Zpq = Zp[:, indZ] + + for d in np.unique(indX): + indd = indX == d + psi1d = psi1[indd, :] + Zpd = Zp[d, :] + Zp2 = Zpd[:, None]*Zpd[None, :] - np.diag(np.power(Zpd, 2)) + np.diag(Zpd) + psi2_full += (np.dot(psi1d.T, psi1d)*Zp2[np.ix_(indZ, indZ)])*b #Zp2*Kufd*Kfud*beta + + psi0_full += np.sum(psi0*Zp[indX, :])*b + psi1Y_full += np.dot(Y_slice.T, psi1*Zpq[indX, :])*b + + if not het_noise: + YRY_full = trYYT*beta + + if self.mpi_comm is not None: + from mpi4py import MPI + psi0_all = np.array(psi0_full) + psi1Y_all = psi1Y_full.copy() + psi2_all = psi2_full.copy() + YRY_all = np.array(YRY_full) + self.mpi_comm.Allreduce([psi0_full, MPI.DOUBLE], [psi0_all, MPI.DOUBLE]) + self.mpi_comm.Allreduce([psi1Y_full, MPI.DOUBLE], [psi1Y_all, MPI.DOUBLE]) + self.mpi_comm.Allreduce([psi2_full, MPI.DOUBLE], [psi2_all, MPI.DOUBLE]) + self.mpi_comm.Allreduce([YRY_full, MPI.DOUBLE], [YRY_all, MPI.DOUBLE]) + return psi0_all, psi1Y_all, psi2_all, YRY_all + + return psi0_full, psi1Y_full, psi2_full, YRY_full + + + def inference_likelihood(self, kern, X, Z, likelihood, Y, Zp): + """ + The first phase of inference: + Compute: log-likelihood, dL_dKmm + + Cached intermediate results: Kmm, KmmInv, + """ + + num_data, output_dim = Y.shape + input_dim = Z.shape[0] + if self.mpi_comm is not None: + from mpi4py import MPI + num_data_all = np.array(num_data,dtype=np.int32) + self.mpi_comm.Allreduce([np.int32(num_data), MPI.INT], [num_data_all, MPI.INT]) + num_data = num_data_all + + #see whether we've got a different noise variance for each datum + beta = 1./np.fmax(likelihood.variance, 1e-6) + het_noise = beta.size > 1 + if het_noise: + self.batchsize = 1 + + psi0_full, psi1Y_full, psi2_full, YRY_full = self.gatherPsiStat(kern, X, Z, Y, beta, Zp) + + #====================================================================== + # Compute Common Components + #====================================================================== + + Kmm = kern.K(Z).copy() + diag.add(Kmm, self.const_jitter) + if not np.isfinite(Kmm).all(): + print(Kmm) + Lm = jitchol(Kmm) + LmInv = dtrtri(Lm) + + LmInvPsi2LmInvT = np.dot(LmInv, np.dot(psi2_full, LmInv.T)) + Lambda = np.eye(Kmm.shape[0])+LmInvPsi2LmInvT + LL = jitchol(Lambda) + LLInv = dtrtri(LL) + logdet_L = 2.*np.sum(np.log(np.diag(LL))) + LmLLInv = np.dot(LLInv, LmInv) + + b = np.dot(psi1Y_full, LmLLInv.T) + bbt = np.sum(np.square(b)) + v = np.dot(b, LmLLInv).T + LLinvPsi1TYYTPsi1LLinvT = tdot(b.T) + + tmp = -np.dot(np.dot(LLInv.T, LLinvPsi1TYYTPsi1LLinvT + output_dim*np.eye(input_dim)), LLInv) + dL_dpsi2R = .5*np.dot(np.dot(LmInv.T, tmp + output_dim*np.eye(input_dim)), LmInv) + + # Cache intermediate results + self.midRes['dL_dpsi2R'] = dL_dpsi2R + self.midRes['v'] = v + + #====================================================================== + # Compute log-likelihood + #====================================================================== + if het_noise: + logL_R = -np.sum(np.log(beta)) + else: + logL_R = -num_data*np.log(beta) + logL = -(output_dim*(num_data*log_2_pi+logL_R+psi0_full-np.trace(LmInvPsi2LmInvT))+YRY_full-bbt)*.5 - output_dim*logdet_L*.5 + + #====================================================================== + # Compute dL_dKmm + #====================================================================== + + dL_dKmm = dL_dpsi2R - .5*output_dim*np.dot(np.dot(LmInv.T, LmInvPsi2LmInvT), LmInv) + + #====================================================================== + # Compute the Posterior distribution of inducing points p(u|Y) + #====================================================================== + + if not self.Y_speedup or het_noise: + wd_inv = backsub_both_sides(Lm, np.eye(input_dim)- backsub_both_sides(LL, np.identity(input_dim), transpose='left'), transpose='left') + post = Posterior(woodbury_inv=wd_inv, woodbury_vector=v, K=Kmm, mean=None, cov=None, K_chol=Lm) + else: + post = None + + #====================================================================== + # Compute dL_dthetaL for uncertian input and non-heter noise + #====================================================================== + + if not het_noise: + dL_dthetaL = .5*(YRY_full*beta + beta*output_dim*psi0_full - num_data*output_dim*beta) - beta*(dL_dpsi2R*psi2_full).sum() - beta*(v.T*psi1Y_full).sum() + self.midRes['dL_dthetaL'] = dL_dthetaL + + return logL, dL_dKmm, post + + def inference_minibatch(self, kern, X, Z, likelihood, Y, Zp): + """ + The second phase of inference: Computing the derivatives over a minibatch of Y + Compute: dL_dpsi0, dL_dpsi1, dL_dpsi2, dL_dthetaL + return a flag showing whether it reached the end of Y (isEnd) + """ + + num_data, output_dim = Y.shape + + #see whether we've got a different noise variance for each datum + beta = 1./np.fmax(likelihood.variance, 1e-6) + het_noise = beta.size > 1 + # VVT_factor is a matrix such that tdot(VVT_factor) = VVT...this is for efficiency! + #self.YYTfactor = beta*self.get_YYTfactor(Y) + if self.Y_speedup and not het_noise: + YYT_factor = self.get_YYTfactor(Y) + else: + YYT_factor = Y + + n_start = self.batch_pos + batchsize = num_data if self.batchsize is None else self.batchsize + n_end = min(batchsize+n_start, num_data) + if n_end == num_data: + isEnd = True + self.batch_pos = 0 + else: + isEnd = False + self.batch_pos = n_end + + if batchsize == num_data: + Y_slice = YYT_factor + X_slice = X + else: + Y_slice = YYT_factor[n_start:n_end] + X_slice = X[n_start:n_end] + + psi0 = kern._Kdiag(X_slice) #Kffdiag + psi1 = kern.K(X_slice, Z) #Kfu + betapsi1 = np.einsum('n,nm->nm', beta, psi1) + + X_slice = X_slice.values + Z = Z.values + + Zp = Zp.gamma.values + indX = np.int_(X_slice[:, -1]) + indZ = np.int_(Z[:, -1]) - Zp.shape[0] + + betaY = beta*Y_slice + + #====================================================================== + # Load Intermediate Results + #====================================================================== + + dL_dpsi2R = self.midRes['dL_dpsi2R'] + v = self.midRes['v'] + + #====================================================================== + # Compute dL_dpsi + #====================================================================== + + dL_dpsi0 = -.5*output_dim*(beta * Zp[indX, :]) #XxQ #TODO: Check this gradient + + dL_dpsi1 = np.dot(betaY, v.T) + dL_dEZp = psi1*dL_dpsi1 + dL_dpsi1 = Zp[np.ix_(indX, indZ)]*dL_dpsi1 + dL_dgamma = np.zeros(Zp.shape) + for d in np.unique(indX): + indd = indX == d + betapsi1d = betapsi1[indd, :] + psi1d = psi1[indd, :] + Zpd = Zp[d, :] + Zp2 = Zpd[:, None]*Zpd[None, :] - np.diag(np.power(Zpd, 2)) + np.diag(Zpd) + dL_dpsi1[indd, :] += np.dot(betapsi1d, Zp2[np.ix_(indZ, indZ)] * dL_dpsi2R)*2. + + dL_EZp2 = dL_dpsi2R * (np.dot(psi1d.T, psi1d) * beta)*2. # Zpd*Kufd*Kfud*beta + #Gradient of Likelihood wrt gamma is calculated here + EZ = Zp[d, indZ] + for q in range(Zp.shape[1]): + EZt = EZ.copy() + indq = indZ == q + EZt[indq] = .5 + dL_dgamma[d, q] = np.sum(dL_dEZp[np.ix_(indd, indq)]) + np.sum(dL_EZp2[:, indq]*EZt[:, None]) -\ + .5*beta*(np.sum(psi0[indd, q])) + + #====================================================================== + # Compute dL_dthetaL + #====================================================================== + if isEnd: + dL_dthetaL = self.midRes['dL_dthetaL'] + else: + dL_dthetaL = 0. + + grad_dict = {'dL_dKdiag': dL_dpsi0, + 'dL_dKnm': dL_dpsi1, + 'dL_dthetaL': dL_dthetaL, + 'dL_dgamma': dL_dgamma} + + return isEnd, (n_start, n_end), grad_dict + + +def update_gradients(model, mpi_comm=None): + if mpi_comm is None: + Y = model.Y + X = model.X + else: + Y = model.Y_local + X = model.X[model.N_range[0]:model.N_range[1]] + + model._log_marginal_likelihood, dL_dKmm, model.posterior = model.inference_method.inference_likelihood(model.kern, X, model.Z, model.likelihood, Y, model.Zp) + + het_noise = model.likelihood.variance.size > 1 + + if het_noise: + dL_dthetaL = np.empty((model.Y.shape[0],)) + else: + dL_dthetaL = np.float64(0.) + + kern_grad = model.kern.gradient.copy() + kern_grad[:] = 0. + model.Z.gradient = 0. + gamma_gradient = model.Zp.gamma.copy() + gamma_gradient[:] = 0. + + isEnd = False + while not isEnd: + isEnd, n_range, grad_dict = model.inference_method.inference_minibatch(model.kern, X, model.Z, model.likelihood, Y, model.Zp) + + if (n_range[1]-n_range[0]) == X.shape[0]: + X_slice = X + elif mpi_comm is None: + X_slice = model.X[n_range[0]:n_range[1]] + else: + X_slice = model.X[model.N_range[0]+n_range[0]:model.N_range[0]+n_range[1]] + + #gradients w.r.t. kernel + model.kern.update_gradients_diag(grad_dict['dL_dKdiag'], X_slice) + kern_grad += model.kern.gradient + + model.kern.update_gradients_full(grad_dict['dL_dKnm'], X_slice, model.Z) + kern_grad += model.kern.gradient + + #gradients w.r.t. Z + model.Z.gradient += model.kern.gradients_X(grad_dict['dL_dKnm'].T, model.Z, X_slice) + + #gradients w.r.t. posterior parameters of Zp + gamma_gradient += grad_dict['dL_dgamma'] + + if het_noise: + dL_dthetaL[n_range[0]:n_range[1]] = grad_dict['dL_dthetaL'] + else: + dL_dthetaL += grad_dict['dL_dthetaL'] + + # Gather the gradients from multiple MPI nodes + if mpi_comm is not None: + from mpi4py import MPI + if het_noise: + raise "het_noise not implemented!" + kern_grad_all = kern_grad.copy() + Z_grad_all = model.Z.gradient.copy() + gamma_grad_all = gamma_gradient.copy() + mpi_comm.Allreduce([kern_grad, MPI.DOUBLE], [kern_grad_all, MPI.DOUBLE]) + mpi_comm.Allreduce([model.Z.gradient, MPI.DOUBLE], [Z_grad_all, MPI.DOUBLE]) + mpi_comm.Allreduce([gamma_gradient, MPI.DOUBLE], [gamma_grad_all, MPI.DOUBLE]) + kern_grad = kern_grad_all + model.Z.gradient = Z_grad_all + gamma_gradient = gamma_grad_all + + #gradients w.r.t. kernel + model.kern.update_gradients_full(dL_dKmm, model.Z, None) + model.kern.gradient += kern_grad + + #gradients w.r.t. Z + model.Z.gradient += model.kern.gradients_X(dL_dKmm, model.Z) + + #gradient w.r.t. gamma + model.Zp.gamma.gradient = gamma_gradient + + # Update Log-likelihood + KL_div = model.variational_prior.KL_divergence(model.Zp) + # update for the KL divergence + model.variational_prior.update_gradients_KL(model.Zp) + + model._log_marginal_likelihood += KL_div + + # dL_dthetaL + model.likelihood.update_gradients(dL_dthetaL) + + +class IBPPosterior(Parameterized): + ''' + The IBP distribution for variational approximations. + ''' + def __init__(self, binary_prob, tau=None, name='Sensitivity space', *a, **kw): + """ + binary_prob : the probability of including a latent function over an output. + """ + super(IBPPosterior, self).__init__(name=name, *a, **kw) + self.gamma = Param("binary_prob", binary_prob, Logistic(1e-10, 1. - 1e-10)) + self.link_parameter(self.gamma) + if tau is not None: + assert tau.size == 2*self.gamma_.shape[1] + self.tau = Param("tau", tau, Logexp()) + else: + self.tau = Param("tau", np.ones((2, self.gamma.shape[1])), Logexp()) + self.link_parameter(self.tau) + + def set_gradients(self, grad): + self.gamma.gradient, self.tau.gradient = grad + + def __getitem__(self, s): + pass + # if isinstance(s, (int, slice, tuple, list, np.ndarray)): + # import copy + # n = self.__new__(self.__class__, self.name) + # dc = self.__dict__.copy() + # dc['binary_prob'] = self.binary_prob[s] + # dc['tau'] = self.tau + # dc['parameters'] = copy.copy(self.parameters) + # n.__dict__.update(dc) + # n.parameters[dc['binary_prob']._parent_index_] = dc['binary_prob'] + # n.parameters[dc['tau']._parent_index_] = dc['tau'] + # n._gradient_array_ = None + # oversize = self.size - self.gamma.size - self.tau.size + # n.size = n.gamma.size + n.tau.size + oversize + # return n + # else: + # return super(IBPPosterior, self).__getitem__(s) + +class IBPPrior(VariationalPrior): + def __init__(self, rank, alpha=2., name='IBPPrior', **kw): + super(IBPPrior, self).__init__(name=name, **kw) + from paramz.transformations import __fixed__ + self.rank = rank + self.alpha = Param('alpha', alpha, __fixed__) + self.link_parameter(self.alpha) + + def KL_divergence(self, variational_posterior): + from scipy.special import gamma, psi + + eta, tau = variational_posterior.gamma.values, variational_posterior.tau.values + + sum_eta = np.sum(eta, axis=0) #sum_d gamma(d,q) + D_seta = eta.shape[0] - sum_eta + ad = self.alpha/eta.shape[1] + psitau1 = psi(tau[0, :]) + psitau2 = psi(tau[1, :]) + sumtau = np.sum(tau, axis=0) + psitau = psi(sumtau) + # E[log p(z)] + part1 = np.sum(sum_eta*psitau1 + D_seta*psitau2 - eta.shape[0]*psitau) + + # E[log p(pi)] + part1 += (ad - 1.)*np.sum(psitau1 - psitau) + eta.shape[1]*np.log(ad) + + #H(z) + part2 = np.sum(-(1.-eta)*np.log(1.-eta) - eta*np.log(eta)) + #H(pi) + part2 += np.sum(np.log(gamma(tau[0, :])*gamma(tau[1, :])/gamma(sumtau))-(tau[0, :]-1.)*psitau1-(tau[1, :]-1.)*psitau2\ + + (sumtau-2.)*psitau) + + return part1+part2 + + def update_gradients_KL(self, variational_posterior): + eta, tau = variational_posterior.gamma.values, variational_posterior.tau.values + + from scipy.special import psi, polygamma + dgamma = np.log(1. - eta) - np.log(eta) + psi(tau[0, :]) - psi(tau[1, :]) + variational_posterior.gamma.gradient += dgamma + ad = self.alpha/self.rank + sumeta = np.sum(eta, axis=0) + sumtau = np.sum(tau, axis=0) + common = (-eta.shape[0] - (ad - 1.) + (sumtau - 2.))*polygamma(1, sumtau) + variational_posterior.tau.gradient[0, :] = (sumeta + ad - tau[0, :])*polygamma(1, tau[0, :]) + common + variational_posterior.tau.gradient[1, :] = ((eta.shape[0] - sumeta) - (tau[1, :] - 1.))*polygamma(1, tau[1, :])\ + + common + + +class IBPLFM(SparseGP_MPI): + """ + Indian Buffet Process for Latent Force Models + + :param Y: observed data (np.ndarray) or GPy.likelihood + :type Y: np.ndarray| GPy.likelihood instance + :param X: input data (np.ndarray) [X:values, X:index], index refers to the number of the output + :type X: np.ndarray + :param input_dim: latent dimensionality + :type input_dim: int + : param rank: number of latent functions + + """ + def __init__(self, X, Y, input_dim=2, output_dim=1, rank=1, Gamma=None, num_inducing=10, + Z=None, kernel=None, inference_method=None, likelihood=None, name='IBP for LFM', alpha=2., beta=2., connM=None, tau=None, mpi_comm=None, normalizer=False, variational_prior=None,**kwargs): + + if kernel is None: + kernel = kern.EQ_ODE2(input_dim, output_dim, rank) + + if Gamma is None: + gamma = np.empty((output_dim, rank)) # The posterior probabilities of the binary variable in the variational approximation + gamma[:] = 0.5 + 0.1 * np.random.randn(output_dim, rank) + gamma[gamma>1.-1e-9] = 1.-1e-9 + gamma[gamma<1e-9] = 1e-9 + else: + gamma = Gamma.copy() + + #TODO: create a vector of inducing points + if Z is None: + Z = np.random.permutation(X.copy())[:num_inducing] + assert Z.shape[1] == X.shape[1] + + if likelihood is None: + likelihood = Gaussian() + + if inference_method is None: + inference_method = VarDTC_minibatch_IBPLFM(mpi_comm=mpi_comm) + + #Definition of variational terms + self.variational_prior = IBPPrior(rank=rank, alpha=alpha) if variational_prior is None else variational_prior + self.Zp = IBPPosterior(gamma, tau=tau) + + super(IBPLFM, self).__init__(X, Y, Z, kernel, likelihood, variational_prior=self.variational_prior, inference_method=inference_method, name=name, mpi_comm=mpi_comm, normalizer=normalizer, **kwargs) + self.link_parameter(self.Zp, index=0) + + def set_Zp_gradients(self, Zp, Zp_grad): + """Set the gradients of the posterior distribution of Zp in its specific form.""" + Zp.gamma.gradient = Zp_grad + + def get_Zp_gradients(self, Zp): + """Get the gradients of the posterior distribution of Zp in its specific form.""" + return Zp.gamma.gradient + + def _propogate_Zp_val(self): + pass + + def parameters_changed(self): + #super(IBPLFM,self).parameters_changed() + if isinstance(self.inference_method, VarDTC_minibatch_IBPLFM): + update_gradients(self, mpi_comm=self.mpi_comm) + return + + # Add the KL divergence term + self._log_marginal_likelihood += self.variational_prior.KL_divergence(self.Zp) + #TODO Change the following according to this variational distribution + #self.Zp.gamma.gradient = self. + + # update for the KL divergence + self.variational_prior.update_gradients_KL(self.Zp) \ No newline at end of file diff --git a/GPy/models/mrd.py b/GPy/models/mrd.py index 547f096f..029a9d00 100644 --- a/GPy/models/mrd.py +++ b/GPy/models/mrd.py @@ -127,8 +127,6 @@ class MRD(BayesianGPLVMMiniBatch): self.unlink_parameter(self.likelihood) self.unlink_parameter(self.kern) - del self.kern - del self.likelihood self.num_data = Ylist[0].shape[0] if isinstance(batchsize, int): @@ -156,7 +154,11 @@ class MRD(BayesianGPLVMMiniBatch): self.link_parameter(spgp, i+2) self.bgplvms.append(spgp) - self.posterior = None + b = self.bgplvms[0] + self.posterior = b.posterior + self.kern = b.kern + self.likelihood = b.likelihood + self.logger.info("init done") def parameters_changed(self): diff --git a/GPy/models/sparse_gp_coregionalized_regression.py b/GPy/models/sparse_gp_coregionalized_regression.py index 2997993e..88841891 100644 --- a/GPy/models/sparse_gp_coregionalized_regression.py +++ b/GPy/models/sparse_gp_coregionalized_regression.py @@ -19,7 +19,7 @@ class SparseGPCoregionalizedRegression(SparseGP): :type Y_list: list of numpy arrays :param Z_list: list of inducing inputs (optional) :type Z_list: empty list | list of numpy arrays - :param kernel: a GPy kernel, defaults to RBF ** Coregionalized + :param kernel: a GPy kernel ** Coregionalized, defaults to RBF ** Coregionalized :type kernel: None | GPy.kernel defaults :likelihoods_list: a list of likelihoods, defaults to list of Gaussian likelihoods :type likelihoods_list: None | a list GPy.likelihoods diff --git a/GPy/models/sparse_gp_regression.py b/GPy/models/sparse_gp_regression.py index b1180511..893ccff6 100644 --- a/GPy/models/sparse_gp_regression.py +++ b/GPy/models/sparse_gp_regression.py @@ -30,7 +30,7 @@ class SparseGPRegression(SparseGP_MPI): """ - def __init__(self, X, Y, kernel=None, Z=None, num_inducing=10, X_variance=None, normalizer=None, mpi_comm=None): + def __init__(self, X, Y, kernel=None, Z=None, num_inducing=10, X_variance=None, normalizer=None, mpi_comm=None, name='sparse_gp'): num_data, input_dim = X.shape # kern defaults to rbf (plus white for stability) @@ -55,7 +55,7 @@ class SparseGPRegression(SparseGP_MPI): else: infr = VarDTC() - SparseGP_MPI.__init__(self, X, Y, Z, kernel, likelihood, inference_method=infr, normalizer=normalizer, mpi_comm=mpi_comm) + SparseGP_MPI.__init__(self, X, Y, Z, kernel, likelihood, inference_method=infr, normalizer=normalizer, mpi_comm=mpi_comm, name=name) def parameters_changed(self): from ..inference.latent_function_inference.var_dtc_parallel import update_gradients_sparsegp,VarDTC_minibatch diff --git a/GPy/models/ss_gplvm.py b/GPy/models/ss_gplvm.py index c8ff1664..7d10bab6 100644 --- a/GPy/models/ss_gplvm.py +++ b/GPy/models/ss_gplvm.py @@ -291,12 +291,12 @@ class SSGPLVM(SparseGP_MPI): Xs[b>self.X.gamma.values] = 0 invcov = (Xs[:,:,:,None]*Xs[:,:,None,:]).sum(1)/noise_var+np.eye(Q) - cov = np.array([pdinv(invcov[s_idx])[0] for s_idx in xrange(invcov.shape[0])]) + cov = np.array([pdinv(invcov[s_idx])[0] for s_idx in range(invcov.shape[0])]) Ws = np.empty((nSamples, Q, D)) tmp = (np.transpose(Xs, (0,2,1)).reshape(nSamples*Q,N).dot(self.Y)).reshape(nSamples,Q,D) mean = (cov[:,:,:,None]*tmp[:,None,:,:]).sum(2)/noise_var zeros = np.zeros((Q,)) - for s_idx in xrange(Xs.shape[0]): + for s_idx in range(Xs.shape[0]): Ws[s_idx] = (np.random.multivariate_normal(mean=zeros,cov=cov[s_idx],size=(D,))).T+mean[s_idx] if raw_samples: diff --git a/GPy/models/ss_mrd.py b/GPy/models/ss_mrd.py index d571a542..0aa472c7 100644 --- a/GPy/models/ss_mrd.py +++ b/GPy/models/ss_mrd.py @@ -25,7 +25,7 @@ class SSMRD(Model): self.X = NormalPosterior(means=X, variances=X_variance) if kernels is None: - kernels = [RBF(input_dim, lengthscale=1./fracs, ARD=True) for i in xrange(len(Ylist))] + kernels = [RBF(input_dim, lengthscale=1./fracs, ARD=True) for i in range(len(Ylist))] if Zs is None: Zs = [None]* len(Ylist) if likelihoods is None: @@ -34,9 +34,9 @@ class SSMRD(Model): inference_methods = [None]* len(Ylist) if IBP: - self.var_priors = [IBPPrior_SSMRD(len(Ylist),input_dim,alpha=alpha) for i in xrange(len(Ylist))] + self.var_priors = [IBPPrior_SSMRD(len(Ylist),input_dim,alpha=alpha) for i in range(len(Ylist))] else: - self.var_priors = [SpikeAndSlabPrior_SSMRD(nModels=len(Ylist),pi=pi,learnPi=False, group_spike=group_spike) for i in xrange(len(Ylist))] + self.var_priors = [SpikeAndSlabPrior_SSMRD(nModels=len(Ylist),pi=pi,learnPi=False, group_spike=group_spike) for i in range(len(Ylist))] self.models = [SSGPLVM(y, input_dim, X=X.copy(), X_variance=X_variance.copy(), Gamma=Gammas[i], num_inducing=num_inducing,Z=Zs[i], learnPi=False, group_spike=group_spike, kernel=kernels[i],inference_method=inference_methods[i],likelihood=likelihoods[i], variational_prior=self.var_priors[i], IBP=IBP, tau=None if taus is None else taus[i], name='model_'+str(i), mpi_comm=mpi_comm, sharedX=True) for i,y in enumerate(Ylist)] @@ -73,7 +73,7 @@ class SSMRD(Model): # Divide latent dimensions idx = np.empty((input_dim,),dtype=np.int) residue = (input_dim)%(len(Ylist)) - for i in xrange(len(Ylist)): + for i in range(len(Ylist)): if i < residue: size = input_dim/len(Ylist)+1 idx[i*size:(i+1)*size] = i @@ -86,7 +86,7 @@ class SSMRD(Model): X = np.empty((Ylist[0].shape[0],input_dim)) fracs = np.empty((input_dim,)) from ..util.initialization import initialize_latent - for i in xrange(len(Ylist)): + for i in range(len(Ylist)): Y = Ylist[i] dim = (idx==i).sum() if dim>0: diff --git a/GPy/models/state_space.py b/GPy/models/state_space.py new file mode 100644 index 00000000..0e3498d8 --- /dev/null +++ b/GPy/models/state_space.py @@ -0,0 +1,745 @@ +# Copyright (c) 2013, Arno Solin. +# Licensed under the BSD 3-clause license (see LICENSE.txt) +# +# This implementation of converting GPs to state space models is based on the article: +# +# @article{Sarkka+Solin+Hartikainen:2013, +# author = {Simo S\"arkk\"a and Arno Solin and Jouni Hartikainen}, +# year = {2013}, +# title = {Spatiotemporal learning via infinite-dimensional {B}ayesian filtering and smoothing}, +# journal = {IEEE Signal Processing Magazine}, +# volume = {30}, +# number = {4}, +# pages = {51--61} +# } +# + +import numpy as np +from scipy import linalg +from ..core import Model +from .. import kern +from GPy.plotting.matplot_dep.models_plots import gpplot +from GPy.plotting.matplot_dep.base_plots import x_frame1D +from GPy.plotting.matplot_dep import Tango +import pylab as pb +from GPy.core.parameterization.param import Param + +class StateSpace(Model): + def __init__(self, X, Y, kernel=None, sigma2=1.0, name='StateSpace'): + super(StateSpace, self).__init__(name=name) + self.num_data, input_dim = X.shape + assert input_dim==1, "State space methods for time only" + num_data_Y, self.output_dim = Y.shape + assert num_data_Y == self.num_data, "X and Y data don't match" + assert self.output_dim == 1, "State space methods for single outputs only" + + # Make sure the observations are ordered in time + sort_index = np.argsort(X[:,0]) + self.X = X[sort_index] + self.Y = Y[sort_index] + + # Noise variance + self.sigma2 = Param('Gaussian_noise', sigma2) + self.link_parameter(self.sigma2) + + # Default kernel + if kernel is None: + self.kern = kern.Matern32(1) + else: + self.kern = kernel + self.link_parameter(self.kern) + + self.sigma2.constrain_positive() + + # Assert that the kernel is supported + if not hasattr(self.kern, 'sde'): + raise NotImplementedError('SDE must be implemented for the kernel being used') + #assert self.kern.sde() not False, "This kernel is not supported for state space estimation" + + def parameters_changed(self): + """ + Parameters have now changed + """ + # Get the model matrices from the kernel + (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() + + # Use the Kalman filter to evaluate the likelihood + self._log_marginal_likelihood = self.kf_likelihood(F,L,Qc,H,self.sigma2,Pinf,self.X.T,self.Y.T) + gradients = self.compute_gradients() + self.sigma2.gradient_full[:] = gradients[-1] + self.kern.gradient_full[:] = gradients[:-1] + + def log_likelihood(self): + return self._log_marginal_likelihood + + def compute_gradients(self): + # Get the model matrices from the kernel + (F,L,Qc,H,Pinf,dFt,dQct,dPinft) = self.kern.sde() + + # Allocate space for the full partial derivative matrices + dF = np.zeros([dFt.shape[0],dFt.shape[1],dFt.shape[2]+1]) + dQc = np.zeros([dQct.shape[0],dQct.shape[1],dQct.shape[2]+1]) + dPinf = np.zeros([dPinft.shape[0],dPinft.shape[1],dPinft.shape[2]+1]) + + # Assign the values for the kernel function + dF[:,:,:-1] = dFt + dQc[:,:,:-1] = dQct + dPinf[:,:,:-1] = dPinft + + # The sigma2 derivative + dR = np.zeros([1,1,dF.shape[2]]) + dR[:,:,-1] = 1 + + # Calculate the likelihood gradients + gradients = self.kf_likelihood_g(F,L,Qc,H,self.sigma2,Pinf,dF,dQc,dPinf,dR,self.X.T,self.Y.T) + return gradients + + def predict_raw(self, Xnew, Ynew=None, filteronly=False): + + # Set defaults + if Ynew is None: + Ynew = self.Y + + # Make a single matrix containing training and testing points + X = np.vstack((self.X, Xnew)) + Y = np.vstack((Ynew, np.nan*np.zeros(Xnew.shape))) + + # Sort the matrix (save the order) + _, return_index, return_inverse = np.unique(X,True,True) + X = X[return_index] + Y = Y[return_index] + + # Get the model matrices from the kernel + (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() + + # Run the Kalman filter + (M, P) = self.kalman_filter(F,L,Qc,H,self.sigma2,Pinf,X.T,Y.T) + + # Run the Rauch-Tung-Striebel smoother + if not filteronly: + (M, P) = self.rts_smoother(F,L,Qc,X.T,M,P) + + # Put the data back in the original order + M = M[:,return_inverse] + P = P[:,:,return_inverse] + + # Only return the values for Xnew + M = M[:,self.num_data:] + P = P[:,:,self.num_data:] + + # Calculate the mean and variance + m = H.dot(M).T + V = np.tensordot(H[0],P,(0,0)) + V = np.tensordot(V,H[0],(0,0)) + V = V[:,None] + + # Return the posterior of the state + return (m, V) + + def predict(self, Xnew, filteronly=False): + + # Run the Kalman filter to get the state + (m, V) = self.predict_raw(Xnew,filteronly=filteronly) + + # Add the noise variance to the state variance + V += self.sigma2 + + # Lower and upper bounds + lower = m - 2*np.sqrt(V) + upper = m + 2*np.sqrt(V) + + # Return mean and variance + return (m, V, lower, upper) + + def plot(self, plot_limits=None, levels=20, samples=0, fignum=None, + ax=None, resolution=None, plot_raw=False, plot_filter=False, + linecol=Tango.colorsHex['darkBlue'],fillcol=Tango.colorsHex['lightBlue']): + + # Deal with optional parameters + if ax is None: + fig = pb.figure(num=fignum) + ax = fig.add_subplot(111) + + # Define the frame on which to plot + resolution = resolution or 200 + Xgrid, xmin, xmax = x_frame1D(self.X, plot_limits=plot_limits) + + # Make a prediction on the frame and plot it + if plot_raw: + m, v = self.predict_raw(Xgrid,filteronly=plot_filter) + lower = m - 2*np.sqrt(v) + upper = m + 2*np.sqrt(v) + Y = self.Y + else: + m, v, lower, upper = self.predict(Xgrid,filteronly=plot_filter) + Y = self.Y + + # Plot the values + gpplot(Xgrid, m, lower, upper, axes=ax, edgecol=linecol, fillcol=fillcol) + ax.plot(self.X, self.Y, 'kx', mew=1.5) + + # Optionally plot some samples + if samples: + if plot_raw: + Ysim = self.posterior_samples_f(Xgrid, samples) + else: + Ysim = self.posterior_samples(Xgrid, samples) + for yi in Ysim.T: + ax.plot(Xgrid, yi, Tango.colorsHex['darkBlue'], linewidth=0.25) + + # Set the limits of the plot to some sensible values + ymin, ymax = min(np.append(Y.flatten(), lower.flatten())), max(np.append(Y.flatten(), upper.flatten())) + ymin, ymax = ymin - 0.1 * (ymax - ymin), ymax + 0.1 * (ymax - ymin) + ax.set_xlim(xmin, xmax) + ax.set_ylim(ymin, ymax) + + def prior_samples_f(self,X,size=10): + + # Sort the matrix (save the order) + (_, return_index, return_inverse) = np.unique(X,True,True) + X = X[return_index] + + # Get the model matrices from the kernel + (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() + + # Allocate space for results + Y = np.empty((size,X.shape[0])) + + # Simulate random draws + #for j in range(0,size): + # Y[j,:] = H.dot(self.simulate(F,L,Qc,Pinf,X.T)) + Y = self.simulate(F,L,Qc,Pinf,X.T,size) + + # Only observations + Y = np.tensordot(H[0],Y,(0,0)) + + # Reorder simulated values + Y = Y[:,return_inverse] + + # Return trajectory + return Y.T + + def posterior_samples_f(self,X,size=10): + + # Sort the matrix (save the order) + (_, return_index, return_inverse) = np.unique(X,True,True) + X = X[return_index] + + # Get the model matrices from the kernel + (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() + + # Run smoother on original data + (m,V) = self.predict_raw(X) + + # Simulate random draws from the GP prior + y = self.prior_samples_f(np.vstack((self.X, X)),size) + + # Allocate space for sample trajectories + Y = np.empty((size,X.shape[0])) + + # Run the RTS smoother on each of these values + for j in range(0,size): + yobs = y[0:self.num_data,j:j+1] + np.sqrt(self.sigma2)*np.random.randn(self.num_data,1) + (m2,V2) = self.predict_raw(X,Ynew=yobs) + Y[j,:] = m.T + y[self.num_data:,j].T - m2.T + + # Reorder simulated values + Y = Y[:,return_inverse] + + # Return posterior sample trajectories + return Y.T + + def posterior_samples(self, X, size=10): + + # Make samples of f + Y = self.posterior_samples_f(X,size) + + # Add noise + Y += np.sqrt(self.sigma2)*np.random.randn(Y.shape[0],Y.shape[1]) + + # Return trajectory + return Y + + def kalman_filter(self,F,L,Qc,H,R,Pinf,X,Y): + # KALMAN_FILTER - Run the Kalman filter for a given model and data + + # Allocate space for results + MF = np.empty((F.shape[0],Y.shape[1])) + PF = np.empty((F.shape[0],F.shape[0],Y.shape[1])) + + # Initialize + MF[:,-1] = np.zeros(F.shape[0]) + PF[:,:,-1] = Pinf.copy() + + # Time step lengths + dt = np.empty(X.shape) + dt[:,0] = X[:,1]-X[:,0] + dt[:,1:] = np.diff(X) + + # Solve the LTI SDE for these time steps + As, Qs, index = self.lti_disc(F,L,Qc,dt) + + # Kalman filter + for k in range(0,Y.shape[1]): + + # Form discrete-time model + #(A, Q) = self.lti_disc(F,L,Qc,dt[:,k]) + A = As[:,:,index[k]]; + Q = Qs[:,:,index[k]]; + + # Prediction step + MF[:,k] = A.dot(MF[:,k-1]) + PF[:,:,k] = A.dot(PF[:,:,k-1]).dot(A.T) + Q + + # Update step (only if there is data) + if not np.isnan(Y[:,k]): + if Y.shape[0]==1: + K = PF[:,:,k].dot(H.T)/(H.dot(PF[:,:,k]).dot(H.T) + R) + else: + LL = linalg.cho_factor(H.dot(PF[:,:,k]).dot(H.T) + R) + K = linalg.cho_solve(LL, H.dot(PF[:,:,k].T)).T + MF[:,k] += K.dot(Y[:,k]-H.dot(MF[:,k])) + PF[:,:,k] -= K.dot(H).dot(PF[:,:,k]) + + # Return values + return (MF, PF) + + def rts_smoother(self,F,L,Qc,X,MS,PS): + # RTS_SMOOTHER - Run the RTS smoother for a given model and data + + # Time step lengths + dt = np.empty(X.shape) + dt[:,0] = X[:,1]-X[:,0] + dt[:,1:] = np.diff(X) + + # Solve the LTI SDE for these time steps + As, Qs, index = self.lti_disc(F,L,Qc,dt) + + # Sequentially smooth states starting from the end + for k in range(2,X.shape[1]+1): + + # Form discrete-time model + #(A, Q) = self.lti_disc(F,L,Qc,dt[:,1-k]) + A = As[:,:,index[1-k]]; + Q = Qs[:,:,index[1-k]]; + + # Smoothing step + LL = linalg.cho_factor(A.dot(PS[:,:,-k]).dot(A.T)+Q) + G = linalg.cho_solve(LL,A.dot(PS[:,:,-k])).T + MS[:,-k] += G.dot(MS[:,1-k]-A.dot(MS[:,-k])) + PS[:,:,-k] += G.dot(PS[:,:,1-k]-A.dot(PS[:,:,-k]).dot(A.T)-Q).dot(G.T) + + # Return + return (MS, PS) + + def kf_likelihood(self,F,L,Qc,H,R,Pinf,X,Y): + # Evaluate marginal likelihood + + # Initialize + lik = 0 + m = np.zeros((F.shape[0],1)) + P = Pinf.copy() + + # Time step lengths + dt = np.empty(X.shape) + dt[:,0] = X[:,1]-X[:,0] + dt[:,1:] = np.diff(X) + + # Solve the LTI SDE for these time steps + As, Qs, index = self.lti_disc(F,L,Qc,dt) + + # Kalman filter for likelihood evaluation + for k in range(0,Y.shape[1]): + + # Form discrete-time model + #(A,Q) = self.lti_disc(F,L,Qc,dt[:,k]) + A = As[:,:,index[k]]; + Q = Qs[:,:,index[k]]; + + # Prediction step + m = A.dot(m) + P = A.dot(P).dot(A.T) + Q + + # Update step only if there is data + if not np.isnan(Y[:,k]): + v = Y[:,k]-H.dot(m) + if Y.shape[0]==1: + S = H.dot(P).dot(H.T) + R + K = P.dot(H.T)/S + lik -= 0.5*np.log(S) + lik -= 0.5*v.shape[0]*np.log(2*np.pi) + lik -= 0.5*v*v/S + else: + LL, isupper = linalg.cho_factor(H.dot(P).dot(H.T) + R) + lik -= np.sum(np.log(np.diag(LL))) + lik -= 0.5*v.shape[0]*np.log(2*np.pi) + lik -= 0.5*linalg.cho_solve((LL, isupper),v).dot(v) + K = linalg.cho_solve((LL, isupper), H.dot(P.T)).T + m += K.dot(v) + P -= K.dot(H).dot(P) + + # Return likelihood + return lik[0,0] + + def kf_likelihood_g(self,F,L,Qc,H,R,Pinf,dF,dQc,dPinf,dR,X,Y): + # Evaluate marginal likelihood gradient + + # State dimension, number of data points and number of parameters + n = F.shape[0] + steps = Y.shape[1] + nparam = dF.shape[2] + + # Time steps + t = X.squeeze() + + # Allocate space + e = 0 + eg = np.zeros(nparam) + + # Set up + m = np.zeros([n,1]) + P = Pinf.copy() + dm = np.zeros([n,nparam]) + dP = dPinf.copy() + mm = m.copy() + PP = P.copy() + + # Initial dt + dt = -np.Inf + + # Allocate space for expm results + AA = np.zeros([2*n, 2*n, nparam]) + FF = np.zeros([2*n, 2*n]) + + # Loop over all observations + for k in range(0,steps): + + # The previous time step + dt_old = dt; + + # The time discretization step length + if k>0: + dt = t[k]-t[k-1] + else: + dt = 0 + + # Loop through all parameters (Kalman filter prediction step) + for j in range(0,nparam): + + # Should we recalculate the matrix exponential? + if abs(dt-dt_old) > 1e-9: + + # The first matrix for the matrix factor decomposition + FF[:n,:n] = F + FF[n:,:n] = dF[:,:,j] + FF[n:,n:] = F + + # Solve the matrix exponential + AA[:,:,j] = linalg.expm3(FF*dt) + + # Solve the differential equation + foo = AA[:,:,j].dot(np.vstack([m, dm[:,j:j+1]])) + mm = foo[:n,:] + dm[:,j:j+1] = foo[n:,:] + + # The discrete-time dynamical model + if j==0: + A = AA[:n,:n,j] + Q = Pinf - A.dot(Pinf).dot(A.T) + PP = A.dot(P).dot(A.T) + Q + + # The derivatives of A and Q + dA = AA[n:,:n,j] + dQ = dPinf[:,:,j] - dA.dot(Pinf).dot(A.T) \ + - A.dot(dPinf[:,:,j]).dot(A.T) - A.dot(Pinf).dot(dA.T) + + # The derivatives of P + dP[:,:,j] = dA.dot(P).dot(A.T) + A.dot(dP[:,:,j]).dot(A.T) \ + + A.dot(P).dot(dA.T) + dQ + + # Set predicted m and P + m = mm + P = PP + + # Start the Kalman filter update step and precalculate variables + S = H.dot(P).dot(H.T) + R + + # We should calculate the Cholesky factor if S is a matrix + # [LS,notposdef] = chol(S,'lower'); + + # The Kalman filter update (S is scalar) + HtiS = H.T/S + iS = 1/S + K = P.dot(HtiS) + v = Y[:,k]-H.dot(m) + vtiS = v.T/S + + # Loop through all parameters (Kalman filter update step derivative) + for j in range(0,nparam): + + # Innovation covariance derivative + dS = H.dot(dP[:,:,j]).dot(H.T) + dR[:,:,j]; + + # Evaluate the energy derivative for j + eg[j] = eg[j] \ + - .5*np.sum(iS*dS) \ + + .5*H.dot(dm[:,j:j+1]).dot(vtiS.T) \ + + .5*vtiS.dot(dS).dot(vtiS.T) \ + + .5*vtiS.dot(H.dot(dm[:,j:j+1])) + + # Kalman filter update step derivatives + dK = dP[:,:,j].dot(HtiS) - P.dot(HtiS).dot(dS)/S + dm[:,j:j+1] = dm[:,j:j+1] + dK.dot(v) - K.dot(H).dot(dm[:,j:j+1]) + dKSKt = dK.dot(S).dot(K.T) + dP[:,:,j] = dP[:,:,j] - dKSKt - K.dot(dS).dot(K.T) - dKSKt.T + + # Evaluate the energy + # e = e - .5*S.shape[0]*np.log(2*np.pi) - np.sum(np.log(np.diag(LS))) - .5*vtiS.dot(v); + e = e - .5*S.shape[0]*np.log(2*np.pi) - np.sum(np.log(np.sqrt(S))) - .5*vtiS.dot(v) + + # Finish Kalman filter update step + m = m + K.dot(v) + P = P - K.dot(S).dot(K.T) + + # Make sure the covariances stay symmetric + P = (P+P.T)/2 + dP = (dP + dP.transpose([1,0,2]))/2 + + # raise NameError('Debug me') + + # Return the gradient + return eg + + def kf_likelihood_g_notstable(self,F,L,Qc,H,R,Pinf,dF,dQc,dPinf,dR,X,Y): + # Evaluate marginal likelihood gradient + + # State dimension, number of data points and number of parameters + steps = Y.shape[1] + nparam = dF.shape[2] + n = F.shape[0] + + # Time steps + t = X.squeeze() + + # Allocate space + e = 0 + eg = np.zeros(nparam) + + # Set up + Z = np.zeros(F.shape) + QC = L.dot(Qc).dot(L.T) + m = np.zeros([n,1]) + P = Pinf.copy() + dm = np.zeros([n,nparam]) + dP = dPinf.copy() + mm = m.copy() + PP = P.copy() + + # % Initial dt + dt = -np.Inf + + # Allocate space for expm results + AA = np.zeros([2*F.shape[0], 2*F.shape[0], nparam]) + AAA = np.zeros([4*F.shape[0], 4*F.shape[0], nparam]) + FF = np.zeros([2*F.shape[0], 2*F.shape[0]]) + FFF = np.zeros([4*F.shape[0], 4*F.shape[0]]) + + # Loop over all observations + for k in range(0,steps): + + # The previous time step + dt_old = dt; + + # The time discretization step length + if k>0: + dt = t[k]-t[k-1] + else: + dt = t[1]-t[0] + + # Loop through all parameters (Kalman filter prediction step) + for j in range(0,nparam): + + # Should we recalculate the matrix exponential? + if abs(dt-dt_old) > 1e-9: + + # The first matrix for the matrix factor decomposition + FF[:n,:n] = F + FF[n:,:n] = dF[:,:,j] + FF[n:,n:] = F + + # Solve the matrix exponential + AA[:,:,j] = linalg.expm3(FF*dt) + + # Solve using matrix fraction decomposition + foo = AA[:,:,j].dot(np.vstack([m, dm[:,j:j+1]])) + + # Pick the parts + mm = foo[:n,:] + dm[:,j:j+1] = foo[n:,:] + + # Should we recalculate the matrix exponential? + if abs(dt-dt_old) > 1e-9: + + # Define W and G + W = L.dot(dQc[:,:,j]).dot(L.T) + G = dF[:,:,j]; + + # The second matrix for the matrix factor decomposition + FFF[:n,:n] = F + FFF[2*n:-n,:n] = G + FFF[:n, n:2*n] = QC + FFF[n:2*n, n:2*n] = -F.T + FFF[2*n:-n,n:2*n] = W + FFF[-n:, n:2*n] = -G.T + FFF[2*n:-n,2*n:-n] = F + FFF[2*n:-n,-n:] = QC + FFF[-n:,-n:] = -F.T + + # Solve the matrix exponential + AAA[:,:,j] = linalg.expm3(FFF*dt) + + # Solve using matrix fraction decomposition + foo = AAA[:,:,j].dot(np.vstack([P, np.eye(n), dP[:,:,j], np.zeros([n,n])])) + + # Pick the parts + C = foo[:n, :] + D = foo[n:2*n, :] + dC = foo[2*n:-n,:] + dD = foo[-n:, :] + + # The prediction step covariance (PP = C/D) + if j==0: + PP = linalg.solve(D.T,C.T).T + PP = (PP + PP.T)/2 + + # Sove dP for j (C/D == P_{k|k-1}) + dP[:,:,j] = linalg.solve(D.T,(dC - PP.dot(dD)).T).T + + # Set predicted m and P + m = mm + P = PP + + # Start the Kalman filter update step and precalculate variables + S = H.dot(P).dot(H.T) + R + + # We should calculate the Cholesky factor if S is a matrix + # [LS,notposdef] = chol(S,'lower'); + + # The Kalman filter update (S is scalar) + HtiS = H.T/S + iS = 1/S + K = P.dot(HtiS) + v = Y[:,k]-H.dot(m) + vtiS = v.T/S + + # Loop through all parameters (Kalman filter update step derivative) + for j in range(0,nparam): + + # Innovation covariance derivative + dS = H.dot(dP[:,:,j]).dot(H.T) + dR[:,:,j]; + + # Evaluate the energy derivative for j + eg[j] = eg[j] \ + - .5*np.sum(iS*dS) \ + + .5*H.dot(dm[:,j:j+1]).dot(vtiS.T) \ + + .5*vtiS.dot(dS).dot(vtiS.T) \ + + .5*vtiS.dot(H.dot(dm[:,j:j+1])) + + # Kalman filter update step derivatives + dK = dP[:,:,j].dot(HtiS) - P.dot(HtiS).dot(dS)/S + dm[:,j:j+1] = dm[:,j:j+1] + dK.dot(v) - K.dot(H).dot(dm[:,j:j+1]) + dKSKt = dK.dot(S).dot(K.T) + dP[:,:,j] = dP[:,:,j] - dKSKt - K.dot(dS).dot(K.T) - dKSKt.T + + # Evaluate the energy + # e = e - .5*S.shape[0]*np.log(2*np.pi) - np.sum(np.log(np.diag(LS))) - .5*vtiS.dot(v); + e = e - .5*S.shape[0]*np.log(2*np.pi) - np.sum(np.log(np.sqrt(S))) - .5*vtiS.dot(v) + + # Finish Kalman filter update step + m = m + K.dot(v) + P = P - K.dot(S).dot(K.T) + + # Make sure the covariances stay symmetric + P = (P+P.T)/2 + dP = (dP + dP.transpose([1,0,2]))/2 + + # raise NameError('Debug me') + + # Report + #print e + #print eg + + # Return the gradient + return eg + + def simulate(self,F,L,Qc,Pinf,X,size=1): + # Simulate a trajectory using the state space model + + # Allocate space for results + f = np.zeros((F.shape[0],size,X.shape[1])) + + # Initial state + f[:,:,1] = np.linalg.cholesky(Pinf).dot(np.random.randn(F.shape[0],size)) + + # Time step lengths + dt = np.empty(X.shape) + dt[:,0] = X[:,1]-X[:,0] + dt[:,1:] = np.diff(X) + + # Solve the LTI SDE for these time steps + As, Qs, index = self.lti_disc(F,L,Qc,dt) + + # Sweep through remaining time points + for k in range(1,X.shape[1]): + + # Form discrete-time model + A = As[:,:,index[1-k]] + Q = Qs[:,:,index[1-k]] + + # Draw the state + f[:,:,k] = A.dot(f[:,:,k-1]) + np.dot(np.linalg.cholesky(Q),np.random.randn(A.shape[0],size)) + + # Return values + return f + + def lti_disc(self,F,L,Qc,dt): + # Discrete-time solution to the LTI SDE + + # Dimensionality + n = F.shape[0] + index = 0 + + # Check for numbers of time steps + if dt.flatten().shape[0]==1: + + # The covariance matrix by matrix fraction decomposition + Phi = np.zeros((2*n,2*n)) + Phi[:n,:n] = F + Phi[:n,n:] = L.dot(Qc).dot(L.T) + Phi[n:,n:] = -F.T + AB = linalg.expm(Phi*dt).dot(np.vstack((np.zeros((n,n)),np.eye(n)))) + Q = linalg.solve(AB[n:,:].T,AB[:n,:].T) + + # The dynamical model + A = linalg.expm(F*dt) + + # Return + return A, Q + + # Optimize for cases where time steps occur repeatedly + else: + + # Time discretizations (round to 14 decimals to avoid problems) + dt, _, index = np.unique(np.round(dt,14),True,True) + + # Allocate space for A and Q + A = np.empty((n,n,dt.shape[0])) + Q = np.empty((n,n,dt.shape[0])) + + # Call this function for each dt + for j in range(0,dt.shape[0]): + A[:,:,j], Q[:,:,j] = self.lti_disc(F,L,Qc,dt[j]) + + # Return + return A, Q, index + diff --git a/GPy/models/state_space_cython.c b/GPy/models/state_space_cython.c new file mode 100644 index 00000000..3e6f3513 --- /dev/null +++ b/GPy/models/state_space_cython.c @@ -0,0 +1,27410 @@ +/* Generated by Cython 0.22 */ + +/* BEGIN: Cython Metadata +{ + "distutils": { + "depends": [] + } +} +END: Cython Metadata */ + +#define PY_SSIZE_T_CLEAN +#ifndef CYTHON_USE_PYLONG_INTERNALS +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 0 +#else +#include "pyconfig.h" +#ifdef PYLONG_BITS_IN_DIGIT +#define CYTHON_USE_PYLONG_INTERNALS 1 +#else +#define CYTHON_USE_PYLONG_INTERNALS 0 +#endif +#endif +#endif +#include "Python.h" +#ifndef Py_PYTHON_H + #error Python headers needed to compile C extensions, please install development version of Python. +#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) + #error Cython requires Python 2.6+ or Python 3.2+. +#else +#define CYTHON_ABI "0_22" +#include +#ifndef offsetof +#define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) +#endif +#if !defined(WIN32) && !defined(MS_WINDOWS) + #ifndef __stdcall + #define __stdcall + #endif + #ifndef __cdecl + #define __cdecl + #endif + #ifndef __fastcall + #define __fastcall + #endif +#endif +#ifndef DL_IMPORT + #define DL_IMPORT(t) t +#endif +#ifndef DL_EXPORT + #define DL_EXPORT(t) t +#endif +#ifndef PY_LONG_LONG + #define PY_LONG_LONG LONG_LONG +#endif +#ifndef Py_HUGE_VAL + #define Py_HUGE_VAL HUGE_VAL +#endif +#ifdef PYPY_VERSION +#define CYTHON_COMPILING_IN_PYPY 1 +#define CYTHON_COMPILING_IN_CPYTHON 0 +#else +#define CYTHON_COMPILING_IN_PYPY 0 +#define CYTHON_COMPILING_IN_CPYTHON 1 +#endif +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) +#define Py_OptimizeFlag 0 +#endif +#define __PYX_BUILD_PY_SSIZE_T "n" +#define CYTHON_FORMAT_SSIZE_T "z" +#if PY_MAJOR_VERSION < 3 + #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyClass_Type +#else + #define __Pyx_BUILTIN_MODULE_NAME "builtins" + #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ + PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) + #define __Pyx_DefaultClassType PyType_Type +#endif +#if PY_MAJOR_VERSION >= 3 + #define Py_TPFLAGS_CHECKTYPES 0 + #define Py_TPFLAGS_HAVE_INDEX 0 + #define Py_TPFLAGS_HAVE_NEWBUFFER 0 +#endif +#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) + #define Py_TPFLAGS_HAVE_FINALIZE 0 +#endif +#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) + #define CYTHON_PEP393_ENABLED 1 + #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op))) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i) + #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u) + #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u) + #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i) +#else + #define CYTHON_PEP393_ENABLED 0 + #define __Pyx_PyUnicode_READY(op) (0) + #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) + #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) + #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) + #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) + #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) +#endif +#if CYTHON_COMPILING_IN_PYPY + #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) + #define __Pyx_PyFrozenSet_Size(s) PyObject_Size(s) +#else + #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) + #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ + PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) + #define __Pyx_PyFrozenSet_Size(s) PySet_Size(s) +#endif +#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) +#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) +#else + #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBaseString_Type PyUnicode_Type + #define PyStringObject PyUnicodeObject + #define PyString_Type PyUnicode_Type + #define PyString_Check PyUnicode_Check + #define PyString_CheckExact PyUnicode_CheckExact +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) + #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) +#else + #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) + #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) +#endif +#ifndef PySet_CheckExact + #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) +#endif +#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) +#if PY_MAJOR_VERSION >= 3 + #define PyIntObject PyLongObject + #define PyInt_Type PyLong_Type + #define PyInt_Check(op) PyLong_Check(op) + #define PyInt_CheckExact(op) PyLong_CheckExact(op) + #define PyInt_FromString PyLong_FromString + #define PyInt_FromUnicode PyLong_FromUnicode + #define PyInt_FromLong PyLong_FromLong + #define PyInt_FromSize_t PyLong_FromSize_t + #define PyInt_FromSsize_t PyLong_FromSsize_t + #define PyInt_AsLong PyLong_AsLong + #define PyInt_AS_LONG PyLong_AS_LONG + #define PyInt_AsSsize_t PyLong_AsSsize_t + #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask + #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask + #define PyNumber_Int PyNumber_Long +#endif +#if PY_MAJOR_VERSION >= 3 + #define PyBoolObject PyLongObject +#endif +#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY + #ifndef PyUnicode_InternFromString + #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) + #endif +#endif +#if PY_VERSION_HEX < 0x030200A4 + typedef long Py_hash_t; + #define __Pyx_PyInt_FromHash_t PyInt_FromLong + #define __Pyx_PyInt_AsHash_t PyInt_AsLong +#else + #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t + #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t +#endif +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) +#else + #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) +#endif +#ifndef CYTHON_INLINE + #if defined(__GNUC__) + #define CYTHON_INLINE __inline__ + #elif defined(_MSC_VER) + #define CYTHON_INLINE __inline + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_INLINE inline + #else + #define CYTHON_INLINE + #endif +#endif +#ifndef CYTHON_RESTRICT + #if defined(__GNUC__) + #define CYTHON_RESTRICT __restrict__ + #elif defined(_MSC_VER) && _MSC_VER >= 1400 + #define CYTHON_RESTRICT __restrict + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + #define CYTHON_RESTRICT restrict + #else + #define CYTHON_RESTRICT + #endif +#endif +#ifdef NAN +#define __PYX_NAN() ((float) NAN) +#else +static CYTHON_INLINE float __PYX_NAN() { + /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and + a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is + a quiet NaN. */ + float value; + memset(&value, 0xFF, sizeof(value)); + return value; +} +#endif +#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None) +#ifdef __cplusplus +template +void __Pyx_call_destructor(T* x) { + x->~T(); +} +template +class __Pyx_FakeReference { + public: + __Pyx_FakeReference() : ptr(NULL) { } + __Pyx_FakeReference(T& ref) : ptr(&ref) { } + T *operator->() { return ptr; } + operator T&() { return *ptr; } + private: + T *ptr; +}; +#endif + + +#if PY_MAJOR_VERSION >= 3 + #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) +#else + #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) + #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) +#endif + +#ifndef __PYX_EXTERN_C + #ifdef __cplusplus + #define __PYX_EXTERN_C extern "C" + #else + #define __PYX_EXTERN_C extern + #endif +#endif + +#if defined(WIN32) || defined(MS_WINDOWS) +#define _USE_MATH_DEFINES +#endif +#include +#define __PYX_HAVE__GPy__models__state_space_cython +#define __PYX_HAVE_API__GPy__models__state_space_cython +#include "string.h" +#include "stdio.h" +#include "stdlib.h" +#include "numpy/arrayobject.h" +#include "numpy/ufuncobject.h" +#include "numpy/npy_math.h" +#ifdef _OPENMP +#include +#endif /* _OPENMP */ + +#ifdef PYREX_WITHOUT_ASSERTIONS +#define CYTHON_WITHOUT_ASSERTIONS +#endif + +#ifndef CYTHON_UNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER)) +# define CYTHON_UNUSED __attribute__ ((__unused__)) +# else +# define CYTHON_UNUSED +# endif +#endif +typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding; + const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; + +#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 +#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0 +#define __PYX_DEFAULT_STRING_ENCODING "" +#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString +#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#define __Pyx_fits_Py_ssize_t(v, type, is_signed) ( \ + (sizeof(type) < sizeof(Py_ssize_t)) || \ + (sizeof(type) > sizeof(Py_ssize_t) && \ + likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX) && \ + (!is_signed || likely(v > (type)PY_SSIZE_T_MIN || \ + v == (type)PY_SSIZE_T_MIN))) || \ + (sizeof(type) == sizeof(Py_ssize_t) && \ + (is_signed || likely(v < (type)PY_SSIZE_T_MAX || \ + v == (type)PY_SSIZE_T_MAX))) ) +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*); +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); +#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) +#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l) +#define __Pyx_PyBytes_FromString PyBytes_FromString +#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize +#else + #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString + #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize +#endif +#define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) +#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#if PY_MAJOR_VERSION < 3 +static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) +{ + const Py_UNICODE *u_end = u; + while (*u_end++) ; + return (size_t)(u_end - u - 1); +} +#else +#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen +#endif +#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) +#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode +#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode +#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None) +#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False)) +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x); +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*); +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t); +#if CYTHON_COMPILING_IN_CPYTHON +#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) +#else +#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) +#endif +#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII +static int __Pyx_sys_getdefaultencoding_not_ascii; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + PyObject* ascii_chars_u = NULL; + PyObject* ascii_chars_b = NULL; + const char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + if (strcmp(default_encoding_c, "ascii") == 0) { + __Pyx_sys_getdefaultencoding_not_ascii = 0; + } else { + char ascii_chars[128]; + int c; + for (c = 0; c < 128; c++) { + ascii_chars[c] = c; + } + __Pyx_sys_getdefaultencoding_not_ascii = 1; + ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); + if (!ascii_chars_u) goto bad; + ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); + if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { + PyErr_Format( + PyExc_ValueError, + "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", + default_encoding_c); + goto bad; + } + Py_DECREF(ascii_chars_u); + Py_DECREF(ascii_chars_b); + } + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + Py_XDECREF(ascii_chars_u); + Py_XDECREF(ascii_chars_b); + return -1; +} +#endif +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) +#else +#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) +#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT +static char* __PYX_DEFAULT_STRING_ENCODING; +static int __Pyx_init_sys_getdefaultencoding_params(void) { + PyObject* sys; + PyObject* default_encoding = NULL; + char* default_encoding_c; + sys = PyImport_ImportModule("sys"); + if (!sys) goto bad; + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); + Py_DECREF(sys); + if (!default_encoding) goto bad; + default_encoding_c = PyBytes_AsString(default_encoding); + if (!default_encoding_c) goto bad; + __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); + if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; + strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); + Py_DECREF(default_encoding); + return 0; +bad: + Py_XDECREF(default_encoding); + return -1; +} +#endif +#endif + + +/* Test for GCC > 2.95 */ +#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))) + #define likely(x) __builtin_expect(!!(x), 1) + #define unlikely(x) __builtin_expect(!!(x), 0) +#else /* !__GNUC__ or GCC < 2.95 */ + #define likely(x) (x) + #define unlikely(x) (x) +#endif /* __GNUC__ */ + +static PyObject *__pyx_m; +static PyObject *__pyx_d; +static PyObject *__pyx_b; +static PyObject *__pyx_empty_tuple; +static PyObject *__pyx_empty_bytes; +static int __pyx_lineno; +static int __pyx_clineno = 0; +static const char * __pyx_cfilenm= __FILE__; +static const char *__pyx_filename; + +#if !defined(CYTHON_CCOMPLEX) + #if defined(__cplusplus) + #define CYTHON_CCOMPLEX 1 + #elif defined(_Complex_I) + #define CYTHON_CCOMPLEX 1 + #else + #define CYTHON_CCOMPLEX 0 + #endif +#endif +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #include + #else + #include + #endif +#endif +#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__) + #undef _Complex_I + #define _Complex_I 1.0fj +#endif + + +static const char *__pyx_f[] = { + "GPy/models/state_space_cython.pyx", + "__init__.pxd", + "type.pxd", +}; +#define IS_UNSIGNED(type) (((type) -1) > 0) +struct __Pyx_StructField_; +#define __PYX_BUF_FLAGS_PACKED_STRUCT (1 << 0) +typedef struct { + const char* name; + struct __Pyx_StructField_* fields; + size_t size; + size_t arraysize[8]; + int ndim; + char typegroup; + char is_unsigned; + int flags; +} __Pyx_TypeInfo; +typedef struct __Pyx_StructField_ { + __Pyx_TypeInfo* type; + const char* name; + size_t offset; +} __Pyx_StructField; +typedef struct { + __Pyx_StructField* field; + size_t parent_offset; +} __Pyx_BufFmt_StackElem; +typedef struct { + __Pyx_StructField root; + __Pyx_BufFmt_StackElem* head; + size_t fmt_offset; + size_t new_count, enc_count; + size_t struct_alignment; + int is_complex; + char enc_type; + char new_packmode; + char enc_packmode; + char is_valid_array; +} __Pyx_BufFmt_Context; + + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 + * # in Cython to enable them only on the right systems. + * + * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + */ +typedef npy_int8 __pyx_t_5numpy_int8_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 + * + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t + */ +typedef npy_int16 __pyx_t_5numpy_int16_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 + * ctypedef npy_int8 int8_t + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< + * ctypedef npy_int64 int64_t + * #ctypedef npy_int96 int96_t + */ +typedef npy_int32 __pyx_t_5numpy_int32_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":729 + * ctypedef npy_int16 int16_t + * ctypedef npy_int32 int32_t + * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< + * #ctypedef npy_int96 int96_t + * #ctypedef npy_int128 int128_t + */ +typedef npy_int64 __pyx_t_5numpy_int64_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 + * #ctypedef npy_int128 int128_t + * + * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + */ +typedef npy_uint8 __pyx_t_5numpy_uint8_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 + * + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t + */ +typedef npy_uint16 __pyx_t_5numpy_uint16_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 + * ctypedef npy_uint8 uint8_t + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< + * ctypedef npy_uint64 uint64_t + * #ctypedef npy_uint96 uint96_t + */ +typedef npy_uint32 __pyx_t_5numpy_uint32_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":736 + * ctypedef npy_uint16 uint16_t + * ctypedef npy_uint32 uint32_t + * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< + * #ctypedef npy_uint96 uint96_t + * #ctypedef npy_uint128 uint128_t + */ +typedef npy_uint64 __pyx_t_5numpy_uint64_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 + * #ctypedef npy_uint128 uint128_t + * + * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< + * ctypedef npy_float64 float64_t + * #ctypedef npy_float80 float80_t + */ +typedef npy_float32 __pyx_t_5numpy_float32_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":741 + * + * ctypedef npy_float32 float32_t + * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< + * #ctypedef npy_float80 float80_t + * #ctypedef npy_float128 float128_t + */ +typedef npy_float64 __pyx_t_5numpy_float64_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 + * # The int types are mapped a bit surprising -- + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t + */ +typedef npy_long __pyx_t_5numpy_int_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 + * # numpy.int corresponds to 'l' and numpy.long to 'q' + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< + * ctypedef npy_longlong longlong_t + * + */ +typedef npy_longlong __pyx_t_5numpy_long_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":752 + * ctypedef npy_long int_t + * ctypedef npy_longlong long_t + * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_ulong uint_t + */ +typedef npy_longlong __pyx_t_5numpy_longlong_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 + * ctypedef npy_longlong longlong_t + * + * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t + */ +typedef npy_ulong __pyx_t_5numpy_uint_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 + * + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< + * ctypedef npy_ulonglong ulonglong_t + * + */ +typedef npy_ulonglong __pyx_t_5numpy_ulong_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":756 + * ctypedef npy_ulong uint_t + * ctypedef npy_ulonglong ulong_t + * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< + * + * ctypedef npy_intp intp_t + */ +typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 + * ctypedef npy_ulonglong ulonglong_t + * + * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< + * ctypedef npy_uintp uintp_t + * + */ +typedef npy_intp __pyx_t_5numpy_intp_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":759 + * + * ctypedef npy_intp intp_t + * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< + * + * ctypedef npy_double float_t + */ +typedef npy_uintp __pyx_t_5numpy_uintp_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 + * ctypedef npy_uintp uintp_t + * + * ctypedef npy_double float_t # <<<<<<<<<<<<<< + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t + */ +typedef npy_double __pyx_t_5numpy_float_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 + * + * ctypedef npy_double float_t + * ctypedef npy_double double_t # <<<<<<<<<<<<<< + * ctypedef npy_longdouble longdouble_t + * + */ +typedef npy_double __pyx_t_5numpy_double_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":763 + * ctypedef npy_double float_t + * ctypedef npy_double double_t + * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cfloat cfloat_t + */ +typedef npy_longdouble __pyx_t_5numpy_longdouble_t; + +/* "GPy/models/state_space_cython.pyx":17 + * DTYPE_int = np.int64 + * + * ctypedef np.float64_t DTYPE_t # <<<<<<<<<<<<<< + * ctypedef np.int64_t DTYPE_int_t + * + */ +typedef __pyx_t_5numpy_float64_t __pyx_t_3GPy_6models_18state_space_cython_DTYPE_t; + +/* "GPy/models/state_space_cython.pyx":18 + * + * ctypedef np.float64_t DTYPE_t + * ctypedef np.int64_t DTYPE_int_t # <<<<<<<<<<<<<< + * + * # Template class for dynamic callables + */ +typedef __pyx_t_5numpy_int64_t __pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t; +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< float > __pyx_t_float_complex; + #else + typedef float _Complex __pyx_t_float_complex; + #endif +#else + typedef struct { float real, imag; } __pyx_t_float_complex; +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + typedef ::std::complex< double > __pyx_t_double_complex; + #else + typedef double _Complex __pyx_t_double_complex; + #endif +#else + typedef struct { double real, imag; } __pyx_t_double_complex; +#endif + + +/*--- Type declarations ---*/ +struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; +struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 + * ctypedef npy_longdouble longdouble_t + * + * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t + */ +typedef npy_cfloat __pyx_t_5numpy_cfloat_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 + * + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< + * ctypedef npy_clongdouble clongdouble_t + * + */ +typedef npy_cdouble __pyx_t_5numpy_cdouble_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":767 + * ctypedef npy_cfloat cfloat_t + * ctypedef npy_cdouble cdouble_t + * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< + * + * ctypedef npy_cdouble complex_t + */ +typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":769 + * ctypedef npy_clongdouble clongdouble_t + * + * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew1(a): + */ +typedef npy_cdouble __pyx_t_5numpy_complex_t; +struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset; +struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset; +struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset; +struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset; + +/* "GPy/models/state_space_cython.pyx":40 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self, bint compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ +struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset { + int __pyx_n; + int compute_derivatives; +}; + +/* "GPy/models/state_space_cython.pyx":63 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self,compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ +struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset { + int __pyx_n; + PyObject *compute_derivatives; +}; + +/* "GPy/models/state_space_cython.pyx":365 + * + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ +struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset { + int __pyx_n; + int compute_derivatives; +}; + +/* "GPy/models/state_space_cython.pyx":444 + * return np.dot(A, m) # default dynamic model + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ +struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset { + int __pyx_n; + int compute_derivatives; +}; + +/* "GPy/models/state_space_cython.pyx":21 + * + * # Template class for dynamic callables + * cdef class Dynamic_Callables_Cython: # <<<<<<<<<<<<<< + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + * raise NotImplemented("(cython) f_a is not implemented!") + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython { + PyObject_HEAD + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_vtab; +}; + + +/* "GPy/models/state_space_cython.pyx":44 + * + * # Template class for measurement callables + * cdef class Measurement_Callables_Cython: # <<<<<<<<<<<<<< + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): + * raise NotImplemented("(cython) f_a is not implemented!") + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython { + PyObject_HEAD + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_vtab; +}; + + +/* "GPy/models/state_space_cython.pyx":66 + * raise NotImplemented("(cython) reset is not implemented!") + * + * cdef class R_handling_Cython(Measurement_Callables_Cython): # <<<<<<<<<<<<<< + * """ + * The calss handles noise matrix R. + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython { + struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_base; + PyArrayObject *R; + PyArrayObject *index; + int R_time_var_index; + PyArrayObject *dR; + int svd_each_time; + PyObject *R_square_root; +}; + + +/* "GPy/models/state_space_cython.pyx":165 + * + * + * cdef class Std_Measurement_Callables_Cython(R_handling_Cython): # <<<<<<<<<<<<<< + * + * cdef: + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython { + struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_base; + PyArrayObject *H; + int H_time_var_index; + PyArrayObject *dH; +}; + + +/* "GPy/models/state_space_cython.pyx":212 + * + * + * cdef class Q_handling_Cython(Dynamic_Callables_Cython): # <<<<<<<<<<<<<< + * + * cdef: + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython { + struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_base; + PyArrayObject *Q; + PyArrayObject *index; + int Q_time_var_index; + PyArrayObject *dQ; + PyObject *Q_square_root; + int svd_each_time; +}; + + +/* "GPy/models/state_space_cython.pyx":318 + * return square_root + * + * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython): # <<<<<<<<<<<<<< + * cdef: + * np.ndarray A + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython { + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base; + PyArrayObject *A; + int A_time_var_index; + PyArrayObject *dA; +}; + + +/* "GPy/models/state_space_cython.pyx":373 + * return self + * + * cdef class AQcompute_batch_Cython(Q_handling_Cython): # <<<<<<<<<<<<<< + * """ + * Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter + */ +struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython { + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base; + PyArrayObject *As; + PyArrayObject *Qs; + PyArrayObject *dAs; + PyArrayObject *dQs; + PyArrayObject *reconstruct_indices; + PyObject *Q_svd_dict; + int last_k; +}; + + + +/* "GPy/models/state_space_cython.pyx":21 + * + * # Template class for dynamic callables + * cdef class Dynamic_Callables_Cython: # <<<<<<<<<<<<<< + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + * raise NotImplemented("(cython) f_a is not implemented!") + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython { + PyObject *(*f_a)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*Ak)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*Qk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*Q_srk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*dAk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*dQk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*reset)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args); +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + + +/* "GPy/models/state_space_cython.pyx":44 + * + * # Template class for measurement callables + * cdef class Measurement_Callables_Cython: # <<<<<<<<<<<<<< + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): + * raise NotImplemented("(cython) f_a is not implemented!") + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython { + PyObject *(*f_h)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*Hk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch); + PyObject *(*Rk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*R_isrk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*dHk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*dRk)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch); + PyObject *(*reset)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args); +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + + +/* "GPy/models/state_space_cython.pyx":66 + * raise NotImplemented("(cython) reset is not implemented!") + * + * cdef class R_handling_Cython(Measurement_Callables_Cython): # <<<<<<<<<<<<<< + * """ + * The calss handles noise matrix R. + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython { + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_base; +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython; + + +/* "GPy/models/state_space_cython.pyx":165 + * + * + * cdef class Std_Measurement_Callables_Cython(R_handling_Cython): # <<<<<<<<<<<<<< + * + * cdef: + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython { + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_base; +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; + + +/* "GPy/models/state_space_cython.pyx":212 + * + * + * cdef class Q_handling_Cython(Dynamic_Callables_Cython): # <<<<<<<<<<<<<< + * + * cdef: + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython { + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_base; +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython; + + +/* "GPy/models/state_space_cython.pyx":318 + * return square_root + * + * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython): # <<<<<<<<<<<<<< + * cdef: + * np.ndarray A + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython { + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base; +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; + + +/* "GPy/models/state_space_cython.pyx":373 + * return self + * + * cdef class AQcompute_batch_Cython(Q_handling_Cython): # <<<<<<<<<<<<<< + * """ + * Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter + */ + +struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython { + struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_base; +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + +/* --- Runtime support code (head) --- */ +#ifndef CYTHON_REFNANNY + #define CYTHON_REFNANNY 0 +#endif +#if CYTHON_REFNANNY + typedef struct { + void (*INCREF)(void*, PyObject*, int); + void (*DECREF)(void*, PyObject*, int); + void (*GOTREF)(void*, PyObject*, int); + void (*GIVEREF)(void*, PyObject*, int); + void* (*SetupContext)(const char*, int, const char*); + void (*FinishContext)(void**); + } __Pyx_RefNannyAPIStruct; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL; + static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); + #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL; +#ifdef WITH_THREAD + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + if (acquire_gil) { \ + PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + PyGILState_Release(__pyx_gilstate_save); \ + } else { \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \ + } +#else + #define __Pyx_RefNannySetupContext(name, acquire_gil) \ + __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) +#endif + #define __Pyx_RefNannyFinishContext() \ + __Pyx_RefNanny->FinishContext(&__pyx_refnanny) + #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__) + #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0) + #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) + #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) + #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) +#else + #define __Pyx_RefNannyDeclarations + #define __Pyx_RefNannySetupContext(name, acquire_gil) + #define __Pyx_RefNannyFinishContext() + #define __Pyx_INCREF(r) Py_INCREF(r) + #define __Pyx_DECREF(r) Py_DECREF(r) + #define __Pyx_GOTREF(r) + #define __Pyx_GIVEREF(r) + #define __Pyx_XINCREF(r) Py_XINCREF(r) + #define __Pyx_XDECREF(r) Py_XDECREF(r) + #define __Pyx_XGOTREF(r) + #define __Pyx_XGIVEREF(r) +#endif +#define __Pyx_XDECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_XDECREF(tmp); \ + } while (0) +#define __Pyx_DECREF_SET(r, v) do { \ + PyObject *tmp = (PyObject *) r; \ + r = v; __Pyx_DECREF(tmp); \ + } while (0) +#define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0) +#define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0) + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_getattro)) + return tp->tp_getattro(obj, attr_name); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_getattr)) + return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); +#endif + return PyObject_GetAttr(obj, attr_name); +} +#else +#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name); + +static CYTHON_INLINE int __Pyx_GetBufferAndValidate(Py_buffer* buf, PyObject* obj, + __Pyx_TypeInfo* dtype, int flags, int nd, int cast, __Pyx_BufFmt_StackElem* stack); +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info); + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); +#else +#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw) +#endif + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); + +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); + +static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact, + Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); + +static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); + +static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ + PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ + const char* function_name); + +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact); + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg); +#endif + +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); + +static void __Pyx_RaiseBufferFallbackError(void); + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); + +static CYTHON_INLINE int __Pyx_IterFinish(void); + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); + +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); +} + +#if PY_MAJOR_VERSION >= 3 +static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { + PyObject *value; + value = PyDict_GetItemWithError(d, key); + if (unlikely(!value)) { + if (!PyErr_Occurred()) { + PyObject* args = PyTuple_Pack(1, key); + if (likely(args)) + PyErr_SetObject(PyExc_KeyError, args); + Py_XDECREF(args); + } + return NULL; + } + Py_INCREF(value); + return value; +} +#else + #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) +#endif + +#if CYTHON_COMPILING_IN_CPYTHON +#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL) +static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) { + PyTypeObject* tp = Py_TYPE(obj); + if (likely(tp->tp_setattro)) + return tp->tp_setattro(obj, attr_name, value); +#if PY_MAJOR_VERSION < 3 + if (likely(tp->tp_setattr)) + return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value); +#endif + return PyObject_SetAttr(obj, attr_name, value); +} +#else +#define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n) +#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v) +#endif + +#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \ + (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \ + __Pyx_GetItemInt_Generic(o, to_py_func(i)))) +#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \ + (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \ + __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \ + (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL)) +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j); +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck); + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void); + +static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse); + +static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc); + +static int __Pyx_SetVtable(PyObject *dict, void *vtable); + +typedef struct { + int code_line; + PyCodeObject* code_object; +} __Pyx_CodeObjectCacheEntry; +struct __Pyx_CodeObjectCache { + int count; + int max_count; + __Pyx_CodeObjectCacheEntry* entries; +}; +static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); +static PyCodeObject *__pyx_find_code_object(int code_line); +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); + +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename); + +typedef struct { + Py_ssize_t shape, strides, suboffsets; +} __Pyx_Buf_DimInfo; +typedef struct { + size_t refcount; + Py_buffer pybuffer; +} __Pyx_Buffer; +typedef struct { + __Pyx_Buffer *rcbuffer; + char *data; + __Pyx_Buf_DimInfo diminfo[8]; +} __Pyx_LocalBuf_ND; + +#if PY_MAJOR_VERSION < 3 + static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags); + static void __Pyx_ReleaseBuffer(Py_buffer *view); +#else + #define __Pyx_GetBuffer PyObject_GetBuffer + #define __Pyx_ReleaseBuffer PyBuffer_Release +#endif + + +static Py_ssize_t __Pyx_zeros[] = {0, 0, 0, 0, 0, 0, 0, 0}; +static Py_ssize_t __Pyx_minusones[] = {-1, -1, -1, -1, -1, -1, -1, -1}; + +static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); + +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); + +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value); + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + #define __Pyx_CREAL(z) ((z).real()) + #define __Pyx_CIMAG(z) ((z).imag()) + #else + #define __Pyx_CREAL(z) (__real__(z)) + #define __Pyx_CIMAG(z) (__imag__(z)) + #endif +#else + #define __Pyx_CREAL(z) ((z).real) + #define __Pyx_CIMAG(z) ((z).imag) +#endif +#if (defined(_WIN32) || defined(__clang__)) && defined(__cplusplus) && CYTHON_CCOMPLEX + #define __Pyx_SET_CREAL(z,x) ((z).real(x)) + #define __Pyx_SET_CIMAG(z,y) ((z).imag(y)) +#else + #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x) + #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y) +#endif + +static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eqf(a, b) ((a)==(b)) + #define __Pyx_c_sumf(a, b) ((a)+(b)) + #define __Pyx_c_difff(a, b) ((a)-(b)) + #define __Pyx_c_prodf(a, b) ((a)*(b)) + #define __Pyx_c_quotf(a, b) ((a)/(b)) + #define __Pyx_c_negf(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zerof(z) ((z)==(float)0) + #define __Pyx_c_conjf(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_absf(z) (::std::abs(z)) + #define __Pyx_c_powf(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zerof(z) ((z)==0) + #define __Pyx_c_conjf(z) (conjf(z)) + #if 1 + #define __Pyx_c_absf(z) (cabsf(z)) + #define __Pyx_c_powf(a, b) (cpowf(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex); + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex); + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex); + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex, __pyx_t_float_complex); + #endif +#endif + +static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double); + +#if CYTHON_CCOMPLEX + #define __Pyx_c_eq(a, b) ((a)==(b)) + #define __Pyx_c_sum(a, b) ((a)+(b)) + #define __Pyx_c_diff(a, b) ((a)-(b)) + #define __Pyx_c_prod(a, b) ((a)*(b)) + #define __Pyx_c_quot(a, b) ((a)/(b)) + #define __Pyx_c_neg(a) (-(a)) + #ifdef __cplusplus + #define __Pyx_c_is_zero(z) ((z)==(double)0) + #define __Pyx_c_conj(z) (::std::conj(z)) + #if 1 + #define __Pyx_c_abs(z) (::std::abs(z)) + #define __Pyx_c_pow(a, b) (::std::pow(a, b)) + #endif + #else + #define __Pyx_c_is_zero(z) ((z)==0) + #define __Pyx_c_conj(z) (conj(z)) + #if 1 + #define __Pyx_c_abs(z) (cabs(z)) + #define __Pyx_c_pow(a, b) (cpow(a, b)) + #endif + #endif +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex); + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex); + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex); + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex, __pyx_t_double_complex); + #endif +#endif + +static int __Pyx_check_binary_version(void); + +#if !defined(__Pyx_PyIdentifier_FromString) +#if PY_MAJOR_VERSION < 3 + #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s) +#else + #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s) +#endif +#endif + +static PyObject *__Pyx_ImportModule(const char *name); + +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); + +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_Hk, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset *__pyx_optional_args); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch); /* proto*/ + +/* Module declarations from 'cpython.buffer' */ + +/* Module declarations from 'cpython.ref' */ + +/* Module declarations from 'libc.string' */ + +/* Module declarations from 'libc.stdio' */ + +/* Module declarations from 'cpython.object' */ + +/* Module declarations from '__builtin__' */ + +/* Module declarations from 'cpython.type' */ +static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0; + +/* Module declarations from 'libc.stdlib' */ + +/* Module declarations from 'numpy' */ + +/* Module declarations from 'numpy' */ +static PyTypeObject *__pyx_ptype_5numpy_dtype = 0; +static PyTypeObject *__pyx_ptype_5numpy_flatiter = 0; +static PyTypeObject *__pyx_ptype_5numpy_broadcast = 0; +static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0; +static PyTypeObject *__pyx_ptype_5numpy_ufunc = 0; +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *, int *); /*proto*/ + +/* Module declarations from 'cython' */ + +/* Module declarations from 'GPy.models.state_space_cython' */ +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = 0; +static PyTypeObject *__pyx_ptype_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = 0; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t = { "DTYPE_t", NULL, sizeof(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_t), { 0 }, 0, 'R', 0, 0 }; +static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t = { "DTYPE_int_t", NULL, sizeof(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t), { 0 }, 0, IS_UNSIGNED(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t) ? 'U' : 'I', IS_UNSIGNED(__pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t), 0 }; +#define __Pyx_MODULE_NAME "GPy.models.state_space_cython" +int __pyx_module_is_main_GPy__models__state_space_cython = 0; + +/* Implementation of 'GPy.models.state_space_cython' */ +static PyObject *__pyx_builtin_NotImplemented; +static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_super; +static PyObject *__pyx_builtin_range; +static PyObject *__pyx_builtin_RuntimeError; +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_Hk); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v_compute_derivatives); /* proto */ +static int __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_p_unique_R_number, PyArrayObject *__pyx_v_dR); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static int __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_H, int __pyx_v_H_time_var_index, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_unique_R_number, PyArrayObject *__pyx_v_dH, PyArrayObject *__pyx_v_dR); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static int __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_p_unique_Q_number, PyArrayObject *__pyx_v_dQ); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static int __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_A, int __pyx_v_A_time_var_index, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_unique_Q_number, PyArrayObject *__pyx_v_dA, PyArrayObject *__pyx_v_dQ); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */ +static int __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyArrayObject *__pyx_v_As, PyArrayObject *__pyx_v_Qs, PyArrayObject *__pyx_v_reconstruct_indices, PyArrayObject *__pyx_v_dAs, PyArrayObject *__pyx_v_dQs); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_compute_derivatives); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, PyArrayObject *__pyx_v_measurement, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP); /* proto */ +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_state_dim, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, CYTHON_UNUSED PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyArrayObject *__pyx_v_m_init, PyArrayObject *__pyx_v_P_init, CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, int __pyx_v_grad_params_no, PyArrayObject *__pyx_v_dm_init, PyArrayObject *__pyx_v_dP_init); /* proto */ +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ +static char __pyx_k_A[] = "A"; +static char __pyx_k_B[] = "B"; +static char __pyx_k_H[] = "H"; +static char __pyx_k_I[] = "I"; +static char __pyx_k_K[] = "K"; +static char __pyx_k_L[] = "L"; +static char __pyx_k_M[] = "M"; +static char __pyx_k_O[] = "O"; +static char __pyx_k_P[] = "P"; +static char __pyx_k_Q[] = "Q"; +static char __pyx_k_R[] = "R"; +static char __pyx_k_S[] = "S"; +static char __pyx_k_T[] = "T"; +static char __pyx_k_U[] = "U"; +static char __pyx_k_X[] = "X"; +static char __pyx_k_Y[] = "Y"; +static char __pyx_k_b[] = "b"; +static char __pyx_k_d[] = "d"; +static char __pyx_k_f[] = "f"; +static char __pyx_k_g[] = "g"; +static char __pyx_k_h[] = "h"; +static char __pyx_k_i[] = "i"; +static char __pyx_k_j[] = "j"; +static char __pyx_k_k[] = "k"; +static char __pyx_k_l[] = "l"; +static char __pyx_k_m[] = "m"; +static char __pyx_k_q[] = "q"; +static char __pyx_k_v[] = "v"; +static char __pyx_k_Ak[] = "Ak"; +static char __pyx_k_As[] = "As"; +static char __pyx_k_Hk[] = "Hk"; +static char __pyx_k_Qk[] = "Qk"; +static char __pyx_k_Qs[] = "Qs"; +static char __pyx_k_Rk[] = "Rk"; +static char __pyx_k_Vh[] = "Vh"; +static char __pyx_k_Zd[] = "Zd"; +static char __pyx_k_Zf[] = "Zf"; +static char __pyx_k_Zg[] = "Zg"; +static char __pyx_k_dA[] = "dA"; +static char __pyx_k_dH[] = "dH"; +static char __pyx_k_dK[] = "dK"; +static char __pyx_k_dQ[] = "dQ"; +static char __pyx_k_dR[] = "dR"; +static char __pyx_k_dS[] = "dS"; +static char __pyx_k_dv[] = "dv"; +static char __pyx_k_np[] = "np"; +static char __pyx_k_pi[] = "pi"; +static char __pyx_k_sp[] = "sp"; +static char __pyx_k_all[] = "all"; +static char __pyx_k_any[] = "any"; +static char __pyx_k_dAk[] = "dAk"; +static char __pyx_k_dAs[] = "dAs"; +static char __pyx_k_dHk[] = "dHk"; +static char __pyx_k_dQk[] = "dQk"; +static char __pyx_k_dQs[] = "dQs"; +static char __pyx_k_dRk[] = "dRk"; +static char __pyx_k_dot[] = "dot"; +static char __pyx_k_f_a[] = "f_a"; +static char __pyx_k_f_h[] = "f_h"; +static char __pyx_k_log[] = "log"; +static char __pyx_k_p_P[] = "p_P"; +static char __pyx_k_p_m[] = "p_m"; +static char __pyx_k_res[] = "res"; +static char __pyx_k_ret[] = "ret"; +static char __pyx_k_sum[] = "sum"; +static char __pyx_k_svd[] = "svd"; +static char __pyx_k_Q_sr[] = "Q_sr"; +static char __pyx_k_axis[] = "axis"; +static char __pyx_k_diag[] = "diag"; +static char __pyx_k_init[] = "__init__"; +static char __pyx_k_main[] = "__main__"; +static char __pyx_k_p_dP[] = "p_dP"; +static char __pyx_k_p_dm[] = "p_dm"; +static char __pyx_k_sqrt[] = "sqrt"; +static char __pyx_k_test[] = "__test__"; +static char __pyx_k_tmp1[] = "tmp1"; +static char __pyx_k_tmp2[] = "tmp2"; +static char __pyx_k_tmp3[] = "tmp3"; +static char __pyx_k_tmp5[] = "tmp5"; +static char __pyx_k_DTYPE[] = "DTYPE"; +static char __pyx_k_P_upd[] = "P_upd"; +static char __pyx_k_Q_srk[] = "Q_srk"; +static char __pyx_k_R_isr[] = "R_isr"; +static char __pyx_k_S_new[] = "S_new"; +static char __pyx_k_S_old[] = "S_old"; +static char __pyx_k_S_svd[] = "S_svd"; +static char __pyx_k_S_upd[] = "S_upd"; +static char __pyx_k_U_upd[] = "U_upd"; +static char __pyx_k_V_new[] = "V_new"; +static char __pyx_k_V_old[] = "V_old"; +static char __pyx_k_dtype[] = "dtype"; +static char __pyx_k_empty[] = "empty"; +static char __pyx_k_index[] = "index"; +static char __pyx_k_int64[] = "int64"; +static char __pyx_k_isnan[] = "isnan"; +static char __pyx_k_m_upd[] = "m_upd"; +static char __pyx_k_numpy[] = "numpy"; +static char __pyx_k_param[] = "param"; +static char __pyx_k_range[] = "range"; +static char __pyx_k_reset[] = "reset"; +static char __pyx_k_scipy[] = "scipy"; +static char __pyx_k_shape[] = "shape"; +static char __pyx_k_super[] = "super"; +static char __pyx_k_zeros[] = "zeros"; +static char __pyx_k_P_init[] = "P_init"; +static char __pyx_k_P_pred[] = "P_pred"; +static char __pyx_k_R_isrk[] = "R_isrk"; +static char __pyx_k_S_pred[] = "S_pred"; +static char __pyx_k_V_pred[] = "V_pred"; +static char __pyx_k_dP_upd[] = "dP_upd"; +static char __pyx_k_dm_upd[] = "dm_upd"; +static char __pyx_k_import[] = "__import__"; +static char __pyx_k_linalg[] = "linalg"; +static char __pyx_k_m_init[] = "m_init"; +static char __pyx_k_m_pred[] = "m_pred"; +static char __pyx_k_nbytes[] = "nbytes"; +static char __pyx_k_unique[] = "unique"; +static char __pyx_k_vstack[] = "vstack"; +static char __pyx_k_dP_init[] = "dP_init"; +static char __pyx_k_dP_pred[] = "dP_pred"; +static char __pyx_k_dm_init[] = "dm_init"; +static char __pyx_k_dm_pred[] = "dm_pred"; +static char __pyx_k_float64[] = "float64"; +static char __pyx_k_regular[] = "regular"; +static char __pyx_k_Prev_cov[] = "Prev_cov"; +static char __pyx_k_steps_no[] = "steps_no"; +static char __pyx_k_DTYPE_int[] = "DTYPE_int"; +static char __pyx_k_prev_mean[] = "prev_mean"; +static char __pyx_k_state_dim[] = "state_dim"; +static char __pyx_k_ValueError[] = "ValueError"; +static char __pyx_k_compute_uv[] = "compute_uv"; +static char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; +static char __pyx_k_svd_1_matr[] = "svd_1_matr"; +static char __pyx_k_svd_2_matr[] = "svd_2_matr"; +static char __pyx_k_measurement[] = "measurement"; +static char __pyx_k_overwrite_a[] = "overwrite_a"; +static char __pyx_k_RuntimeError[] = "RuntimeError"; +static char __pyx_k_check_finite[] = "check_finite"; +static char __pyx_k_k_measurment[] = "k_measurment"; +static char __pyx_k_param_number[] = "param_number"; +static char __pyx_k_dA_all_params[] = "dA_all_params"; +static char __pyx_k_dH_all_params[] = "dH_all_params"; +static char __pyx_k_dQ_all_params[] = "dQ_all_params"; +static char __pyx_k_dR_all_params[] = "dR_all_params"; +static char __pyx_k_full_matrices[] = "full_matrices"; +static char __pyx_k_NotImplemented[] = "NotImplemented"; +static char __pyx_k_grad_params_no[] = "grad_params_no"; +static char __pyx_k_log_likelihood[] = "log_likelihood"; +static char __pyx_k_time_series_no[] = "time_series_no"; +static char __pyx_k_unique_Q_number[] = "unique_Q_number"; +static char __pyx_k_unique_R_number[] = "unique_R_number"; +static char __pyx_k_A_time_var_index[] = "A_time_var_index"; +static char __pyx_k_H_time_var_index[] = "H_time_var_index"; +static char __pyx_k_Q_time_var_index[] = "Q_time_var_index"; +static char __pyx_k_R_time_var_index[] = "R_time_var_index"; +static char __pyx_k_p_unique_Q_number[] = "p_unique_Q_number"; +static char __pyx_k_p_unique_R_number[] = "p_unique_R_number"; +static char __pyx_k_dP_pred_all_params[] = "dP_pred_all_params"; +static char __pyx_k_dm_pred_all_params[] = "dm_pred_all_params"; +static char __pyx_k_total_size_of_data[] = "total_size_of_data"; +static char __pyx_k_calc_log_likelihood[] = "calc_log_likelihood"; +static char __pyx_k_compute_derivatives[] = "compute_derivatives"; +static char __pyx_k_grad_log_likelihood[] = "grad_log_likelihood"; +static char __pyx_k_p_dynamic_callables[] = "p_dynamic_callables"; +static char __pyx_k_reconstruct_indices[] = "reconstruct_indices"; +static char __pyx_k_p_kalman_filter_type[] = "p_kalman_filter_type"; +static char __pyx_k_dA_derivative_is_None[] = "dA derivative is None"; +static char __pyx_k_dH_derivative_is_None[] = "dH derivative is None"; +static char __pyx_k_dQ_derivative_is_None[] = "dQ derivative is None"; +static char __pyx_k_dR_derivative_is_None[] = "dR derivative is None"; +static char __pyx_k_log_likelihood_update[] = "log_likelihood_update"; +static char __pyx_k_measurement_dim_gt_one[] = "measurement_dim_gt_one"; +static char __pyx_k_d_log_likelihood_update[] = "d_log_likelihood_update"; +static char __pyx_k_p_measurement_callables[] = "p_measurement_callables"; +static char __pyx_k_calc_grad_log_likelihood[] = "calc_grad_log_likelihood"; +static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; +static char __pyx_k_cython_Ak_is_not_implemented[] = "(cython) Ak is not implemented!"; +static char __pyx_k_cython_Hk_is_not_implemented[] = "(cython) Hk is not implemented!"; +static char __pyx_k_cython_Qk_is_not_implemented[] = "(cython) Qk is not implemented!"; +static char __pyx_k_cython_Rk_is_not_implemented[] = "(cython) Rk is not implemented!"; +static char __pyx_k_GPy_models_state_space_cython[] = "GPy.models.state_space_cython"; +static char __pyx_k_cython_dAk_is_not_implemented[] = "(cython) dAk is not implemented!"; +static char __pyx_k_cython_dQk_is_not_implemented[] = "(cython) dQk is not implemented!"; +static char __pyx_k_cython_f_a_is_not_implemented[] = "(cython) f_a is not implemented!"; +static char __pyx_k_kalman_update_step_SVD_Cython[] = "_kalman_update_step_SVD_Cython"; +static char __pyx_k_Contains_some_cython_code_for_s[] = "\nContains some cython code for state space modelling.\n"; +static char __pyx_k_Nan_values_in_likelihood_update[] = "Nan values in likelihood update!"; +static char __pyx_k_cont_discr_kalman_filter_raw_Cy[] = "_cont_discr_kalman_filter_raw_Cython"; +static char __pyx_k_cython_Q_srk_is_not_implemented[] = "(cython) Q_srk is not implemented!"; +static char __pyx_k_cython_reset_is_not_implemented[] = "(cython) reset is not implemented!"; +static char __pyx_k_kalman_prediction_step_SVD_Cyth[] = "_kalman_prediction_step_SVD_Cython"; +static char __pyx_k_unknown_dtype_code_in_numpy_pxd[] = "unknown dtype code in numpy.pxd (%d)"; +static char __pyx_k_users_agrigori_SpiderOak_sp_hiv[] = "/users/agrigori/SpiderOak/sp_hive/Programming/python/GPy/GPy/models/state_space_cython.pyx"; +static char __pyx_k_Format_string_allocated_too_shor[] = "Format string allocated too short, see comment in numpy.pxd"; +static char __pyx_k_Kalman_Filter_Update_SVD_S_is_ne[] = "Kalman Filter Update SVD: S is negative step %i"; +static char __pyx_k_Measurement_dimension_larger_the[] = "Measurement dimension larger then 1 is currently not supported"; +static char __pyx_k_Nan_measurements_are_currently_n[] = "Nan measurements are currently not supported if\n they are intermixed with not NaN measurements"; +static char __pyx_k_Non_native_byte_order_not_suppor[] = "Non-native byte order not supported"; +static char __pyx_k_ndarray_is_not_Fortran_contiguou[] = "ndarray is not Fortran contiguous"; +static char __pyx_k_Format_string_allocated_too_shor_2[] = "Format string allocated too short."; +static PyObject *__pyx_n_s_A; +static PyObject *__pyx_n_s_A_time_var_index; +static PyObject *__pyx_n_s_Ak; +static PyObject *__pyx_n_s_As; +static PyObject *__pyx_n_s_DTYPE; +static PyObject *__pyx_n_s_DTYPE_int; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor; +static PyObject *__pyx_kp_u_Format_string_allocated_too_shor_2; +static PyObject *__pyx_n_s_GPy_models_state_space_cython; +static PyObject *__pyx_n_s_H; +static PyObject *__pyx_n_s_H_time_var_index; +static PyObject *__pyx_n_s_Hk; +static PyObject *__pyx_n_s_K; +static PyObject *__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne; +static PyObject *__pyx_n_s_M; +static PyObject *__pyx_kp_s_Measurement_dimension_larger_the; +static PyObject *__pyx_kp_s_Nan_measurements_are_currently_n; +static PyObject *__pyx_kp_s_Nan_values_in_likelihood_update; +static PyObject *__pyx_kp_u_Non_native_byte_order_not_suppor; +static PyObject *__pyx_n_s_NotImplemented; +static PyObject *__pyx_n_s_P; +static PyObject *__pyx_n_s_P_init; +static PyObject *__pyx_n_s_P_pred; +static PyObject *__pyx_n_s_P_upd; +static PyObject *__pyx_n_s_Prev_cov; +static PyObject *__pyx_n_s_Q; +static PyObject *__pyx_n_s_Q_sr; +static PyObject *__pyx_n_s_Q_srk; +static PyObject *__pyx_n_s_Q_time_var_index; +static PyObject *__pyx_n_s_Qk; +static PyObject *__pyx_n_s_Qs; +static PyObject *__pyx_n_s_R; +static PyObject *__pyx_n_s_R_isr; +static PyObject *__pyx_n_s_R_isrk; +static PyObject *__pyx_n_s_R_time_var_index; +static PyObject *__pyx_n_s_Rk; +static PyObject *__pyx_n_s_RuntimeError; +static PyObject *__pyx_n_s_S; +static PyObject *__pyx_n_s_S_new; +static PyObject *__pyx_n_s_S_old; +static PyObject *__pyx_n_s_S_pred; +static PyObject *__pyx_n_s_S_svd; +static PyObject *__pyx_n_s_S_upd; +static PyObject *__pyx_n_s_T; +static PyObject *__pyx_n_s_U; +static PyObject *__pyx_n_s_U_upd; +static PyObject *__pyx_n_s_V_new; +static PyObject *__pyx_n_s_V_old; +static PyObject *__pyx_n_s_V_pred; +static PyObject *__pyx_n_s_ValueError; +static PyObject *__pyx_n_s_Vh; +static PyObject *__pyx_n_s_X; +static PyObject *__pyx_n_s_Y; +static PyObject *__pyx_n_s_all; +static PyObject *__pyx_n_s_any; +static PyObject *__pyx_n_s_axis; +static PyObject *__pyx_n_s_calc_grad_log_likelihood; +static PyObject *__pyx_n_s_calc_log_likelihood; +static PyObject *__pyx_n_s_check_finite; +static PyObject *__pyx_n_s_compute_derivatives; +static PyObject *__pyx_n_s_compute_uv; +static PyObject *__pyx_n_s_cont_discr_kalman_filter_raw_Cy; +static PyObject *__pyx_kp_s_cython_Ak_is_not_implemented; +static PyObject *__pyx_kp_s_cython_Hk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_Q_srk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_Qk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_Rk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_dAk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_dQk_is_not_implemented; +static PyObject *__pyx_kp_s_cython_f_a_is_not_implemented; +static PyObject *__pyx_kp_s_cython_reset_is_not_implemented; +static PyObject *__pyx_n_s_dA; +static PyObject *__pyx_n_s_dA_all_params; +static PyObject *__pyx_kp_s_dA_derivative_is_None; +static PyObject *__pyx_n_s_dAk; +static PyObject *__pyx_n_s_dAs; +static PyObject *__pyx_n_s_dH; +static PyObject *__pyx_n_s_dH_all_params; +static PyObject *__pyx_kp_s_dH_derivative_is_None; +static PyObject *__pyx_n_s_dHk; +static PyObject *__pyx_n_s_dK; +static PyObject *__pyx_n_s_dP_init; +static PyObject *__pyx_n_s_dP_pred; +static PyObject *__pyx_n_s_dP_pred_all_params; +static PyObject *__pyx_n_s_dP_upd; +static PyObject *__pyx_n_s_dQ; +static PyObject *__pyx_n_s_dQ_all_params; +static PyObject *__pyx_kp_s_dQ_derivative_is_None; +static PyObject *__pyx_n_s_dQk; +static PyObject *__pyx_n_s_dQs; +static PyObject *__pyx_n_s_dR; +static PyObject *__pyx_n_s_dR_all_params; +static PyObject *__pyx_kp_s_dR_derivative_is_None; +static PyObject *__pyx_n_s_dRk; +static PyObject *__pyx_n_s_dS; +static PyObject *__pyx_n_s_d_log_likelihood_update; +static PyObject *__pyx_n_s_diag; +static PyObject *__pyx_n_s_dm_init; +static PyObject *__pyx_n_s_dm_pred; +static PyObject *__pyx_n_s_dm_pred_all_params; +static PyObject *__pyx_n_s_dm_upd; +static PyObject *__pyx_n_s_dot; +static PyObject *__pyx_n_s_dtype; +static PyObject *__pyx_n_s_dv; +static PyObject *__pyx_n_s_empty; +static PyObject *__pyx_n_s_f_a; +static PyObject *__pyx_n_s_f_h; +static PyObject *__pyx_n_s_float64; +static PyObject *__pyx_n_s_full_matrices; +static PyObject *__pyx_n_s_grad_log_likelihood; +static PyObject *__pyx_n_s_grad_params_no; +static PyObject *__pyx_n_s_import; +static PyObject *__pyx_n_s_index; +static PyObject *__pyx_n_s_init; +static PyObject *__pyx_n_s_int64; +static PyObject *__pyx_n_s_isnan; +static PyObject *__pyx_n_s_j; +static PyObject *__pyx_n_s_k; +static PyObject *__pyx_n_s_k_measurment; +static PyObject *__pyx_n_s_kalman_prediction_step_SVD_Cyth; +static PyObject *__pyx_n_s_kalman_update_step_SVD_Cython; +static PyObject *__pyx_n_s_linalg; +static PyObject *__pyx_n_s_log; +static PyObject *__pyx_n_s_log_likelihood; +static PyObject *__pyx_n_s_log_likelihood_update; +static PyObject *__pyx_n_s_m; +static PyObject *__pyx_n_s_m_init; +static PyObject *__pyx_n_s_m_pred; +static PyObject *__pyx_n_s_m_upd; +static PyObject *__pyx_n_s_main; +static PyObject *__pyx_n_s_measurement; +static PyObject *__pyx_n_s_measurement_dim_gt_one; +static PyObject *__pyx_n_s_nbytes; +static PyObject *__pyx_kp_u_ndarray_is_not_C_contiguous; +static PyObject *__pyx_kp_u_ndarray_is_not_Fortran_contiguou; +static PyObject *__pyx_n_s_np; +static PyObject *__pyx_n_s_numpy; +static PyObject *__pyx_n_s_overwrite_a; +static PyObject *__pyx_n_s_p_P; +static PyObject *__pyx_n_s_p_dP; +static PyObject *__pyx_n_s_p_dm; +static PyObject *__pyx_n_s_p_dynamic_callables; +static PyObject *__pyx_n_s_p_kalman_filter_type; +static PyObject *__pyx_n_s_p_m; +static PyObject *__pyx_n_s_p_measurement_callables; +static PyObject *__pyx_n_s_p_unique_Q_number; +static PyObject *__pyx_n_s_p_unique_R_number; +static PyObject *__pyx_n_s_param; +static PyObject *__pyx_n_s_param_number; +static PyObject *__pyx_n_s_pi; +static PyObject *__pyx_n_s_prev_mean; +static PyObject *__pyx_n_s_pyx_vtable; +static PyObject *__pyx_n_s_range; +static PyObject *__pyx_n_s_reconstruct_indices; +static PyObject *__pyx_n_s_regular; +static PyObject *__pyx_n_s_res; +static PyObject *__pyx_n_s_reset; +static PyObject *__pyx_n_s_ret; +static PyObject *__pyx_n_s_scipy; +static PyObject *__pyx_n_s_shape; +static PyObject *__pyx_n_s_sp; +static PyObject *__pyx_n_s_sqrt; +static PyObject *__pyx_n_s_state_dim; +static PyObject *__pyx_n_s_steps_no; +static PyObject *__pyx_n_s_sum; +static PyObject *__pyx_n_s_super; +static PyObject *__pyx_n_s_svd; +static PyObject *__pyx_n_s_svd_1_matr; +static PyObject *__pyx_n_s_svd_2_matr; +static PyObject *__pyx_n_s_test; +static PyObject *__pyx_n_s_time_series_no; +static PyObject *__pyx_n_s_tmp1; +static PyObject *__pyx_n_s_tmp2; +static PyObject *__pyx_n_s_tmp3; +static PyObject *__pyx_n_s_tmp5; +static PyObject *__pyx_n_s_total_size_of_data; +static PyObject *__pyx_n_s_unique; +static PyObject *__pyx_n_s_unique_Q_number; +static PyObject *__pyx_n_s_unique_R_number; +static PyObject *__pyx_kp_u_unknown_dtype_code_in_numpy_pxd; +static PyObject *__pyx_kp_s_users_agrigori_SpiderOak_sp_hiv; +static PyObject *__pyx_n_s_v; +static PyObject *__pyx_n_s_vstack; +static PyObject *__pyx_n_s_zeros; +static PyObject *__pyx_float_0_5; +static PyObject *__pyx_float_1_0; +static PyObject *__pyx_float_1eneg_17; +static PyObject *__pyx_float_neg_0_5; +static PyObject *__pyx_int_0; +static PyObject *__pyx_int_1; +static PyObject *__pyx_int_2; +static PyObject *__pyx_tuple_; +static PyObject *__pyx_tuple__2; +static PyObject *__pyx_tuple__3; +static PyObject *__pyx_tuple__4; +static PyObject *__pyx_tuple__5; +static PyObject *__pyx_tuple__6; +static PyObject *__pyx_tuple__7; +static PyObject *__pyx_tuple__8; +static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__15; +static PyObject *__pyx_slice__16; +static PyObject *__pyx_slice__18; +static PyObject *__pyx_slice__19; +static PyObject *__pyx_slice__20; +static PyObject *__pyx_slice__21; +static PyObject *__pyx_slice__23; +static PyObject *__pyx_slice__24; +static PyObject *__pyx_slice__26; +static PyObject *__pyx_slice__27; +static PyObject *__pyx_slice__28; +static PyObject *__pyx_slice__29; +static PyObject *__pyx_slice__31; +static PyObject *__pyx_slice__32; +static PyObject *__pyx_slice__33; +static PyObject *__pyx_slice__34; +static PyObject *__pyx_slice__35; +static PyObject *__pyx_slice__36; +static PyObject *__pyx_slice__37; +static PyObject *__pyx_slice__38; +static PyObject *__pyx_slice__39; +static PyObject *__pyx_slice__40; +static PyObject *__pyx_slice__41; +static PyObject *__pyx_slice__42; +static PyObject *__pyx_slice__43; +static PyObject *__pyx_slice__44; +static PyObject *__pyx_slice__45; +static PyObject *__pyx_slice__46; +static PyObject *__pyx_slice__47; +static PyObject *__pyx_slice__48; +static PyObject *__pyx_slice__49; +static PyObject *__pyx_slice__50; +static PyObject *__pyx_slice__51; +static PyObject *__pyx_slice__52; +static PyObject *__pyx_slice__53; +static PyObject *__pyx_slice__54; +static PyObject *__pyx_slice__55; +static PyObject *__pyx_slice__56; +static PyObject *__pyx_slice__57; +static PyObject *__pyx_slice__58; +static PyObject *__pyx_slice__59; +static PyObject *__pyx_slice__60; +static PyObject *__pyx_slice__61; +static PyObject *__pyx_slice__62; +static PyObject *__pyx_slice__63; +static PyObject *__pyx_slice__64; +static PyObject *__pyx_slice__65; +static PyObject *__pyx_slice__66; +static PyObject *__pyx_slice__69; +static PyObject *__pyx_slice__70; +static PyObject *__pyx_slice__71; +static PyObject *__pyx_slice__72; +static PyObject *__pyx_slice__73; +static PyObject *__pyx_slice__74; +static PyObject *__pyx_slice__75; +static PyObject *__pyx_slice__76; +static PyObject *__pyx_slice__77; +static PyObject *__pyx_slice__78; +static PyObject *__pyx_slice__79; +static PyObject *__pyx_slice__80; +static PyObject *__pyx_slice__81; +static PyObject *__pyx_slice__82; +static PyObject *__pyx_slice__83; +static PyObject *__pyx_slice__84; +static PyObject *__pyx_slice__85; +static PyObject *__pyx_slice__86; +static PyObject *__pyx_slice__87; +static PyObject *__pyx_slice__88; +static PyObject *__pyx_slice__89; +static PyObject *__pyx_slice__90; +static PyObject *__pyx_slice__91; +static PyObject *__pyx_slice__92; +static PyObject *__pyx_slice__93; +static PyObject *__pyx_slice__94; +static PyObject *__pyx_slice__95; +static PyObject *__pyx_slice__97; +static PyObject *__pyx_slice__98; +static PyObject *__pyx_tuple__10; +static PyObject *__pyx_tuple__11; +static PyObject *__pyx_tuple__12; +static PyObject *__pyx_tuple__13; +static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__17; +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__25; +static PyObject *__pyx_tuple__30; +static PyObject *__pyx_tuple__67; +static PyObject *__pyx_tuple__68; +static PyObject *__pyx_tuple__96; +static PyObject *__pyx_tuple__99; +static PyObject *__pyx_slice__100; +static PyObject *__pyx_slice__101; +static PyObject *__pyx_slice__102; +static PyObject *__pyx_slice__103; +static PyObject *__pyx_slice__105; +static PyObject *__pyx_slice__106; +static PyObject *__pyx_slice__107; +static PyObject *__pyx_slice__108; +static PyObject *__pyx_tuple__104; +static PyObject *__pyx_tuple__109; +static PyObject *__pyx_tuple__110; +static PyObject *__pyx_tuple__111; +static PyObject *__pyx_tuple__112; +static PyObject *__pyx_tuple__113; +static PyObject *__pyx_tuple__114; +static PyObject *__pyx_tuple__115; +static PyObject *__pyx_tuple__117; +static PyObject *__pyx_tuple__119; +static PyObject *__pyx_codeobj__116; +static PyObject *__pyx_codeobj__118; +static PyObject *__pyx_codeobj__120; + +/* "GPy/models/state_space_cython.pyx":22 + * # Template class for dynamic callables + * cdef class Dynamic_Callables_Cython: + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) f_a is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); 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); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); 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_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":23 + * cdef class Dynamic_Callables_Cython: + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + * raise NotImplemented("(cython) f_a is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple_, 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_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":22 + * # Template class for dynamic callables + * cdef class Dynamic_Callables_Cython: + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) f_a is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_A = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("f_a (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_A = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_A); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a(__pyx_v_self, __pyx_v_k, __pyx_v_m, __pyx_v_A, 1); 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_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":25 + * raise NotImplemented("(cython) f_a is not implemented!") + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Ak is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P; + __Pyx_Buffer __pyx_pybuffer_P; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_P.pybuffer.buf = NULL; + __pyx_pybuffer_P.refcount = 0; + __pyx_pybuffernd_P.data = NULL; + __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_P)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":26 + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix + * raise NotImplemented("(cython) Ak is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Qk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":25 + * raise NotImplemented("(cython) f_a is not implemented!") + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Ak is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_P = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Ak (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_P,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_P = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P), __pyx_ptype_5numpy_ndarray, 1, "P", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_P); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_2Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P; + __Pyx_Buffer __pyx_pybuffer_P; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_P.pybuffer.buf = NULL; + __pyx_pybuffer_P.refcount = 0; + __pyx_pybuffernd_P.data = NULL; + __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak(__pyx_v_self, __pyx_v_k, __pyx_v_m, __pyx_v_P, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":28 + * raise NotImplemented("(cython) Ak is not implemented!") + * + * cpdef Qk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Qk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":29 + * + * cpdef Qk(self, int k): + * raise NotImplemented("(cython) Qk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Q_srk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":28 + * raise NotImplemented("(cython) Ak is not implemented!") + * + * cpdef Qk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Qk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Qk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_4Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":31 + * raise NotImplemented("(cython) Qk is not implemented!") + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":32 + * + * cpdef Q_srk(self, int k): + * raise NotImplemented("(cython) Q_srk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":31 + * raise NotImplemented("(cython) Qk is not implemented!") + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Q_srk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":34 + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dAk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":35 + * + * cpdef dAk(self, int k): + * raise NotImplemented("(cython) dAk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__5, 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_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":34 + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dAk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dAk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_8dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":37 + * raise NotImplemented("(cython) dAk is not implemented!") + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dQk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); 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); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); 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_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":38 + * + * cpdef dQk(self, int k): + * raise NotImplemented("(cython) dQk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef reset(self, bint compute_derivatives = False): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__6, NULL); 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_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":37 + * raise NotImplemented("(cython) dAk is not implemented!") + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dQk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dQk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_10dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk(__pyx_v_self, __pyx_v_k, 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_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":40 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self, bint compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args) { + int __pyx_v_compute_derivatives = ((int)0); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":41 + * + * cpdef reset(self, bint compute_derivatives = False): + * raise NotImplemented("(cython) reset is not implemented!") # <<<<<<<<<<<<<< + * + * # Template class for measurement callables + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":40 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self, bint compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_compute_derivatives; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compute_derivatives); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_compute_derivatives = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives; + __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->reset(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":45 + * # Template class for measurement callables + * cdef class Measurement_Callables_Cython: + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) f_a is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_Hk, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_Hk; + __Pyx_Buffer __pyx_pybuffer_Hk; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_h", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_Hk.pybuffer.buf = NULL; + __pyx_pybuffer_Hk.refcount = 0; + __pyx_pybuffernd_Hk.data = NULL; + __pyx_pybuffernd_Hk.rcbuffer = &__pyx_pybuffer_Hk; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer, (PyObject*)__pyx_v_Hk, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_Hk.diminfo[0].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Hk.diminfo[0].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Hk.diminfo[1].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Hk.diminfo[1].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_h); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_Hk)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_Hk)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Hk)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":46 + * cdef class Measurement_Callables_Cython: + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): + * raise NotImplemented("(cython) f_a is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__8, NULL); 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); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":45 + * # Template class for measurement callables + * cdef class Measurement_Callables_Cython: + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) f_a is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_Hk = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("f_h (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_Hk,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Hk)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_h") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m_pred = ((PyArrayObject *)values[1]); + __pyx_v_Hk = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Hk), __pyx_ptype_5numpy_ndarray, 1, "Hk", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_Hk); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_Hk) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_Hk; + __Pyx_Buffer __pyx_pybuffer_Hk; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_h", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_Hk.pybuffer.buf = NULL; + __pyx_pybuffer_Hk.refcount = 0; + __pyx_pybuffernd_Hk.data = NULL; + __pyx_pybuffernd_Hk.rcbuffer = &__pyx_pybuffer_Hk; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer, (PyObject*)__pyx_v_Hk, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_Hk.diminfo[0].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Hk.diminfo[0].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Hk.diminfo[1].strides = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Hk.diminfo[1].shape = __pyx_pybuffernd_Hk.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h(__pyx_v_self, __pyx_v_k, __pyx_v_m_pred, __pyx_v_Hk, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Hk.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":48 + * raise NotImplemented("(cython) f_a is not implemented!") + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Hk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Hk", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Hk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":49 + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + * raise NotImplemented("(cython) Hk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Rk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":48 + * raise NotImplemented("(cython) f_a is not implemented!") + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Hk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_P_pred = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Hk (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Hk") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m_pred = ((PyArrayObject *)values[1]); + __pyx_v_P_pred = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_2Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Hk", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk(__pyx_v_self, __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":51 + * raise NotImplemented("(cython) Hk is not implemented!") + * + * cpdef Rk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Rk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Rk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Rk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":52 + * + * cpdef Rk(self, int k): + * raise NotImplemented("(cython) Rk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef R_isrk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":51 + * raise NotImplemented("(cython) Hk is not implemented!") + * + * cpdef Rk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Rk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Rk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_4Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Rk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":54 + * raise NotImplemented("(cython) Rk is not implemented!") + * + * cpdef R_isrk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("R_isrk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_R_isrk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":55 + * + * cpdef R_isrk(self, int k): + * raise NotImplemented("(cython) Q_srk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dHk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":54 + * raise NotImplemented("(cython) Rk is not implemented!") + * + * cpdef R_isrk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("R_isrk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("R_isrk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":57 + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + * cpdef dHk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dAk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dHk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dHk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":58 + * + * cpdef dHk(self, int k): + * raise NotImplemented("(cython) dAk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dRk(self, int k): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":57 + * raise NotImplemented("(cython) Q_srk is not implemented!") + * + * cpdef dHk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dAk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dHk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_8dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dHk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":60 + * raise NotImplemented("(cython) dAk is not implemented!") + * + * cpdef dRk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dQk is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dRk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dRk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":61 + * + * cpdef dRk(self, int k): + * raise NotImplemented("(cython) dQk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef reset(self,compute_derivatives = False): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":60 + * raise NotImplemented("(cython) dAk is not implemented!") + * + * cpdef dRk(self, int k): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) dQk is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dRk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_10dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dRk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":63 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self,compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args) { + PyObject *__pyx_v_compute_derivatives = ((PyObject *)Py_False); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset)) { + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_compute_derivatives); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __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 = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(__pyx_v_compute_derivatives); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_compute_derivatives); + __Pyx_GIVEREF(__pyx_v_compute_derivatives); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __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_3); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":64 + * + * cpdef reset(self,compute_derivatives = False): + * raise NotImplemented("(cython) reset is not implemented!") # <<<<<<<<<<<<<< + * + * cdef class R_handling_Cython(Measurement_Callables_Cython): + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_NotImplemented, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":63 + * raise NotImplemented("(cython) dQk is not implemented!") + * + * cpdef reset(self,compute_derivatives = False): # <<<<<<<<<<<<<< + * raise NotImplemented("(cython) reset is not implemented!") + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_compute_derivatives = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,0}; + PyObject* values[1] = {0}; + values[0] = ((PyObject *)Py_False); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compute_derivatives); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_compute_derivatives = values[0]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_12reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_self, PyObject *__pyx_v_compute_derivatives) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives; + __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->reset(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Measurement_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":78 + * dict R_square_root + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None): + * """ + */ + +/* Python wrapper */ +static int __pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython___init__[] = "\n Input: \n ---------------\n R - array with noise on various steps. The result of preprocessing\n the noise input.\n \n index - for each step of Kalman filter contains the corresponding index\n in the array.\n \n R_time_var_index - another index in the array R. Computed earlier and passed here.\n \n unique_R_number - number of unique noise matrices below which square roots\n are cached and above which they are computed each time.\n \n dR: 3D array[:, :, param_num]\n derivative of R. Derivative is supported only when R do not change over time\n \n Output:\n --------------\n Object which has two necessary functions:\n f_R(k)\n inv_R_square_root(k)\n "; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__; +#endif +static int __pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_R = 0; + PyArrayObject *__pyx_v_index = 0; + int __pyx_v_R_time_var_index; + int __pyx_v_p_unique_R_number; + PyArrayObject *__pyx_v_dR = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_R,&__pyx_n_s_index,&__pyx_n_s_R_time_var_index,&__pyx_n_s_p_unique_R_number,&__pyx_n_s_dR,0}; + PyObject* values[5] = {0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":79 + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, + * int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None): # <<<<<<<<<<<<<< + * """ + * Input: + */ + values[4] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_R)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_R_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_unique_R_number)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dR); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_R = ((PyArrayObject *)values[0]); + __pyx_v_index = ((PyArrayObject *)values[1]); + __pyx_v_R_time_var_index = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_R_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_p_unique_R_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_p_unique_R_number == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_dR = ((PyArrayObject *)values[4]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_R), __pyx_ptype_5numpy_ndarray, 1, "R", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dR), __pyx_ptype_5numpy_ndarray, 1, "dR", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), __pyx_v_R, __pyx_v_index, __pyx_v_R_time_var_index, __pyx_v_p_unique_R_number, __pyx_v_dR); + + /* "GPy/models/state_space_cython.pyx":78 + * dict R_square_root + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None): + * """ + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_p_unique_R_number, PyArrayObject *__pyx_v_dR) { + int __pyx_v_unique_len; + __Pyx_LocalBuf_ND __pyx_pybuffernd_R; + __Pyx_Buffer __pyx_pybuffer_R; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dR; + __Pyx_Buffer __pyx_pybuffer_dR; + __Pyx_LocalBuf_ND __pyx_pybuffernd_index; + __Pyx_Buffer __pyx_pybuffer_index; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_R.pybuffer.buf = NULL; + __pyx_pybuffer_R.refcount = 0; + __pyx_pybuffernd_R.data = NULL; + __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R; + __pyx_pybuffer_index.pybuffer.buf = NULL; + __pyx_pybuffer_index.refcount = 0; + __pyx_pybuffernd_index.data = NULL; + __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index; + __pyx_pybuffer_dR.pybuffer.buf = NULL; + __pyx_pybuffer_dR.refcount = 0; + __pyx_pybuffernd_dR.data = NULL; + __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_v_R, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_R.diminfo[2].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_R.diminfo[2].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR.diminfo[2].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR.diminfo[2].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":104 + * """ + * + * self.R = R # <<<<<<<<<<<<<< + * self.index = index + * self.R_time_var_index = R_time_var_index + */ + __Pyx_INCREF(((PyObject *)__pyx_v_R)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); + __Pyx_GOTREF(__pyx_v_self->R); + __Pyx_DECREF(((PyObject *)__pyx_v_self->R)); + __pyx_v_self->R = ((PyArrayObject *)__pyx_v_R); + + /* "GPy/models/state_space_cython.pyx":105 + * + * self.R = R + * self.index = index # <<<<<<<<<<<<<< + * self.R_time_var_index = R_time_var_index + * self.dR = dR + */ + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + __Pyx_GOTREF(__pyx_v_self->index); + __Pyx_DECREF(((PyObject *)__pyx_v_self->index)); + __pyx_v_self->index = ((PyArrayObject *)__pyx_v_index); + + /* "GPy/models/state_space_cython.pyx":106 + * self.R = R + * self.index = index + * self.R_time_var_index = R_time_var_index # <<<<<<<<<<<<<< + * self.dR = dR + * + */ + __pyx_v_self->R_time_var_index = __pyx_v_R_time_var_index; + + /* "GPy/models/state_space_cython.pyx":107 + * self.index = index + * self.R_time_var_index = R_time_var_index + * self.dR = dR # <<<<<<<<<<<<<< + * + * cdef int unique_len = len(np.unique(index)) + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dR)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dR)); + __Pyx_GOTREF(__pyx_v_self->dR); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dR)); + __pyx_v_self->dR = ((PyArrayObject *)__pyx_v_dR); + + /* "GPy/models/state_space_cython.pyx":109 + * self.dR = dR + * + * cdef int unique_len = len(np.unique(index)) # <<<<<<<<<<<<<< + * + * if (unique_len > p_unique_R_number): + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_unique); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_2) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_index)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + __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 = 109; __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; + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_unique_len = __pyx_t_5; + + /* "GPy/models/state_space_cython.pyx":111 + * cdef int unique_len = len(np.unique(index)) + * + * if (unique_len > p_unique_R_number): # <<<<<<<<<<<<<< + * self.svd_each_time = True + * else: + */ + __pyx_t_6 = ((__pyx_v_unique_len > __pyx_v_p_unique_R_number) != 0); + if (__pyx_t_6) { + + /* "GPy/models/state_space_cython.pyx":112 + * + * if (unique_len > p_unique_R_number): + * self.svd_each_time = True # <<<<<<<<<<<<<< + * else: + * self.svd_each_time = False + */ + __pyx_v_self->svd_each_time = 1; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":114 + * self.svd_each_time = True + * else: + * self.svd_each_time = False # <<<<<<<<<<<<<< + * + * self.R_square_root = {} + */ + __pyx_v_self->svd_each_time = 0; + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":116 + * self.svd_each_time = False + * + * self.R_square_root = {} # <<<<<<<<<<<<<< + * + * cpdef Rk(self, int k): + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->R_square_root); + __Pyx_DECREF(__pyx_v_self->R_square_root); + __pyx_v_self->R_square_root = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":78 + * dict R_square_root + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None): + * """ + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":118 + * self.R_square_root = {} + * + * cpdef Rk(self, int k): # <<<<<<<<<<<<<< + * return self.R[:,:, self.index[self.R_time_var_index, k]] + * + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Rk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Rk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":119 + * + * cpdef Rk(self, int k): + * return self.R[:,:, self.index[self.R_time_var_index, k]] # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->R_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __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); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__15); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); + __Pyx_INCREF(__pyx_slice__16); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->R), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":118 + * self.R_square_root = {} + * + * cpdef Rk(self, int k): # <<<<<<<<<<<<<< + * return self.R[:,:, self.index[self.R_time_var_index, k]] + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Rk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_2Rk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Rk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.Rk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":122 + * + * + * cpdef dRk(self,int k): # <<<<<<<<<<<<<< + * if self.dR is None: + * raise ValueError("dR derivative is None") + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dRk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dRk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":123 + * + * cpdef dRk(self,int k): + * if self.dR is None: # <<<<<<<<<<<<<< + * raise ValueError("dR derivative is None") + * + */ + __pyx_t_7 = (((PyObject *)__pyx_v_self->dR) == Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + /* "GPy/models/state_space_cython.pyx":124 + * cpdef dRk(self,int k): + * if self.dR is None: + * raise ValueError("dR derivative is None") # <<<<<<<<<<<<<< + * + * return self.dR # the same dirivative on each iteration + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "GPy/models/state_space_cython.pyx":126 + * raise ValueError("dR derivative is None") + * + * return self.dR # the same dirivative on each iteration # <<<<<<<<<<<<<< + * + * cpdef R_isrk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->dR)); + __pyx_r = ((PyObject *)__pyx_v_self->dR); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":122 + * + * + * cpdef dRk(self,int k): # <<<<<<<<<<<<<< + * if self.dR is None: + * raise ValueError("dR derivative is None") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dRk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_4dRk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dRk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.dRk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":128 + * return self.dR # the same dirivative on each iteration + * + * cpdef R_isrk(self, int k): # <<<<<<<<<<<<<< + * """ + * Function returns the inverse square root of R matrix on step k. + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + int __pyx_v_ind; + PyArrayObject *__pyx_v_R = 0; + PyArrayObject *__pyx_v_inv_square_root = 0; + PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_R; + __Pyx_Buffer __pyx_pybuffer_R; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_inv_square_root; + __Pyx_Buffer __pyx_pybuffer_inv_square_root; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyArrayObject *__pyx_t_8 = NULL; + int __pyx_t_9; + PyArrayObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *(*__pyx_t_14)(PyObject *); + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + int __pyx_t_18; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("R_isrk", 0); + __pyx_pybuffer_R.pybuffer.buf = NULL; + __pyx_pybuffer_R.refcount = 0; + __pyx_pybuffernd_R.data = NULL; + __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R; + __pyx_pybuffer_inv_square_root.pybuffer.buf = NULL; + __pyx_pybuffer_inv_square_root.refcount = 0; + __pyx_pybuffernd_inv_square_root.data = NULL; + __pyx_pybuffernd_inv_square_root.rcbuffer = &__pyx_pybuffer_inv_square_root; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_R_isrk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":132 + * Function returns the inverse square root of R matrix on step k. + * """ + * cdef int ind = self.index[self.R_time_var_index, k] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ] + * + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->R_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __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); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_ind = ((int)__pyx_t_7); + + /* "GPy/models/state_space_cython.pyx":133 + * """ + * cdef int ind = self.index[self.R_time_var_index, k] + * cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ] # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] inv_square_root + */ + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__18); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + __Pyx_INCREF(__pyx_slice__19); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->R), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_8 = 0; + __pyx_v_R = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":141 + * cdef np.ndarray[DTYPE_t, ndim=2] Vh + * + * if (R.shape[0] == 1): # 1-D case handle simplier. No storage # <<<<<<<<<<<<<< + * # of the result, just compute it each time. + * inv_square_root = np.sqrt( 1.0/R ) + */ + __pyx_t_9 = (((__pyx_v_R->dimensions[0]) == 1) != 0); + if (__pyx_t_9) { + + /* "GPy/models/state_space_cython.pyx":143 + * if (R.shape[0] == 1): # 1-D case handle simplier. No storage + * # of the result, just compute it each time. + * inv_square_root = np.sqrt( 1.0/R ) # <<<<<<<<<<<<<< + * else: + * if self.svd_each_time: + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_float_1_0, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_6) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL; + PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":145 + * inv_square_root = np.sqrt( 1.0/R ) + * else: + * if self.svd_each_time: # <<<<<<<<<<<<<< + * + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + */ + __pyx_t_9 = (__pyx_v_self->svd_each_time != 0); + if (__pyx_t_9) { + + /* "GPy/models/state_space_cython.pyx":147 + * if self.svd_each_time: + * + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_R)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_R)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":148 + * + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * + * inv_square_root = U * 1.0/np.sqrt(S) + */ + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":147 + * if self.svd_each_time: + * + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_3 = PyList_GET_ITEM(sequence, 0); + __pyx_t_1 = PyList_GET_ITEM(sequence, 1); + __pyx_t_2 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_6)->tp_iternext; + index = 0; __pyx_t_3 = __pyx_t_14(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 1; __pyx_t_1 = __pyx_t_14(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 2; __pyx_t_2 = __pyx_t_14(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_6), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __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 = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_3); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":150 + * overwrite_a=False,check_finite=True) + * + * inv_square_root = U * 1.0/np.sqrt(S) # <<<<<<<<<<<<<< + * else: + * if ind in self.R_square_root: + */ + __pyx_t_4 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_float_1_0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_3); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L4; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":152 + * inv_square_root = U * 1.0/np.sqrt(S) + * else: + * if ind in self.R_square_root: # <<<<<<<<<<<<<< + * inv_square_root = self.R_square_root[ind] + * else: + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (unlikely(__pyx_v_self->R_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_9 = (__Pyx_PyDict_Contains(__pyx_t_3, __pyx_v_self->R_square_root, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_18 = (__pyx_t_9 != 0); + if (__pyx_t_18) { + + /* "GPy/models/state_space_cython.pyx":153 + * else: + * if ind in self.R_square_root: + * inv_square_root = self.R_square_root[ind] # <<<<<<<<<<<<<< + * else: + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + */ + if (unlikely(__pyx_v_self->R_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->R_square_root, __pyx_t_3); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L7; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":155 + * inv_square_root = self.R_square_root[ind] + * else: + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __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_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_R)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_R)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":156 + * else: + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * + * inv_square_root = U * 1.0/np.sqrt(S) + */ + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":155 + * inv_square_root = self.R_square_root[ind] + * else: + * U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { + PyObject* sequence = __pyx_t_6; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_4 = PyList_GET_ITEM(sequence, 0); + __pyx_t_3 = PyList_GET_ITEM(sequence, 1); + __pyx_t_2 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_1 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_1)->tp_iternext; + index = 0; __pyx_t_4 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + index = 1; __pyx_t_3 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + index = 2; __pyx_t_2 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_1), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L9_unpacking_done; + __pyx_L8_unpacking_failed:; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L9_unpacking_done:; + } + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_3); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":158 + * overwrite_a=False,check_finite=True) + * + * inv_square_root = U * 1.0/np.sqrt(S) # <<<<<<<<<<<<<< + * + * self.R_square_root[ind] = inv_square_root + */ + __pyx_t_6 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_float_1_0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __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; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_3)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_3) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_t_6, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_inv_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_inv_square_root.diminfo[0].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_inv_square_root.diminfo[0].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_inv_square_root.diminfo[1].strides = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_inv_square_root.diminfo[1].shape = __pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_inv_square_root = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":160 + * inv_square_root = U * 1.0/np.sqrt(S) + * + * self.R_square_root[ind] = inv_square_root # <<<<<<<<<<<<<< + * + * return inv_square_root + */ + if (unlikely(__pyx_v_self->R_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyDict_SetItem(__pyx_v_self->R_square_root, __pyx_t_4, ((PyObject *)__pyx_v_inv_square_root)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __pyx_L7:; + } + __pyx_L4:; + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":162 + * self.R_square_root[ind] = inv_square_root + * + * return inv_square_root # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_inv_square_root)); + __pyx_r = ((PyObject *)__pyx_v_inv_square_root); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":128 + * return self.dR # the same dirivative on each iteration + * + * cpdef R_isrk(self, int k): # <<<<<<<<<<<<<< + * """ + * Function returns the inverse square root of R matrix on step k. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_inv_square_root.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_R); + __Pyx_XDECREF((PyObject *)__pyx_v_inv_square_root); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk[] = "\n Function returns the inverse square root of R matrix on step k.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("R_isrk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("R_isrk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.R_handling_Cython.R_isrk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":172 + * np.ndarray dH + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + * int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, + */ + +/* Python wrapper */ +static int __pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_H = 0; + int __pyx_v_H_time_var_index; + PyArrayObject *__pyx_v_R = 0; + PyArrayObject *__pyx_v_index = 0; + int __pyx_v_R_time_var_index; + int __pyx_v_unique_R_number; + PyArrayObject *__pyx_v_dH = 0; + PyArrayObject *__pyx_v_dR = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_H,&__pyx_n_s_H_time_var_index,&__pyx_n_s_R,&__pyx_n_s_index,&__pyx_n_s_R_time_var_index,&__pyx_n_s_unique_R_number,&__pyx_n_s_dH,&__pyx_n_s_dR,0}; + PyObject* values[8] = {0,0,0,0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":174 + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index, + * np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + * int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] dR=None): + * + */ + values[6] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":175 + * np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + * int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, + * np.ndarray[DTYPE_t, ndim=3] dR=None): # <<<<<<<<<<<<<< + * + * super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR) + */ + values[7] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_H)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_H_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_R)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_R_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_unique_R_number)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dH); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dR); + if (value) { values[7] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_H = ((PyArrayObject *)values[0]); + __pyx_v_H_time_var_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_H_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_R = ((PyArrayObject *)values[2]); + __pyx_v_index = ((PyArrayObject *)values[3]); + __pyx_v_R_time_var_index = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_R_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_unique_R_number = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_unique_R_number == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_dH = ((PyArrayObject *)values[6]); + __pyx_v_dR = ((PyArrayObject *)values[7]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_H), __pyx_ptype_5numpy_ndarray, 1, "H", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_R), __pyx_ptype_5numpy_ndarray, 1, "R", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dH), __pyx_ptype_5numpy_ndarray, 1, "dH", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dR), __pyx_ptype_5numpy_ndarray, 1, "dR", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_H, __pyx_v_H_time_var_index, __pyx_v_R, __pyx_v_index, __pyx_v_R_time_var_index, __pyx_v_unique_R_number, __pyx_v_dH, __pyx_v_dR); + + /* "GPy/models/state_space_cython.pyx":172 + * np.ndarray dH + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + * int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_H, int __pyx_v_H_time_var_index, PyArrayObject *__pyx_v_R, PyArrayObject *__pyx_v_index, int __pyx_v_R_time_var_index, int __pyx_v_unique_R_number, PyArrayObject *__pyx_v_dH, PyArrayObject *__pyx_v_dR) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_H; + __Pyx_Buffer __pyx_pybuffer_H; + __Pyx_LocalBuf_ND __pyx_pybuffernd_R; + __Pyx_Buffer __pyx_pybuffer_R; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dH; + __Pyx_Buffer __pyx_pybuffer_dH; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dR; + __Pyx_Buffer __pyx_pybuffer_dR; + __Pyx_LocalBuf_ND __pyx_pybuffernd_index; + __Pyx_Buffer __pyx_pybuffer_index; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_H.pybuffer.buf = NULL; + __pyx_pybuffer_H.refcount = 0; + __pyx_pybuffernd_H.data = NULL; + __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H; + __pyx_pybuffer_R.pybuffer.buf = NULL; + __pyx_pybuffer_R.refcount = 0; + __pyx_pybuffernd_R.data = NULL; + __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R; + __pyx_pybuffer_index.pybuffer.buf = NULL; + __pyx_pybuffer_index.refcount = 0; + __pyx_pybuffernd_index.data = NULL; + __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index; + __pyx_pybuffer_dH.pybuffer.buf = NULL; + __pyx_pybuffer_dH.refcount = 0; + __pyx_pybuffernd_dH.data = NULL; + __pyx_pybuffernd_dH.rcbuffer = &__pyx_pybuffer_dH; + __pyx_pybuffer_dR.pybuffer.buf = NULL; + __pyx_pybuffer_dR.refcount = 0; + __pyx_pybuffernd_dR.data = NULL; + __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_H.diminfo[2].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_H.diminfo[2].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_v_R, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_R.diminfo[2].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_R.diminfo[2].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dH.diminfo[0].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH.diminfo[0].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH.diminfo[1].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH.diminfo[1].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dH.diminfo[2].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dH.diminfo[2].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR.diminfo[2].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR.diminfo[2].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":177 + * np.ndarray[DTYPE_t, ndim=3] dR=None): + * + * super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR) # <<<<<<<<<<<<<< + * + * self.H = H + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython))); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __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_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_R_time_var_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_unique_R_number); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_R)); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_R)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_R)); + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_dR)); + PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, ((PyObject *)__pyx_v_dR)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dR)); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":179 + * super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR) + * + * self.H = H # <<<<<<<<<<<<<< + * self.H_time_var_index = H_time_var_index + * self.dH = dH + */ + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + __Pyx_GOTREF(__pyx_v_self->H); + __Pyx_DECREF(((PyObject *)__pyx_v_self->H)); + __pyx_v_self->H = ((PyArrayObject *)__pyx_v_H); + + /* "GPy/models/state_space_cython.pyx":180 + * + * self.H = H + * self.H_time_var_index = H_time_var_index # <<<<<<<<<<<<<< + * self.dH = dH + * + */ + __pyx_v_self->H_time_var_index = __pyx_v_H_time_var_index; + + /* "GPy/models/state_space_cython.pyx":181 + * self.H = H + * self.H_time_var_index = H_time_var_index + * self.dH = dH # <<<<<<<<<<<<<< + * + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H): + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dH)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dH)); + __Pyx_GOTREF(__pyx_v_self->dH); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dH)); + __pyx_v_self->dH = ((PyArrayObject *)__pyx_v_dH); + + /* "GPy/models/state_space_cython.pyx":172 + * np.ndarray dH + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + * int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":183 + * self.dH = dH + * + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H): # <<<<<<<<<<<<<< + * """ + * function (k, x_{k}, H_{k}). Measurement function. + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_H; + __Pyx_Buffer __pyx_pybuffer_H; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_h", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_H.pybuffer.buf = NULL; + __pyx_pybuffer_H.refcount = 0; + __pyx_pybuffernd_H.data = NULL; + __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_h); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":191 + * """ + * + * return np.dot(H, m) # <<<<<<<<<<<<<< + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __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; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_2) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":183 + * self.dH = dH + * + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H): # <<<<<<<<<<<<<< + * """ + * function (k, x_{k}, H_{k}). Measurement function. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h[] = "\n function (k, x_{k}, H_{k}). Measurement function.\n k (iteration number), starts at 0\n x_{k} state \n H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_H = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("f_h (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_H,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_H)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_h") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_H = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("f_h", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_H), __pyx_ptype_5numpy_ndarray, 1, "H", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_H); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_H) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_H; + __Pyx_Buffer __pyx_pybuffer_H; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_h", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_H.pybuffer.buf = NULL; + __pyx_pybuffer_H.refcount = 0; + __pyx_pybuffernd_H.data = NULL; + __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_v_H, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_H), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.f_h", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":193 + * return np.dot(H, m) + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * """ + * function (k, m, P) return Jacobian of measurement function, it is + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Hk", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Hk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":202 + * """ + * + * return self.H[:,:, self.index[self.H_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dHk(self,int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->H_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->__pyx_base.index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__20); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__20); + __Pyx_GIVEREF(__pyx_slice__20); + __Pyx_INCREF(__pyx_slice__21); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__21); + __Pyx_GIVEREF(__pyx_slice__21); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->H), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":193 + * return np.dot(H, m) + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * """ + * function (k, m, P) return Jacobian of measurement function, it is + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk[] = "\n function (k, m, P) return Jacobian of measurement function, it is\n passed into p_h.\n k (iteration number), starts at 0\n m: point where Jacobian is evaluated\n P: parameter for Jacobian, usually covariance matrix.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_P_pred = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Hk (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Hk") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m_pred = ((PyArrayObject *)values[1]); + __pyx_v_P_pred = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("Hk", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Hk", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.Hk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":204 + * return self.H[:,:, self.index[self.H_time_var_index, k]] + * + * cpdef dHk(self,int k): # <<<<<<<<<<<<<< + * if self.dH is None: + * raise ValueError("dH derivative is None") + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dHk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dHk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":205 + * + * cpdef dHk(self,int k): + * if self.dH is None: # <<<<<<<<<<<<<< + * raise ValueError("dH derivative is None") + * + */ + __pyx_t_7 = (((PyObject *)__pyx_v_self->dH) == Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + /* "GPy/models/state_space_cython.pyx":206 + * cpdef dHk(self,int k): + * if self.dH is None: + * raise ValueError("dH derivative is None") # <<<<<<<<<<<<<< + * + * return self.dH # the same dirivative on each iteration + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "GPy/models/state_space_cython.pyx":208 + * raise ValueError("dH derivative is None") + * + * return self.dH # the same dirivative on each iteration # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->dH)); + __pyx_r = ((PyObject *)__pyx_v_self->dH); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":204 + * return self.H[:,:, self.index[self.H_time_var_index, k]] + * + * cpdef dHk(self,int k): # <<<<<<<<<<<<<< + * if self.dH is None: + * raise ValueError("dH derivative is None") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dHk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_6dHk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dHk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Measurement_Callables_Cython.dHk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":222 + * bint svd_each_time + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None): + * """ + */ + +/* Python wrapper */ +static int __pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__[] = "\n Input: \n ---------------\n Q - array with noise on various steps. The result of preprocessing\n the noise input.\n \n index - for each step of Kalman filter contains the corresponding index\n in the array.\n \n Q_time_var_index - another index in the array R. Computed earlier and passed here.\n \n unique_Q_number - number of unique noise matrices below which square roots\n are cached and above which they are computed each time.\n \n dQ: 3D array[:, :, param_num]\n derivative of Q. Derivative is supported only when Q do not change over time\n \n Output:\n --------------\n Object which has three necessary functions:\n Qk(k)\n dQk(k)\n Q_srkt(k)\n "; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__; +#endif +static int __pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_Q = 0; + PyArrayObject *__pyx_v_index = 0; + int __pyx_v_Q_time_var_index; + int __pyx_v_p_unique_Q_number; + PyArrayObject *__pyx_v_dQ = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_Q,&__pyx_n_s_index,&__pyx_n_s_Q_time_var_index,&__pyx_n_s_p_unique_Q_number,&__pyx_n_s_dQ,0}; + PyObject* values[5] = {0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":223 + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index, + * int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None): # <<<<<<<<<<<<<< + * """ + * Input: + */ + values[4] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Q_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_unique_Q_number)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dQ); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_Q = ((PyArrayObject *)values[0]); + __pyx_v_index = ((PyArrayObject *)values[1]); + __pyx_v_Q_time_var_index = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_Q_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_p_unique_Q_number = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_p_unique_Q_number == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_dQ = ((PyArrayObject *)values[4]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Q), __pyx_ptype_5numpy_ndarray, 1, "Q", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQ), __pyx_ptype_5numpy_ndarray, 1, "dQ", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), __pyx_v_Q, __pyx_v_index, __pyx_v_Q_time_var_index, __pyx_v_p_unique_Q_number, __pyx_v_dQ); + + /* "GPy/models/state_space_cython.pyx":222 + * bint svd_each_time + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None): + * """ + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_p_unique_Q_number, PyArrayObject *__pyx_v_dQ) { + int __pyx_v_unique_len; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Q; + __Pyx_Buffer __pyx_pybuffer_Q; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ; + __Pyx_Buffer __pyx_pybuffer_dQ; + __Pyx_LocalBuf_ND __pyx_pybuffernd_index; + __Pyx_Buffer __pyx_pybuffer_index; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_Q.pybuffer.buf = NULL; + __pyx_pybuffer_Q.refcount = 0; + __pyx_pybuffernd_Q.data = NULL; + __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q; + __pyx_pybuffer_index.pybuffer.buf = NULL; + __pyx_pybuffer_index.refcount = 0; + __pyx_pybuffernd_index.data = NULL; + __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index; + __pyx_pybuffer_dQ.pybuffer.buf = NULL; + __pyx_pybuffer_dQ.refcount = 0; + __pyx_pybuffernd_dQ.data = NULL; + __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_v_Q, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Q.diminfo[2].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Q.diminfo[2].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ.diminfo[2].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ.diminfo[2].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":249 + * """ + * + * self.Q = Q # <<<<<<<<<<<<<< + * self.index = index + * self.Q_time_var_index = Q_time_var_index + */ + __Pyx_INCREF(((PyObject *)__pyx_v_Q)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Q)); + __Pyx_GOTREF(__pyx_v_self->Q); + __Pyx_DECREF(((PyObject *)__pyx_v_self->Q)); + __pyx_v_self->Q = ((PyArrayObject *)__pyx_v_Q); + + /* "GPy/models/state_space_cython.pyx":250 + * + * self.Q = Q + * self.index = index # <<<<<<<<<<<<<< + * self.Q_time_var_index = Q_time_var_index + * self.dQ = dQ + */ + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + __Pyx_GOTREF(__pyx_v_self->index); + __Pyx_DECREF(((PyObject *)__pyx_v_self->index)); + __pyx_v_self->index = ((PyArrayObject *)__pyx_v_index); + + /* "GPy/models/state_space_cython.pyx":251 + * self.Q = Q + * self.index = index + * self.Q_time_var_index = Q_time_var_index # <<<<<<<<<<<<<< + * self.dQ = dQ + * + */ + __pyx_v_self->Q_time_var_index = __pyx_v_Q_time_var_index; + + /* "GPy/models/state_space_cython.pyx":252 + * self.index = index + * self.Q_time_var_index = Q_time_var_index + * self.dQ = dQ # <<<<<<<<<<<<<< + * + * cdef int unique_len = len(np.unique(index)) + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dQ)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dQ)); + __Pyx_GOTREF(__pyx_v_self->dQ); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dQ)); + __pyx_v_self->dQ = ((PyArrayObject *)__pyx_v_dQ); + + /* "GPy/models/state_space_cython.pyx":254 + * self.dQ = dQ + * + * cdef int unique_len = len(np.unique(index)) # <<<<<<<<<<<<<< + * + * if (unique_len > p_unique_Q_number): + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_unique); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_3))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_3, function); + } + } + if (!__pyx_t_2) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, ((PyObject *)__pyx_v_index)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __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 = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_4, 0+1, ((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + __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 = 254; __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; + __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_unique_len = __pyx_t_5; + + /* "GPy/models/state_space_cython.pyx":256 + * cdef int unique_len = len(np.unique(index)) + * + * if (unique_len > p_unique_Q_number): # <<<<<<<<<<<<<< + * self.svd_each_time = True + * else: + */ + __pyx_t_6 = ((__pyx_v_unique_len > __pyx_v_p_unique_Q_number) != 0); + if (__pyx_t_6) { + + /* "GPy/models/state_space_cython.pyx":257 + * + * if (unique_len > p_unique_Q_number): + * self.svd_each_time = True # <<<<<<<<<<<<<< + * else: + * self.svd_each_time = False + */ + __pyx_v_self->svd_each_time = 1; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":259 + * self.svd_each_time = True + * else: + * self.svd_each_time = False # <<<<<<<<<<<<<< + * + * self.Q_square_root = {} + */ + __pyx_v_self->svd_each_time = 0; + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":261 + * self.svd_each_time = False + * + * self.Q_square_root = {} # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->Q_square_root); + __Pyx_DECREF(__pyx_v_self->Q_square_root); + __pyx_v_self->Q_square_root = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":222 + * bint svd_each_time + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index, # <<<<<<<<<<<<<< + * int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None): + * """ + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":264 + * + * + * cpdef Qk(self, int k): # <<<<<<<<<<<<<< + * """ + * function (k). Returns noise matrix of dynamic model on iteration k. + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":269 + * k (iteration number). starts at 0 + * """ + * return self.Q[:,:, self.index[self.Q_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->Q_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __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); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__23); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__23); + __Pyx_GIVEREF(__pyx_slice__23); + __Pyx_INCREF(__pyx_slice__24); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__24); + __Pyx_GIVEREF(__pyx_slice__24); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->Q), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":264 + * + * + * cpdef Qk(self, int k): # <<<<<<<<<<<<<< + * """ + * function (k). Returns noise matrix of dynamic model on iteration k. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk[] = "\n function (k). Returns noise matrix of dynamic model on iteration k.\n k (iteration number). starts at 0\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Qk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":271 + * return self.Q[:,:, self.index[self.Q_time_var_index, k]] + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * if self.dQ is None: + * raise ValueError("dQ derivative is None") + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":272 + * + * cpdef dQk(self, int k): + * if self.dQ is None: # <<<<<<<<<<<<<< + * raise ValueError("dQ derivative is None") + * + */ + __pyx_t_7 = (((PyObject *)__pyx_v_self->dQ) == Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + /* "GPy/models/state_space_cython.pyx":273 + * cpdef dQk(self, int k): + * if self.dQ is None: + * raise ValueError("dQ derivative is None") # <<<<<<<<<<<<<< + * + * return self.dQ # the same dirivative on each iteration + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "GPy/models/state_space_cython.pyx":275 + * raise ValueError("dQ derivative is None") + * + * return self.dQ # the same dirivative on each iteration # <<<<<<<<<<<<<< + * + * cpdef Q_srk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->dQ)); + __pyx_r = ((PyObject *)__pyx_v_self->dQ); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":271 + * return self.Q[:,:, self.index[self.Q_time_var_index, k]] + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * if self.dQ is None: + * raise ValueError("dQ derivative is None") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dQk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_4dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":277 + * return self.dQ # the same dirivative on each iteration + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * """ + * function (k). Returns the square root of noise matrix of dynamic model on iteration k. + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + int __pyx_v_ind; + PyArrayObject *__pyx_v_Q = 0; + PyArrayObject *__pyx_v_square_root = 0; + PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Q; + __Pyx_Buffer __pyx_pybuffer_Q; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_square_root; + __Pyx_Buffer __pyx_pybuffer_square_root; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + PyArrayObject *__pyx_t_8 = NULL; + int __pyx_t_9; + PyArrayObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *(*__pyx_t_14)(PyObject *); + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + int __pyx_t_18; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + __pyx_pybuffer_Q.pybuffer.buf = NULL; + __pyx_pybuffer_Q.refcount = 0; + __pyx_pybuffernd_Q.data = NULL; + __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q; + __pyx_pybuffer_square_root.pybuffer.buf = NULL; + __pyx_pybuffer_square_root.refcount = 0; + __pyx_pybuffernd_square_root.data = NULL; + __pyx_pybuffernd_square_root.rcbuffer = &__pyx_pybuffer_square_root; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":284 + * This function is implemented to use SVD prediction step. + * """ + * cdef int ind = self.index[self.Q_time_var_index, k] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind] + * + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->Q_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_ind = ((int)__pyx_t_7); + + /* "GPy/models/state_space_cython.pyx":285 + * """ + * cdef int ind = self.index[self.Q_time_var_index, k] + * cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind] # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__26); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__26); + __Pyx_GIVEREF(__pyx_slice__26); + __Pyx_INCREF(__pyx_slice__27); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__27); + __Pyx_GIVEREF(__pyx_slice__27); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->Q), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_8 = 0; + __pyx_v_Q = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":294 + * cdef np.ndarray[DTYPE_t, ndim=2] Vh + * + * if (Q.shape[0] == 1): # 1-D case handle simplier. No storage # <<<<<<<<<<<<<< + * # of the result, just compute it each time. + * square_root = np.sqrt( Q ) + */ + __pyx_t_9 = (((__pyx_v_Q->dimensions[0]) == 1) != 0); + if (__pyx_t_9) { + + /* "GPy/models/state_space_cython.pyx":296 + * if (Q.shape[0] == 1): # 1-D case handle simplier. No storage + * # of the result, just compute it each time. + * square_root = np.sqrt( Q ) # <<<<<<<<<<<<<< + * else: + * if self.svd_each_time: + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_Q)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_Q)); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_Q)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Q)); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":298 + * square_root = np.sqrt( Q ) + * else: + * if self.svd_each_time: # <<<<<<<<<<<<<< + * + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + */ + __pyx_t_9 = (__pyx_v_self->svd_each_time != 0); + if (__pyx_t_9) { + + /* "GPy/models/state_space_cython.pyx":300 + * if self.svd_each_time: + * + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_Q)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_Q)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Q)); + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":301 + * + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * + * square_root = U * np.sqrt(S) + */ + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":300 + * if self.svd_each_time: + * + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_6 = PyList_GET_ITEM(sequence, 0); + __pyx_t_1 = PyList_GET_ITEM(sequence, 1); + __pyx_t_2 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; + index = 0; __pyx_t_6 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + index = 1; __pyx_t_1 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 2; __pyx_t_2 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_3), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __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 = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":303 + * overwrite_a=False,check_finite=True) + * + * square_root = U * np.sqrt(S) # <<<<<<<<<<<<<< + * else: + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_2) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __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); __pyx_t_2 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_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 = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + goto __pyx_L4; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":306 + * else: + * + * if ind in self.Q_square_root: # <<<<<<<<<<<<<< + * square_root = self.Q_square_root[ind] + * else: + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(__pyx_v_self->Q_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_9 = (__Pyx_PyDict_Contains(__pyx_t_1, __pyx_v_self->Q_square_root, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_18 = (__pyx_t_9 != 0); + if (__pyx_t_18) { + + /* "GPy/models/state_space_cython.pyx":307 + * + * if ind in self.Q_square_root: + * square_root = self.Q_square_root[ind] # <<<<<<<<<<<<<< + * else: + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + */ + if (unlikely(__pyx_v_self->Q_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyDict_GetItem(__pyx_v_self->Q_square_root, __pyx_t_1); if (unlikely(__pyx_t_4 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + goto __pyx_L7; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":309 + * square_root = self.Q_square_root[ind] + * else: + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_Q)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_Q)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Q)); + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":310 + * else: + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * + * square_root = U * np.sqrt(S) + */ + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":309 + * square_root = self.Q_square_root[ind] + * else: + * U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { + PyObject* sequence = __pyx_t_2; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_6 = PyList_GET_ITEM(sequence, 0); + __pyx_t_1 = PyList_GET_ITEM(sequence, 1); + __pyx_t_4 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_3 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; + index = 0; __pyx_t_6 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + index = 1; __pyx_t_1 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 2; __pyx_t_4 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L8_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_3), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L9_unpacking_done; + __pyx_L8_unpacking_failed:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L9_unpacking_done:; + } + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __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 = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":312 + * overwrite_a=False,check_finite=True) + * + * square_root = U * np.sqrt(S) # <<<<<<<<<<<<<< + * + * self.Q_square_root[ind] = square_root + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_6, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 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 = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":314 + * square_root = U * np.sqrt(S) + * + * self.Q_square_root[ind] = square_root # <<<<<<<<<<<<<< + * + * return square_root + */ + if (unlikely(__pyx_v_self->Q_square_root == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_ind); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(PyDict_SetItem(__pyx_v_self->Q_square_root, __pyx_t_1, ((PyObject *)__pyx_v_square_root)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_L7:; + } + __pyx_L4:; + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":316 + * self.Q_square_root[ind] = square_root + * + * return square_root # <<<<<<<<<<<<<< + * + * cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_square_root)); + __pyx_r = ((PyObject *)__pyx_v_square_root); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":277 + * return self.dQ # the same dirivative on each iteration + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * """ + * function (k). Returns the square root of noise matrix of dynamic model on iteration k. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_Q); + __Pyx_XDECREF((PyObject *)__pyx_v_square_root); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk[] = "\n function (k). Returns the square root of noise matrix of dynamic model on iteration k.\n k (iteration number). starts at 0\n \n This function is implemented to use SVD prediction step.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Q_srk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Q_handling_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":324 + * np.ndarray dA + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] Q, + * np.ndarray[DTYPE_t, ndim=2] index, + */ + +/* Python wrapper */ +static int __pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_A = 0; + int __pyx_v_A_time_var_index; + PyArrayObject *__pyx_v_Q = 0; + PyArrayObject *__pyx_v_index = 0; + int __pyx_v_Q_time_var_index; + int __pyx_v_unique_Q_number; + PyArrayObject *__pyx_v_dA = 0; + PyArrayObject *__pyx_v_dQ = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_A,&__pyx_n_s_A_time_var_index,&__pyx_n_s_Q,&__pyx_n_s_index,&__pyx_n_s_Q_time_var_index,&__pyx_n_s_unique_Q_number,&__pyx_n_s_dA,&__pyx_n_s_dQ,0}; + PyObject* values[8] = {0,0,0,0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":328 + * np.ndarray[DTYPE_t, ndim=2] index, + * int Q_time_var_index, int unique_Q_number, + * np.ndarray[DTYPE_t, ndim=3] dA = None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] dQ=None): + * + */ + values[6] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":329 + * int Q_time_var_index, int unique_Q_number, + * np.ndarray[DTYPE_t, ndim=3] dA = None, + * np.ndarray[DTYPE_t, ndim=3] dQ=None): # <<<<<<<<<<<<<< + * + * super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ) + */ + values[7] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_A_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Q)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Q_time_var_index)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_unique_Q_number)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, 5); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dA); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dQ); + if (value) { values[7] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_A = ((PyArrayObject *)values[0]); + __pyx_v_A_time_var_index = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_A_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_Q = ((PyArrayObject *)values[2]); + __pyx_v_index = ((PyArrayObject *)values[3]); + __pyx_v_Q_time_var_index = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_Q_time_var_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_unique_Q_number = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_unique_Q_number == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_dA = ((PyArrayObject *)values[6]); + __pyx_v_dQ = ((PyArrayObject *)values[7]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 6, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Q), __pyx_ptype_5numpy_ndarray, 1, "Q", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 325; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_index), __pyx_ptype_5numpy_ndarray, 1, "index", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dA), __pyx_ptype_5numpy_ndarray, 1, "dA", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQ), __pyx_ptype_5numpy_ndarray, 1, "dQ", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_A, __pyx_v_A_time_var_index, __pyx_v_Q, __pyx_v_index, __pyx_v_Q_time_var_index, __pyx_v_unique_Q_number, __pyx_v_dA, __pyx_v_dQ); + + /* "GPy/models/state_space_cython.pyx":324 + * np.ndarray dA + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] Q, + * np.ndarray[DTYPE_t, ndim=2] index, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, PyArrayObject *__pyx_v_A, int __pyx_v_A_time_var_index, PyArrayObject *__pyx_v_Q, PyArrayObject *__pyx_v_index, int __pyx_v_Q_time_var_index, int __pyx_v_unique_Q_number, PyArrayObject *__pyx_v_dA, PyArrayObject *__pyx_v_dQ) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Q; + __Pyx_Buffer __pyx_pybuffer_Q; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dA; + __Pyx_Buffer __pyx_pybuffer_dA; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ; + __Pyx_Buffer __pyx_pybuffer_dQ; + __Pyx_LocalBuf_ND __pyx_pybuffernd_index; + __Pyx_Buffer __pyx_pybuffer_index; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + __pyx_pybuffer_Q.pybuffer.buf = NULL; + __pyx_pybuffer_Q.refcount = 0; + __pyx_pybuffernd_Q.data = NULL; + __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q; + __pyx_pybuffer_index.pybuffer.buf = NULL; + __pyx_pybuffer_index.refcount = 0; + __pyx_pybuffernd_index.data = NULL; + __pyx_pybuffernd_index.rcbuffer = &__pyx_pybuffer_index; + __pyx_pybuffer_dA.pybuffer.buf = NULL; + __pyx_pybuffer_dA.refcount = 0; + __pyx_pybuffernd_dA.data = NULL; + __pyx_pybuffernd_dA.rcbuffer = &__pyx_pybuffer_dA; + __pyx_pybuffer_dQ.pybuffer.buf = NULL; + __pyx_pybuffer_dQ.refcount = 0; + __pyx_pybuffernd_dQ.data = NULL; + __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_A.diminfo[2].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_A.diminfo[2].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_v_Q, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Q.diminfo[2].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Q.diminfo[2].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_index.rcbuffer->pybuffer, (PyObject*)__pyx_v_index, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_index.diminfo[0].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_index.diminfo[0].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_index.diminfo[1].strides = __pyx_pybuffernd_index.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_index.diminfo[1].shape = __pyx_pybuffernd_index.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dA.diminfo[0].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA.diminfo[0].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA.diminfo[1].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA.diminfo[1].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dA.diminfo[2].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dA.diminfo[2].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ.diminfo[2].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ.diminfo[2].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":331 + * np.ndarray[DTYPE_t, ndim=3] dQ=None): + * + * super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ) # <<<<<<<<<<<<<< + * + * self.A = A + */ + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython))); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython))); + __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython))); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __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_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_Q_time_var_index); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_unique_Q_number); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_2, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(5+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_Q)); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_Q)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Q)); + __Pyx_INCREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_index)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_index)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_7, 3+__pyx_t_6, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_dQ)); + PyTuple_SET_ITEM(__pyx_t_7, 4+__pyx_t_6, ((PyObject *)__pyx_v_dQ)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dQ)); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":333 + * super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ) + * + * self.A = A # <<<<<<<<<<<<<< + * self.A_time_var_index = A_time_var_index + * self.dA = dA + */ + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __Pyx_GOTREF(__pyx_v_self->A); + __Pyx_DECREF(((PyObject *)__pyx_v_self->A)); + __pyx_v_self->A = ((PyArrayObject *)__pyx_v_A); + + /* "GPy/models/state_space_cython.pyx":334 + * + * self.A = A + * self.A_time_var_index = A_time_var_index # <<<<<<<<<<<<<< + * self.dA = dA + * + */ + __pyx_v_self->A_time_var_index = __pyx_v_A_time_var_index; + + /* "GPy/models/state_space_cython.pyx":335 + * self.A = A + * self.A_time_var_index = A_time_var_index + * self.dA = dA # <<<<<<<<<<<<<< + * + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dA)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dA)); + __Pyx_GOTREF(__pyx_v_self->dA); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dA)); + __pyx_v_self->dA = ((PyArrayObject *)__pyx_v_dA); + + /* "GPy/models/state_space_cython.pyx":324 + * np.ndarray dA + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] Q, + * np.ndarray[DTYPE_t, ndim=2] index, + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_index.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":337 + * self.dA = dA + * + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * """ + * f_a: function (k, x_{k-1}, A_{k}). Dynamic function. + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":345 + * """ + * + * return np.dot(A,m) # <<<<<<<<<<<<<< + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __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; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_2) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":337 + * self.dA = dA + * + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * """ + * f_a: function (k, x_{k-1}, A_{k}). Dynamic function. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a[] = "\n f_a: function (k, x_{k-1}, A_{k}). Dynamic function. \n k (iteration number), starts at 0\n x_{k-1} State from the previous step\n A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_A = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("f_a (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_A = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_A); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_A), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":347 + * return np.dot(A,m) + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * """ + * function (k, m, P) return Jacobian of measurement function, it is + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m_pred, CYTHON_UNUSED PyArrayObject *__pyx_v_P_pred, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":356 + * """ + * + * return self.A[:,:, self.index[self.A_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->A_time_var_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __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); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->__pyx_base.index), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(((int)__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__28); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__28); + __Pyx_GIVEREF(__pyx_slice__28); + __Pyx_INCREF(__pyx_slice__29); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__29); + __Pyx_GIVEREF(__pyx_slice__29); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_self->A), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":347 + * return np.dot(A,m) + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix # <<<<<<<<<<<<<< + * """ + * function (k, m, P) return Jacobian of measurement function, it is + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak[] = "\n function (k, m, P) return Jacobian of measurement function, it is\n passed into p_h.\n k (iteration number), starts at 0\n m: point where Jacobian is evaluated\n P: parameter for Jacobian, usually covariance matrix.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_P_pred = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Ak (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m_pred,&__pyx_n_s_P_pred,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P_pred)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m_pred = ((PyArrayObject *)values[1]); + __pyx_v_P_pred = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_pred), __pyx_ptype_5numpy_ndarray, 1, "m_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_pred), __pyx_ptype_5numpy_ndarray, 1, "P_pred", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m_pred, __pyx_v_P_pred); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m_pred, PyArrayObject *__pyx_v_P_pred) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":358 + * return self.A[:,:, self.index[self.A_time_var_index, k]] + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * if self.dA is None: + * raise ValueError("dA derivative is None") + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":359 + * + * cpdef dAk(self, int k): + * if self.dA is None: # <<<<<<<<<<<<<< + * raise ValueError("dA derivative is None") + * + */ + __pyx_t_7 = (((PyObject *)__pyx_v_self->dA) == Py_None); + __pyx_t_8 = (__pyx_t_7 != 0); + if (__pyx_t_8) { + + /* "GPy/models/state_space_cython.pyx":360 + * cpdef dAk(self, int k): + * if self.dA is None: + * raise ValueError("dA derivative is None") # <<<<<<<<<<<<<< + * + * return self.dA # the same dirivative on each iteration + */ + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "GPy/models/state_space_cython.pyx":362 + * raise ValueError("dA derivative is None") + * + * return self.dA # the same dirivative on each iteration # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self->dA)); + __pyx_r = ((PyObject *)__pyx_v_self->dA); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":358 + * return self.A[:,:, self.index[self.A_time_var_index, k]] + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * if self.dA is None: + * raise ValueError("dA derivative is None") + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dAk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_6dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":365 + * + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset *__pyx_optional_args) { + int __pyx_v_compute_derivatives = ((int)0); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":371 + * time steps. + * """ + * return self # <<<<<<<<<<<<<< + * + * cdef class AQcompute_batch_Cython(Q_handling_Cython): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":365 + * + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset[] = "\n For reusing this object e.g. in smoother computation. It makes sence\n because necessary matrices have been already computed for all\n time steps.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_compute_derivatives; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compute_derivatives); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_compute_derivatives = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)__pyx_v_self), __pyx_v_compute_derivatives); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives; + __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython->__pyx_base.__pyx_base.reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.Std_Dynamic_Callables_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":399 + * int last_k + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + * np.ndarray[DTYPE_t, ndim=4] dAs=None, + */ + +/* Python wrapper */ +static int __pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__[] = "\n Constructor. All necessary parameters are passed here and stored \n in the opject. \n \n Input:\n -------------------\n F, L, Qc, P_inf : matrices\n Parameters of corresponding continuous state model\n dt: array\n All time steps\n compute_derivatives: bool\n Whether to calculate derivatives\n \n dP_inf, dF, dQc: 3D array\n Derivatives if they are required\n \n Output:\n -------------------\n \n "; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__; +#endif +static int __pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyArrayObject *__pyx_v_As = 0; + PyArrayObject *__pyx_v_Qs = 0; + PyArrayObject *__pyx_v_reconstruct_indices = 0; + PyArrayObject *__pyx_v_dAs = 0; + PyArrayObject *__pyx_v_dQs = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_As,&__pyx_n_s_Qs,&__pyx_n_s_reconstruct_indices,&__pyx_n_s_dAs,&__pyx_n_s_dQs,0}; + PyObject* values[5] = {0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":401 + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs, + * np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + * np.ndarray[DTYPE_t, ndim=4] dAs=None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=4] dQs=None): + * """ + */ + values[3] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":402 + * np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + * np.ndarray[DTYPE_t, ndim=4] dAs=None, + * np.ndarray[DTYPE_t, ndim=4] dQs=None): # <<<<<<<<<<<<<< + * """ + * Constructor. All necessary parameters are passed here and stored + */ + values[4] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_As)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Qs)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reconstruct_indices)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dAs); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dQs); + if (value) { values[4] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_As = ((PyArrayObject *)values[0]); + __pyx_v_Qs = ((PyArrayObject *)values[1]); + __pyx_v_reconstruct_indices = ((PyArrayObject *)values[2]); + __pyx_v_dAs = ((PyArrayObject *)values[3]); + __pyx_v_dQs = ((PyArrayObject *)values[4]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_As), __pyx_ptype_5numpy_ndarray, 1, "As", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_Qs), __pyx_ptype_5numpy_ndarray, 1, "Qs", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reconstruct_indices), __pyx_ptype_5numpy_ndarray, 1, "reconstruct_indices", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dAs), __pyx_ptype_5numpy_ndarray, 1, "dAs", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dQs), __pyx_ptype_5numpy_ndarray, 1, "dQs", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_As, __pyx_v_Qs, __pyx_v_reconstruct_indices, __pyx_v_dAs, __pyx_v_dQs); + + /* "GPy/models/state_space_cython.pyx":399 + * int last_k + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + * np.ndarray[DTYPE_t, ndim=4] dAs=None, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, PyArrayObject *__pyx_v_As, PyArrayObject *__pyx_v_Qs, PyArrayObject *__pyx_v_reconstruct_indices, PyArrayObject *__pyx_v_dAs, PyArrayObject *__pyx_v_dQs) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_As; + __Pyx_Buffer __pyx_pybuffer_As; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Qs; + __Pyx_Buffer __pyx_pybuffer_Qs; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dAs; + __Pyx_Buffer __pyx_pybuffer_dAs; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dQs; + __Pyx_Buffer __pyx_pybuffer_dQs; + __Pyx_LocalBuf_ND __pyx_pybuffernd_reconstruct_indices; + __Pyx_Buffer __pyx_pybuffer_reconstruct_indices; + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_pybuffer_As.pybuffer.buf = NULL; + __pyx_pybuffer_As.refcount = 0; + __pyx_pybuffernd_As.data = NULL; + __pyx_pybuffernd_As.rcbuffer = &__pyx_pybuffer_As; + __pyx_pybuffer_Qs.pybuffer.buf = NULL; + __pyx_pybuffer_Qs.refcount = 0; + __pyx_pybuffernd_Qs.data = NULL; + __pyx_pybuffernd_Qs.rcbuffer = &__pyx_pybuffer_Qs; + __pyx_pybuffer_reconstruct_indices.pybuffer.buf = NULL; + __pyx_pybuffer_reconstruct_indices.refcount = 0; + __pyx_pybuffernd_reconstruct_indices.data = NULL; + __pyx_pybuffernd_reconstruct_indices.rcbuffer = &__pyx_pybuffer_reconstruct_indices; + __pyx_pybuffer_dAs.pybuffer.buf = NULL; + __pyx_pybuffer_dAs.refcount = 0; + __pyx_pybuffernd_dAs.data = NULL; + __pyx_pybuffernd_dAs.rcbuffer = &__pyx_pybuffer_dAs; + __pyx_pybuffer_dQs.pybuffer.buf = NULL; + __pyx_pybuffer_dQs.refcount = 0; + __pyx_pybuffernd_dQs.data = NULL; + __pyx_pybuffernd_dQs.rcbuffer = &__pyx_pybuffer_dQs; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_As.rcbuffer->pybuffer, (PyObject*)__pyx_v_As, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_As.diminfo[0].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_As.diminfo[0].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_As.diminfo[1].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_As.diminfo[1].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_As.diminfo[2].strides = __pyx_pybuffernd_As.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_As.diminfo[2].shape = __pyx_pybuffernd_As.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer, (PyObject*)__pyx_v_Qs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_Qs.diminfo[0].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Qs.diminfo[0].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Qs.diminfo[1].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Qs.diminfo[1].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_Qs.diminfo[2].strides = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_Qs.diminfo[2].shape = __pyx_pybuffernd_Qs.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_reconstruct_indices, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_int_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_reconstruct_indices.diminfo[0].strides = __pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_reconstruct_indices.diminfo[0].shape = __pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer.shape[0]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer, (PyObject*)__pyx_v_dAs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dAs.diminfo[0].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dAs.diminfo[0].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dAs.diminfo[1].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dAs.diminfo[1].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dAs.diminfo[2].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dAs.diminfo[2].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[2]; __pyx_pybuffernd_dAs.diminfo[3].strides = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.strides[3]; __pyx_pybuffernd_dAs.diminfo[3].shape = __pyx_pybuffernd_dAs.rcbuffer->pybuffer.shape[3]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQs, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 4, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dQs.diminfo[0].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQs.diminfo[0].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQs.diminfo[1].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQs.diminfo[1].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQs.diminfo[2].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQs.diminfo[2].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[2]; __pyx_pybuffernd_dQs.diminfo[3].strides = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.strides[3]; __pyx_pybuffernd_dQs.diminfo[3].shape = __pyx_pybuffernd_dQs.rcbuffer->pybuffer.shape[3]; + + /* "GPy/models/state_space_cython.pyx":424 + * """ + * + * self.As = As # <<<<<<<<<<<<<< + * self.Qs = Qs + * self.dAs = dAs + */ + __Pyx_INCREF(((PyObject *)__pyx_v_As)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_As)); + __Pyx_GOTREF(__pyx_v_self->As); + __Pyx_DECREF(((PyObject *)__pyx_v_self->As)); + __pyx_v_self->As = ((PyArrayObject *)__pyx_v_As); + + /* "GPy/models/state_space_cython.pyx":425 + * + * self.As = As + * self.Qs = Qs # <<<<<<<<<<<<<< + * self.dAs = dAs + * self.dQs = dQs + */ + __Pyx_INCREF(((PyObject *)__pyx_v_Qs)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Qs)); + __Pyx_GOTREF(__pyx_v_self->Qs); + __Pyx_DECREF(((PyObject *)__pyx_v_self->Qs)); + __pyx_v_self->Qs = ((PyArrayObject *)__pyx_v_Qs); + + /* "GPy/models/state_space_cython.pyx":426 + * self.As = As + * self.Qs = Qs + * self.dAs = dAs # <<<<<<<<<<<<<< + * self.dQs = dQs + * self.reconstruct_indices = reconstruct_indices + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dAs)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dAs)); + __Pyx_GOTREF(__pyx_v_self->dAs); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dAs)); + __pyx_v_self->dAs = ((PyArrayObject *)__pyx_v_dAs); + + /* "GPy/models/state_space_cython.pyx":427 + * self.Qs = Qs + * self.dAs = dAs + * self.dQs = dQs # <<<<<<<<<<<<<< + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + */ + __Pyx_INCREF(((PyObject *)__pyx_v_dQs)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dQs)); + __Pyx_GOTREF(__pyx_v_self->dQs); + __Pyx_DECREF(((PyObject *)__pyx_v_self->dQs)); + __pyx_v_self->dQs = ((PyArrayObject *)__pyx_v_dQs); + + /* "GPy/models/state_space_cython.pyx":428 + * self.dAs = dAs + * self.dQs = dQs + * self.reconstruct_indices = reconstruct_indices # <<<<<<<<<<<<<< + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + */ + __Pyx_INCREF(((PyObject *)__pyx_v_reconstruct_indices)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_reconstruct_indices)); + __Pyx_GOTREF(__pyx_v_self->reconstruct_indices); + __Pyx_DECREF(((PyObject *)__pyx_v_self->reconstruct_indices)); + __pyx_v_self->reconstruct_indices = ((PyArrayObject *)__pyx_v_reconstruct_indices); + + /* "GPy/models/state_space_cython.pyx":429 + * self.dQs = dQs + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ # <<<<<<<<<<<<<< + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->As), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->Qs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":430 + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ # <<<<<<<<<<<<<< + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + */ + __pyx_t_4 = (((PyObject *)__pyx_v_self->dAs) != Py_None); + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dAs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + } + + /* "GPy/models/state_space_cython.pyx":429 + * self.dQs = dQs + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ # <<<<<<<<<<<<<< + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + */ + __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":431 + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ # <<<<<<<<<<<<<< + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + * + */ + __pyx_t_4 = (((PyObject *)__pyx_v_self->dQs) != Py_None); + if ((__pyx_t_4 != 0)) { + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->dQs), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __pyx_t_3; + __pyx_t_3 = 0; + } else { + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + } + + /* "GPy/models/state_space_cython.pyx":430 + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ # <<<<<<<<<<<<<< + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + */ + __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":432 + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) # <<<<<<<<<<<<<< + * + * self.Q_svd_dict = {} + */ + __pyx_t_4 = (((PyObject *)__pyx_v_self->reconstruct_indices) != Py_None); + if ((__pyx_t_4 != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_n_s_nbytes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __Pyx_INCREF(__pyx_int_0); + __pyx_t_2 = __pyx_int_0; + } + + /* "GPy/models/state_space_cython.pyx":431 + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ # <<<<<<<<<<<<<< + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + * + */ + __pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":429 + * self.dQs = dQs + * self.reconstruct_indices = reconstruct_indices + * self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ # <<<<<<<<<<<<<< + * (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + * (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + */ + if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_total_size_of_data, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":434 + * (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + * + * self.Q_svd_dict = {} # <<<<<<<<<<<<<< + * self.last_k = 0 + * # !!!Print statistics! Which object is created + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->Q_svd_dict); + __Pyx_DECREF(__pyx_v_self->Q_svd_dict); + __pyx_v_self->Q_svd_dict = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":435 + * + * self.Q_svd_dict = {} + * self.last_k = 0 # <<<<<<<<<<<<<< + * # !!!Print statistics! Which object is created + * # !!!Print statistics! Print sizes of matrices + */ + __pyx_v_self->last_k = 0; + + /* "GPy/models/state_space_cython.pyx":399 + * int last_k + * + * def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + * np.ndarray[DTYPE_t, ndim=4] dAs=None, + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_As.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_As.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Qs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dAs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQs.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_reconstruct_indices.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":438 + * # !!!Print statistics! Which object is created + * # !!!Print statistics! Print sizes of matrices + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * """ + * Dynamic model + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(CYTHON_UNUSED struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, CYTHON_UNUSED int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_f_a); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":442 + * Dynamic model + * """ + * return np.dot(A, m) # default dynamic model # <<<<<<<<<<<<<< + * + * cpdef reset(self, bint compute_derivatives=False): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_dot); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __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; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_2) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":438 + * # !!!Print statistics! Which object is created + * # !!!Print statistics! Print sizes of matrices + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): # <<<<<<<<<<<<<< + * """ + * Dynamic model + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a[] = "\n Dynamic model\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_A = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("f_a (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_A,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_A)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "f_a") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_A = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("f_a", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_A), __pyx_ptype_5numpy_ndarray, 1, "A", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_A); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_A) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("f_a", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_v_A, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_A), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.f_a", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":444 + * return np.dot(A, m) # default dynamic model + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset *__pyx_optional_args) { + int __pyx_v_compute_derivatives = ((int)0); + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + if (__pyx_optional_args) { + if (__pyx_optional_args->__pyx_n > 0) { + __pyx_v_compute_derivatives = __pyx_optional_args->compute_derivatives; + } + } + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_compute_derivatives); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":450 + * time steps. + * """ + * return self # <<<<<<<<<<<<<< + * + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __pyx_r = ((PyObject *)__pyx_v_self); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":444 + * return np.dot(A, m) # default dynamic model + * + * cpdef reset(self, bint compute_derivatives=False): # <<<<<<<<<<<<<< + * """ + * For reusing this object e.g. in smoother computation. It makes sence + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset[] = "\n For reusing this object e.g. in smoother computation. It makes sence\n because necessary matrices have been already computed for all\n time steps.\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_compute_derivatives; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reset (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_compute_derivatives,0}; + PyObject* values[1] = {0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_compute_derivatives); + if (value) { values[0] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reset") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + } + if (values[0]) { + __pyx_v_compute_derivatives = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_compute_derivatives == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_compute_derivatives = ((int)0); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("reset", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_compute_derivatives); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_compute_derivatives) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reset", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2.__pyx_n = 1; + __pyx_t_2.compute_derivatives = __pyx_v_compute_derivatives; + __pyx_t_1 = __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython->__pyx_base.__pyx_base.reset(((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_self), 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.reset", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":452 + * return self + * + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.As[:,:, self.reconstruct_indices[k]] + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, CYTHON_UNUSED PyArrayObject *__pyx_v_m, CYTHON_UNUSED PyArrayObject *__pyx_v_P, int __pyx_skip_dispatch) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P; + __Pyx_Buffer __pyx_pybuffer_P; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_P.pybuffer.buf = NULL; + __pyx_pybuffer_P.refcount = 0; + __pyx_pybuffernd_P.data = NULL; + __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Ak); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + __pyx_t_6 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_6 = 1; + } + } + __pyx_t_7 = PyTuple_New(3+__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(((PyObject *)__pyx_v_m)); + PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, ((PyObject *)__pyx_v_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m)); + __Pyx_INCREF(((PyObject *)__pyx_v_P)); + PyTuple_SET_ITEM(__pyx_t_7, 2+__pyx_t_6, ((PyObject *)__pyx_v_P)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P)); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":453 + * + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): + * self.last_k = k # <<<<<<<<<<<<<< + * return self.As[:,:, self.reconstruct_indices[k]] + * + */ + __pyx_v_self->last_k = __pyx_v_k; + + /* "GPy/models/state_space_cython.pyx":454 + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): + * self.last_k = k + * return self.As[:,:, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef Qk(self,int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__31); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__31); + __Pyx_GIVEREF(__pyx_slice__31); + __Pyx_INCREF(__pyx_slice__32); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__32); + __Pyx_GIVEREF(__pyx_slice__32); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->As), __pyx_t_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":452 + * return self + * + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.As[:,:, self.reconstruct_indices[k]] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_k; + PyArrayObject *__pyx_v_m = 0; + PyArrayObject *__pyx_v_P = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Ak (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_m,&__pyx_n_s_P,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "Ak") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_k = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_m = ((PyArrayObject *)values[1]); + __pyx_v_P = ((PyArrayObject *)values[2]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("Ak", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m), __pyx_ptype_5numpy_ndarray, 1, "m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P), __pyx_ptype_5numpy_ndarray, 1, "P", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), __pyx_v_k, __pyx_v_m, __pyx_v_P); + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_6Ak(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, PyArrayObject *__pyx_v_m, PyArrayObject *__pyx_v_P) { + __Pyx_LocalBuf_ND __pyx_pybuffernd_P; + __Pyx_Buffer __pyx_pybuffer_P; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m; + __Pyx_Buffer __pyx_pybuffer_m; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Ak", 0); + __pyx_pybuffer_m.pybuffer.buf = NULL; + __pyx_pybuffer_m.refcount = 0; + __pyx_pybuffernd_m.data = NULL; + __pyx_pybuffernd_m.rcbuffer = &__pyx_pybuffer_m; + __pyx_pybuffer_P.pybuffer.buf = NULL; + __pyx_pybuffer_P.refcount = 0; + __pyx_pybuffernd_P.data = NULL; + __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m.diminfo[0].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m.diminfo[0].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m.diminfo[1].strides = __pyx_pybuffernd_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m.diminfo[1].shape = __pyx_pybuffernd_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_v_P, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak(__pyx_v_self, __pyx_v_k, ((PyArrayObject *)__pyx_v_m), ((PyArrayObject *)__pyx_v_P), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Ak", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":456 + * return self.As[:,:, self.reconstruct_indices[k]] + * + * cpdef Qk(self,int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.Qs[:,:, self.reconstruct_indices[k]] + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Qk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":457 + * + * cpdef Qk(self,int k): + * self.last_k = k # <<<<<<<<<<<<<< + * return self.Qs[:,:, self.reconstruct_indices[k]] + * + */ + __pyx_v_self->last_k = __pyx_v_k; + + /* "GPy/models/state_space_cython.pyx":458 + * cpdef Qk(self,int k): + * self.last_k = k + * return self.Qs[:,:, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__33); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__33); + __Pyx_GIVEREF(__pyx_slice__33); + __Pyx_INCREF(__pyx_slice__34); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__34); + __Pyx_GIVEREF(__pyx_slice__34); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->Qs), __pyx_t_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":456 + * return self.As[:,:, self.reconstruct_indices[k]] + * + * cpdef Qk(self,int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.Qs[:,:, self.reconstruct_indices[k]] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Qk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_8Qk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Qk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Qk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":460 + * return self.Qs[:,:, self.reconstruct_indices[k]] + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.dAs[:,:, :, self.reconstruct_indices[k]] + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dAk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":461 + * + * cpdef dAk(self, int k): + * self.last_k = k # <<<<<<<<<<<<<< + * return self.dAs[:,:, :, self.reconstruct_indices[k]] + * + */ + __pyx_v_self->last_k = __pyx_v_k; + + /* "GPy/models/state_space_cython.pyx":462 + * cpdef dAk(self, int k): + * self.last_k = k + * return self.dAs[:,:, :, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__35); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__35); + __Pyx_GIVEREF(__pyx_slice__35); + __Pyx_INCREF(__pyx_slice__36); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__36); + __Pyx_GIVEREF(__pyx_slice__36); + __Pyx_INCREF(__pyx_slice__37); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_slice__37); + __Pyx_GIVEREF(__pyx_slice__37); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->dAs), __pyx_t_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":460 + * return self.Qs[:,:, self.reconstruct_indices[k]] + * + * cpdef dAk(self, int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.dAs[:,:, :, self.reconstruct_indices[k]] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dAk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_10dAk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dAk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dAk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":464 + * return self.dAs[:,:, :, self.reconstruct_indices[k]] + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.dQs[:,:, :, self.reconstruct_indices[k]] + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_dQk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":465 + * + * cpdef dQk(self, int k): + * self.last_k = k # <<<<<<<<<<<<<< + * return self.dQs[:,:, :, self.reconstruct_indices[k]] + * + */ + __pyx_v_self->last_k = __pyx_v_k; + + /* "GPy/models/state_space_cython.pyx":466 + * cpdef dQk(self, int k): + * self.last_k = k + * return self.dQs[:,:, :, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(((int)__pyx_t_7)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__38); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_slice__38); + __Pyx_GIVEREF(__pyx_slice__38); + __Pyx_INCREF(__pyx_slice__39); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_slice__39); + __Pyx_GIVEREF(__pyx_slice__39); + __Pyx_INCREF(__pyx_slice__40); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_slice__40); + __Pyx_GIVEREF(__pyx_slice__40); + PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->dQs), __pyx_t_2); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":464 + * return self.dAs[:,:, :, self.reconstruct_indices[k]] + * + * cpdef dQk(self, int k): # <<<<<<<<<<<<<< + * self.last_k = k + * return self.dQs[:,:, :, self.reconstruct_indices[k]] + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("dQk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_12dQk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("dQk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.dQk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":469 + * + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * """ + * Square root of the noise matrix Q + */ + +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static PyObject *__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k, int __pyx_skip_dispatch) { + int __pyx_v_matrix_index; + PyArrayObject *__pyx_v_square_root = 0; + PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_square_root; + __Pyx_Buffer __pyx_pybuffer_square_root; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + PyArrayObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *(*__pyx_t_14)(PyObject *); + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + __pyx_pybuffer_square_root.pybuffer.buf = NULL; + __pyx_pybuffer_square_root.refcount = 0; + __pyx_pybuffernd_square_root.data = NULL; + __pyx_pybuffernd_square_root.rcbuffer = &__pyx_pybuffer_square_root; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + /* Check if called by wrapper */ + if (unlikely(__pyx_skip_dispatch)) ; + /* Check if overridden in Python */ + else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_Q_srk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk)) { + __Pyx_XDECREF(__pyx_r); + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_5) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + + /* "GPy/models/state_space_cython.pyx":474 + * """ + * + * cdef int matrix_index = self.reconstruct_indices[k] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] square_root + * + */ + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->reconstruct_indices), __pyx_v_k, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_matrix_index = ((int)__pyx_t_7); + + /* "GPy/models/state_space_cython.pyx":481 + * cdef np.ndarray[DTYPE_t, ndim=2] Vh + * + * if matrix_index in self.Q_svd_dict: # <<<<<<<<<<<<<< + * square_root = self.Q_svd_dict[matrix_index] + * else: + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_8 = (__Pyx_PyDict_Contains(__pyx_t_1, __pyx_v_self->Q_svd_dict, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = (__pyx_t_8 != 0); + if (__pyx_t_9) { + + /* "GPy/models/state_space_cython.pyx":482 + * + * if matrix_index in self.Q_svd_dict: + * square_root = self.Q_svd_dict[matrix_index] # <<<<<<<<<<<<<< + * else: + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], + */ + if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyDict_GetItem(__pyx_v_self->Q_svd_dict, __pyx_t_1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":484 + * square_root = self.Q_svd_dict[matrix_index] + * else: + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], # <<<<<<<<<<<<<< + * full_matrices=False, compute_uv=True, + * overwrite_a=False, check_finite=False) + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_linalg); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_svd); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_slice__41); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_slice__41); + __Pyx_GIVEREF(__pyx_slice__41); + __Pyx_INCREF(__pyx_slice__42); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__42); + __Pyx_GIVEREF(__pyx_slice__42); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_self->Qs), __pyx_t_4); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __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 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "GPy/models/state_space_cython.pyx":485 + * else: + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], + * full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False, check_finite=False) + * + */ + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":486 + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], + * full_matrices=False, compute_uv=True, + * overwrite_a=False, check_finite=False) # <<<<<<<<<<<<<< + * + * square_root = U * np.sqrt(S) + */ + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_check_finite, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":484 + * square_root = self.Q_svd_dict[matrix_index] + * else: + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], # <<<<<<<<<<<<<< + * full_matrices=False, compute_uv=True, + * overwrite_a=False, check_finite=False) + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { + PyObject* sequence = __pyx_t_6; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_4 = PyList_GET_ITEM(sequence, 1); + __pyx_t_2 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + #endif + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_3 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_3)->tp_iternext; + index = 0; __pyx_t_1 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L4_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 1; __pyx_t_4 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_4)) goto __pyx_L4_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + index = 2; __pyx_t_2 = __pyx_t_14(__pyx_t_3); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_3), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L5_unpacking_done; + __pyx_L4_unpacking_failed:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L5_unpacking_done:; + } + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":488 + * overwrite_a=False, check_finite=False) + * + * square_root = U * np.sqrt(S) # <<<<<<<<<<<<<< + * self.Q_svd_dict[matrix_index] = square_root + * + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __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; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_2)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_2) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Multiply(((PyObject *)__pyx_v_U), __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_t_7 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_7 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer, (PyObject*)__pyx_v_square_root, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_square_root.diminfo[0].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_square_root.diminfo[0].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_square_root.diminfo[1].strides = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_square_root.diminfo[1].shape = __pyx_pybuffernd_square_root.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __pyx_v_square_root = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":489 + * + * square_root = U * np.sqrt(S) + * self.Q_svd_dict[matrix_index] = square_root # <<<<<<<<<<<<<< + * + * return square_root + */ + if (unlikely(__pyx_v_self->Q_svd_dict == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_matrix_index); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(PyDict_SetItem(__pyx_v_self->Q_svd_dict, __pyx_t_4, ((PyObject *)__pyx_v_square_root)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":491 + * self.Q_svd_dict[matrix_index] = square_root + * + * return square_root # <<<<<<<<<<<<<< + * + * # def return_last(self): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_square_root)); + __pyx_r = ((PyObject *)__pyx_v_square_root); + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":469 + * + * + * cpdef Q_srk(self, int k): # <<<<<<<<<<<<<< + * """ + * Square root of the noise matrix Q + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_square_root.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_square_root); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk[] = "\n Square root of the noise matrix Q\n "; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk(PyObject *__pyx_v_self, PyObject *__pyx_arg_k) { + int __pyx_v_k; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("Q_srk (wrapper)", 0); + assert(__pyx_arg_k); { + __pyx_v_k = __Pyx_PyInt_As_int(__pyx_arg_k); if (unlikely((__pyx_v_k == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)__pyx_v_self), ((int)__pyx_v_k)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *__pyx_v_self, int __pyx_v_k) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("Q_srk", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk(__pyx_v_self, __pyx_v_k, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("GPy.models.state_space_cython.AQcompute_batch_Cython.Q_srk", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":510 + * + * @cython.boundscheck(False) + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, # <<<<<<<<<<<<<< + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython[] = "\n Desctrete prediction function \n \n Input:\n k:int\n Iteration No. Starts at 0. Total number of iterations equal to the \n number of measurements.\n \n p_m: matrix of size (state_dim, time_series_no)\n Mean value from the previous step. For \"multiple time series mode\" \n it is matrix, second dimension of which correspond to different\n time series.\n \n p_P: tuple (Prev_cov, S, V)\n Covariance matrix from the previous step and its SVD decomposition.\n Prev_cov = V * S * V.T The tuple is (Prev_cov, S, V) \n \n p_a: function (k, x_{k-1}, A_{k}). Dynamic function. \n k (iteration number), starts at 0\n x_{k-1} State from the previous step\n A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}.\n \n p_f_A: function (k, m, P) return Jacobian of dynamic function, it is\n passed into p_a.\n k (iteration number), starts at 0\n m: point where Jacobian is evaluated\n P: parameter for Jacobian, usually covariance matrix.\n \n p_f_Q: function (k). Returns noise matrix of dynamic model on iteration k.\n k (iteration number). starts at 0\n \n p_f_Qsr: function (k). Returns square root of noise matrix of the \n dynamic model on iteration k. k (iteration number). starts at 0\n \n calc_grad_log_likelihood: boolean\n Whether to calculate gradient of the marginal likelihood \n of the state-space model. If true then the next parameter must \n provide the extra parameters for gradient calculation.\n \n p_dm: 3D array (state_dim, time_series_no, parameters_no)\n Mean derivatives from the previous step. For \"multiple time series mode\" \n it is 3D array, second dimension"" of which correspond to different\n time series.\n \n p_dP: 3D array (state_dim, state_dim, parameters_no)\n Mean derivatives from the previous step\n \n grad_calc_params_1: List or None\n List with derivatives. The first component is 'f_dA' - function(k)\n which returns the derivative of A. The second element is 'f_dQ'\n - function(k). Function which returns the derivative of Q.\n \n Output:\n ----------------------------\n m_pred, P_pred, dm_pred, dP_pred: metrices, 3D objects\n Results of the prediction steps. \n \n "; +static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython = {"_kalman_prediction_step_SVD_Cython", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython}; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + long __pyx_v_k; + PyArrayObject *__pyx_v_p_m = 0; + PyObject *__pyx_v_p_P = 0; + struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables = 0; + int __pyx_v_calc_grad_log_likelihood; + PyArrayObject *__pyx_v_p_dm = 0; + PyArrayObject *__pyx_v_p_dP = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_kalman_prediction_step_SVD_Cython (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_p_m,&__pyx_n_s_p_P,&__pyx_n_s_p_dynamic_callables,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_p_dm,&__pyx_n_s_p_dP,0}; + PyObject* values[7] = {0,0,0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":513 + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): + * """ + */ + values[5] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":514 + * bint calc_grad_log_likelihood=False, + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): # <<<<<<<<<<<<<< + * """ + * Desctrete prediction function + */ + values[6] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_P)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dynamic_callables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dm); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dP); + if (value) { values[6] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_kalman_prediction_step_SVD_Cython") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_k = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_k == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_p_m = ((PyArrayObject *)values[1]); + __pyx_v_p_P = ((PyObject*)values[2]); + __pyx_v_p_dynamic_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)values[3]); + if (values[4]) { + __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[4]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 512; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "GPy/models/state_space_cython.pyx":512 + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): + */ + __pyx_v_calc_grad_log_likelihood = ((int)0); + } + __pyx_v_p_dm = ((PyArrayObject *)values[5]); + __pyx_v_p_dP = ((PyArrayObject *)values[6]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_kalman_prediction_step_SVD_Cython", 0, 4, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_prediction_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_m), __pyx_ptype_5numpy_ndarray, 1, "p_m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_P), (&PyTuple_Type), 1, "p_P", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dynamic_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, 1, "p_dynamic_callables", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dm), __pyx_ptype_5numpy_ndarray, 1, "p_dm", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 513; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dP), __pyx_ptype_5numpy_ndarray, 1, "p_dP", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(__pyx_self, __pyx_v_k, __pyx_v_p_m, __pyx_v_p_P, __pyx_v_p_dynamic_callables, __pyx_v_calc_grad_log_likelihood, __pyx_v_p_dm, __pyx_v_p_dP); + + /* "GPy/models/state_space_cython.pyx":510 + * + * @cython.boundscheck(False) + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, # <<<<<<<<<<<<<< + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython__kalman_prediction_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP) { + PyArrayObject *__pyx_v_Prev_cov = 0; + PyArrayObject *__pyx_v_S_old = 0; + PyArrayObject *__pyx_v_V_old = 0; + PyArrayObject *__pyx_v_A = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_Q = 0; + PyArrayObject *__pyx_v_Q_sr = 0; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_svd_1_matr = 0; + PyObject *__pyx_v_res = NULL; + CYTHON_UNUSED PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S = 0; + PyArrayObject *__pyx_v_Vh = 0; + PyArrayObject *__pyx_v_V_new = 0; + PyArrayObject *__pyx_v_S_new = 0; + PyArrayObject *__pyx_v_P_pred = 0; + PyArrayObject *__pyx_v_dA_all_params = 0; + PyArrayObject *__pyx_v_dQ_all_params = 0; + PyArrayObject *__pyx_v_dm_pred = 0; + PyArrayObject *__pyx_v_dP_pred = 0; + int __pyx_v_param_number; + int __pyx_v_j; + PyObject *__pyx_v_ret = 0; + PyArrayObject *__pyx_v_dA = 0; + PyArrayObject *__pyx_v_dQ = 0; + __Pyx_LocalBuf_ND __pyx_pybuffernd_A; + __Pyx_Buffer __pyx_pybuffer_A; + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Prev_cov; + __Pyx_Buffer __pyx_pybuffer_Prev_cov; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Q; + __Pyx_Buffer __pyx_pybuffer_Q; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Q_sr; + __Pyx_Buffer __pyx_pybuffer_Q_sr; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S_new; + __Pyx_Buffer __pyx_pybuffer_S_new; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S_old; + __Pyx_Buffer __pyx_pybuffer_S_old; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_V_new; + __Pyx_Buffer __pyx_pybuffer_V_new; + __Pyx_LocalBuf_ND __pyx_pybuffernd_V_old; + __Pyx_Buffer __pyx_pybuffer_V_old; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dA; + __Pyx_Buffer __pyx_pybuffer_dA; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dA_all_params; + __Pyx_Buffer __pyx_pybuffer_dA_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred; + __Pyx_Buffer __pyx_pybuffer_dP_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ; + __Pyx_Buffer __pyx_pybuffer_dQ; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dQ_all_params; + __Pyx_Buffer __pyx_pybuffer_dQ_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred; + __Pyx_Buffer __pyx_pybuffer_dm_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dP; + __Pyx_Buffer __pyx_pybuffer_p_dP; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dm; + __Pyx_Buffer __pyx_pybuffer_p_dm; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_m; + __Pyx_Buffer __pyx_pybuffer_p_m; + __Pyx_LocalBuf_ND __pyx_pybuffernd_svd_1_matr; + __Pyx_Buffer __pyx_pybuffer_svd_1_matr; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyArrayObject *__pyx_t_2 = NULL; + PyArrayObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyArrayObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + Py_ssize_t __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyArrayObject *__pyx_t_13 = NULL; + PyArrayObject *__pyx_t_14 = NULL; + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + PyArrayObject *__pyx_t_18 = NULL; + PyArrayObject *__pyx_t_19 = NULL; + int __pyx_t_20; + PyArrayObject *__pyx_t_21 = NULL; + int __pyx_t_22; + PyObject *__pyx_t_23 = NULL; + PyObject *__pyx_t_24 = NULL; + PyObject *__pyx_t_25 = NULL; + PyArrayObject *__pyx_t_26 = NULL; + PyArrayObject *__pyx_t_27 = NULL; + PyArrayObject *__pyx_t_28 = NULL; + int __pyx_t_29; + PyArrayObject *__pyx_t_30 = NULL; + int __pyx_t_31; + PyArrayObject *__pyx_t_32 = NULL; + PyObject *__pyx_t_33 = NULL; + PyObject *__pyx_t_34 = NULL; + PyObject *__pyx_t_35 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_kalman_prediction_step_SVD_Cython", 0); + __pyx_pybuffer_Prev_cov.pybuffer.buf = NULL; + __pyx_pybuffer_Prev_cov.refcount = 0; + __pyx_pybuffernd_Prev_cov.data = NULL; + __pyx_pybuffernd_Prev_cov.rcbuffer = &__pyx_pybuffer_Prev_cov; + __pyx_pybuffer_S_old.pybuffer.buf = NULL; + __pyx_pybuffer_S_old.refcount = 0; + __pyx_pybuffernd_S_old.data = NULL; + __pyx_pybuffernd_S_old.rcbuffer = &__pyx_pybuffer_S_old; + __pyx_pybuffer_V_old.pybuffer.buf = NULL; + __pyx_pybuffer_V_old.refcount = 0; + __pyx_pybuffernd_V_old.data = NULL; + __pyx_pybuffernd_V_old.rcbuffer = &__pyx_pybuffer_V_old; + __pyx_pybuffer_A.pybuffer.buf = NULL; + __pyx_pybuffer_A.refcount = 0; + __pyx_pybuffernd_A.data = NULL; + __pyx_pybuffernd_A.rcbuffer = &__pyx_pybuffer_A; + __pyx_pybuffer_Q.pybuffer.buf = NULL; + __pyx_pybuffer_Q.refcount = 0; + __pyx_pybuffernd_Q.data = NULL; + __pyx_pybuffernd_Q.rcbuffer = &__pyx_pybuffer_Q; + __pyx_pybuffer_Q_sr.pybuffer.buf = NULL; + __pyx_pybuffer_Q_sr.refcount = 0; + __pyx_pybuffernd_Q_sr.data = NULL; + __pyx_pybuffernd_Q_sr.rcbuffer = &__pyx_pybuffer_Q_sr; + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_svd_1_matr.pybuffer.buf = NULL; + __pyx_pybuffer_svd_1_matr.refcount = 0; + __pyx_pybuffernd_svd_1_matr.data = NULL; + __pyx_pybuffernd_svd_1_matr.rcbuffer = &__pyx_pybuffer_svd_1_matr; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + __pyx_pybuffer_V_new.pybuffer.buf = NULL; + __pyx_pybuffer_V_new.refcount = 0; + __pyx_pybuffernd_V_new.data = NULL; + __pyx_pybuffernd_V_new.rcbuffer = &__pyx_pybuffer_V_new; + __pyx_pybuffer_S_new.pybuffer.buf = NULL; + __pyx_pybuffer_S_new.refcount = 0; + __pyx_pybuffernd_S_new.data = NULL; + __pyx_pybuffernd_S_new.rcbuffer = &__pyx_pybuffer_S_new; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + __pyx_pybuffer_dA_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dA_all_params.refcount = 0; + __pyx_pybuffernd_dA_all_params.data = NULL; + __pyx_pybuffernd_dA_all_params.rcbuffer = &__pyx_pybuffer_dA_all_params; + __pyx_pybuffer_dQ_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dQ_all_params.refcount = 0; + __pyx_pybuffernd_dQ_all_params.data = NULL; + __pyx_pybuffernd_dQ_all_params.rcbuffer = &__pyx_pybuffer_dQ_all_params; + __pyx_pybuffer_dm_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dm_pred.refcount = 0; + __pyx_pybuffernd_dm_pred.data = NULL; + __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred; + __pyx_pybuffer_dP_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dP_pred.refcount = 0; + __pyx_pybuffernd_dP_pred.data = NULL; + __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred; + __pyx_pybuffer_dA.pybuffer.buf = NULL; + __pyx_pybuffer_dA.refcount = 0; + __pyx_pybuffernd_dA.data = NULL; + __pyx_pybuffernd_dA.rcbuffer = &__pyx_pybuffer_dA; + __pyx_pybuffer_dQ.pybuffer.buf = NULL; + __pyx_pybuffer_dQ.refcount = 0; + __pyx_pybuffernd_dQ.data = NULL; + __pyx_pybuffernd_dQ.rcbuffer = &__pyx_pybuffer_dQ; + __pyx_pybuffer_p_m.pybuffer.buf = NULL; + __pyx_pybuffer_p_m.refcount = 0; + __pyx_pybuffernd_p_m.data = NULL; + __pyx_pybuffernd_p_m.rcbuffer = &__pyx_pybuffer_p_m; + __pyx_pybuffer_p_dm.pybuffer.buf = NULL; + __pyx_pybuffer_p_dm.refcount = 0; + __pyx_pybuffernd_p_dm.data = NULL; + __pyx_pybuffernd_p_dm.rcbuffer = &__pyx_pybuffer_p_dm; + __pyx_pybuffer_p_dP.pybuffer.buf = NULL; + __pyx_pybuffer_p_dP.refcount = 0; + __pyx_pybuffernd_p_dP.data = NULL; + __pyx_pybuffernd_p_dP.rcbuffer = &__pyx_pybuffer_p_dP; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_m.diminfo[0].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_m.diminfo[0].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_m.diminfo[1].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_m.diminfo[1].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dm, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_dm.diminfo[0].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dm.diminfo[0].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dm.diminfo[1].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dm.diminfo[1].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dm.diminfo[2].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dm.diminfo[2].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dP, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_dP.diminfo[0].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dP.diminfo[0].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dP.diminfo[1].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dP.diminfo[1].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dP.diminfo[2].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dP.diminfo[2].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":575 + * + * # covariance from the previous step# p_prev_cov = v * S * V.T + * cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1] + * cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2] + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 0)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 0), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 0); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Prev_cov = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Prev_cov.diminfo[0].strides = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Prev_cov.diminfo[0].shape = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Prev_cov.diminfo[1].strides = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Prev_cov.diminfo[1].shape = __pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_v_Prev_cov = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":576 + * # covariance from the previous step# p_prev_cov = v * S * V.T + * cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2] + * #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 1)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 1), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 1); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S_old = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_old.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S_old.diminfo[0].strides = __pyx_pybuffernd_S_old.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_old.diminfo[0].shape = __pyx_pybuffernd_S_old.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_v_S_old = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":577 + * cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1] + * cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2] # <<<<<<<<<<<<<< + * #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step + * + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 2)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 2), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 2); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_V_old = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_old.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_V_old.diminfo[0].strides = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_old.diminfo[0].shape = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_old.diminfo[1].strides = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_old.diminfo[1].shape = __pyx_pybuffernd_V_old.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_v_V_old = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":581 + * + * # index correspond to values from previous iteration. + * cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step) + * cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k) + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Ak(__pyx_v_p_dynamic_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_p_m), ((PyArrayObject *)__pyx_v_Prev_cov), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_A.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_A = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_A.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_A.diminfo[0].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_A.diminfo[0].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_A.diminfo[1].strides = __pyx_pybuffernd_A.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_A.diminfo[1].shape = __pyx_pybuffernd_A.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_2 = 0; + __pyx_v_A = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":582 + * # index correspond to values from previous iteration. + * cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian) + * cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k) + * # Prediction step -> + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Qk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Q = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Q.diminfo[0].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q.diminfo[0].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q.diminfo[1].strides = __pyx_pybuffernd_Q.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q.diminfo[1].shape = __pyx_pybuffernd_Q.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_3 = 0; + __pyx_v_Q = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":583 + * cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian) + * cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step) + * cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k) # <<<<<<<<<<<<<< + * # Prediction step -> + * cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_dynamic_callables.f_a(k, p_m, A) # predicted mean + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->Q_srk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Q_sr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 583; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Q_sr.diminfo[0].strides = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Q_sr.diminfo[0].shape = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Q_sr.diminfo[1].strides = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Q_sr.diminfo[1].shape = __pyx_pybuffernd_Q_sr.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __pyx_v_Q_sr = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":585 + * cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k) + * # Prediction step -> + * cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_dynamic_callables.f_a(k, p_m, A) # predicted mean # <<<<<<<<<<<<<< + * + * # coavariance prediction have changed: + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->f_a(__pyx_v_p_dynamic_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_p_m), ((PyArrayObject *)__pyx_v_A), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_m_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_5 = 0; + __pyx_v_m_pred = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":588 + * + * # coavariance prediction have changed: + * cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) # <<<<<<<<<<<<<< + * res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_vstack); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + } + } + if (!__pyx_t_8) { + __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_S_old)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + } else { + __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S_old)); + PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_S_old)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S_old)); + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_8); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_8, function); + __pyx_t_11 = 1; + } + } + __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_10) { + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + __Pyx_INCREF(((PyObject *)__pyx_v_V_old)); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, ((PyObject *)__pyx_v_V_old)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_V_old)); + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Multiply(__pyx_t_6, __pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_T); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Q_sr), __pyx_n_s_T); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_9 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_8) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL; + PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 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 = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_svd_1_matr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_svd_1_matr.diminfo[0].strides = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_svd_1_matr.diminfo[0].shape = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_svd_1_matr.diminfo[1].strides = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_svd_1_matr.diminfo[1].shape = __pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_13 = 0; + __pyx_v_svd_1_matr = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":589 + * # coavariance prediction have changed: + * cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) + * res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * # (U,S,Vh) + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_linalg); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_svd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(((PyObject *)__pyx_v_svd_1_matr)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_svd_1_matr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_svd_1_matr)); + __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":590 + * cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) + * res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * # (U,S,Vh) + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + */ + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":589 + * # coavariance prediction have changed: + * cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) + * res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * # (U,S,Vh) + */ + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 589; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_res = __pyx_t_6; + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":592 + * overwrite_a=False,check_finite=True) + * # (U,S,Vh) + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S = res[1] + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + */ + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_res, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_U = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_14 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":593 + * # (U,S,Vh) + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S = res[1] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + * # predicted variance computed by the regular method. For testing + */ + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_res, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_15 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":594 + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S = res[1] + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] # <<<<<<<<<<<<<< + * # predicted variance computed by the regular method. For testing + * #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q + */ + __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_res, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_16 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Vh = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Vh.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_16 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":597 + * # predicted variance computed by the regular method. For testing + * #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q + * cdef np.ndarray[DTYPE_t, ndim=2] V_new = Vh.T # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S_new = S**2 + * + */ + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_V_new = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_new.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_V_new.diminfo[0].strides = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_new.diminfo[0].shape = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_new.diminfo[1].strides = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_new.diminfo[1].shape = __pyx_pybuffernd_V_new.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_17 = 0; + __pyx_v_V_new = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":598 + * #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q + * cdef np.ndarray[DTYPE_t, ndim=2] V_new = Vh.T + * cdef np.ndarray[DTYPE_t, ndim=1] S_new = S**2 # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance + */ + __pyx_t_6 = PyNumber_Power(((PyObject *)__pyx_v_S), __pyx_int_2, Py_None); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_18 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S_new = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_new.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S_new.diminfo[0].strides = __pyx_pybuffernd_S_new.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_new.diminfo[0].shape = __pyx_pybuffernd_S_new.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_18 = 0; + __pyx_v_S_new = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":600 + * cdef np.ndarray[DTYPE_t, ndim=1] S_new = S**2 + * + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance # <<<<<<<<<<<<<< + * #tuple P_pred = (P_pred, S_new, Vh.T) + * # Prediction step <- + */ + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Multiply(((PyObject *)__pyx_v_V_new), ((PyObject *)__pyx_v_S_new)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_V_new), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_11 = 1; + } + } + __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_8) { + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_9 = 0; + __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_P_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_19 = 0; + __pyx_v_P_pred = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":617 + * cdef np.ndarray[DTYPE_t, ndim=2] dA + * cdef np.ndarray[DTYPE_t, ndim=2] dQ + * if calc_grad_log_likelihood: # <<<<<<<<<<<<<< + * dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters + * dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters + */ + __pyx_t_20 = (__pyx_v_calc_grad_log_likelihood != 0); + if (__pyx_t_20) { + + /* "GPy/models/state_space_cython.pyx":618 + * cdef np.ndarray[DTYPE_t, ndim=2] dQ + * if calc_grad_log_likelihood: + * dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters # <<<<<<<<<<<<<< + * dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters + * + */ + __pyx_t_6 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->dAk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_25); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_23, __pyx_t_24, __pyx_t_25); + } + } + __pyx_pybuffernd_dA_all_params.diminfo[0].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA_all_params.diminfo[0].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA_all_params.diminfo[1].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA_all_params.diminfo[1].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dA_all_params.diminfo[2].strides = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dA_all_params.diminfo[2].shape = __pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_21 = 0; + __pyx_v_dA_all_params = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":619 + * if calc_grad_log_likelihood: + * dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters + * dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters # <<<<<<<<<<<<<< + * + * param_number = p_dP.shape[2] + */ + __pyx_t_6 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->dQk(__pyx_v_p_dynamic_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_26 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_26, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_25, __pyx_t_24, __pyx_t_23); + } + } + __pyx_pybuffernd_dQ_all_params.diminfo[0].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ_all_params.diminfo[0].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ_all_params.diminfo[1].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ_all_params.diminfo[1].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dQ_all_params.diminfo[2].strides = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dQ_all_params.diminfo[2].shape = __pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_26 = 0; + __pyx_v_dQ_all_params = ((PyArrayObject *)__pyx_t_6); + __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":621 + * dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters + * + * param_number = p_dP.shape[2] # <<<<<<<<<<<<<< + * + * # p_dm, p_dP - derivatives form the previoius step + */ + __pyx_v_param_number = (__pyx_v_p_dP->dimensions[2]); + + /* "GPy/models/state_space_cython.pyx":624 + * + * # p_dm, p_dP - derivatives form the previoius step + * dm_pred = np.empty((p_dm.shape[0], p_dm.shape[1], p_dm.shape[2]), dtype = DTYPE) # <<<<<<<<<<<<<< + * dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE) + * + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_12 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[1])); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dm->dimensions[2])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_6 = 0; + __pyx_t_12 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_t_12) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, __pyx_t_9); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_27 = ((PyArrayObject *)__pyx_t_12); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_25); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_23, __pyx_t_24, __pyx_t_25); + } + } + __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_27 = 0; + __pyx_v_dm_pred = ((PyArrayObject *)__pyx_t_12); + __pyx_t_12 = 0; + + /* "GPy/models/state_space_cython.pyx":625 + * # p_dm, p_dP - derivatives form the previoius step + * dm_pred = np.empty((p_dm.shape[0], p_dm.shape[1], p_dm.shape[2]), dtype = DTYPE) + * dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE) # <<<<<<<<<<<<<< + * + * for j in range(param_number): + */ + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[0])); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_1 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[1])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_p_dP->dimensions[2])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_12 = 0; + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_28 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_25, __pyx_t_24, __pyx_t_23); + } + } + __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_28 = 0; + __pyx_v_dP_pred = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":627 + * dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE) + * + * for j in range(param_number): # <<<<<<<<<<<<<< + * dA = dA_all_params[:,:,j] + * dQ = dQ_all_params[:,:,j] + */ + __pyx_t_22 = __pyx_v_param_number; + for (__pyx_t_29 = 0; __pyx_t_29 < __pyx_t_22; __pyx_t_29+=1) { + __pyx_v_j = __pyx_t_29; + + /* "GPy/models/state_space_cython.pyx":628 + * + * for j in range(param_number): + * dA = dA_all_params[:,:,j] # <<<<<<<<<<<<<< + * dQ = dQ_all_params[:,:,j] + * + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_slice__43); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__43); + __Pyx_GIVEREF(__pyx_slice__43); + __Pyx_INCREF(__pyx_slice__44); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_slice__44); + __Pyx_GIVEREF(__pyx_slice__44); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dA_all_params), __pyx_t_6); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer); + __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_31 < 0)) { + PyErr_Fetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dA.rcbuffer->pybuffer, (PyObject*)__pyx_v_dA, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_25); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_23, __pyx_t_24, __pyx_t_25); + } + } + __pyx_pybuffernd_dA.diminfo[0].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dA.diminfo[0].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dA.diminfo[1].strides = __pyx_pybuffernd_dA.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dA.diminfo[1].shape = __pyx_pybuffernd_dA.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_31 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_30 = 0; + __Pyx_XDECREF_SET(__pyx_v_dA, ((PyArrayObject *)__pyx_t_1)); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":629 + * for j in range(param_number): + * dA = dA_all_params[:,:,j] + * dQ = dQ_all_params[:,:,j] # <<<<<<<<<<<<<< + * + * dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_slice__45); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_slice__45); + __Pyx_GIVEREF(__pyx_slice__45); + __Pyx_INCREF(__pyx_slice__46); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_slice__46); + __Pyx_GIVEREF(__pyx_slice__46); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dQ_all_params), __pyx_t_6); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 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 = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_32 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __pyx_t_31 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_31 < 0)) { + PyErr_Fetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer, (PyObject*)__pyx_v_dQ, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_25, __pyx_t_24, __pyx_t_23); + } + } + __pyx_pybuffernd_dQ.diminfo[0].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dQ.diminfo[0].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dQ.diminfo[1].strides = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dQ.diminfo[1].shape = __pyx_pybuffernd_dQ.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_31 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_32 = 0; + __Pyx_XDECREF_SET(__pyx_v_dQ, ((PyArrayObject *)__pyx_t_1)); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":631 + * dQ = dQ_all_params[:,:,j] + * + * dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) # <<<<<<<<<<<<<< + * # prediction step derivatives for current parameter: + * + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_11 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_6) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dA)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_11, ((PyObject *)__pyx_v_dA)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dA)); + __Pyx_INCREF(((PyObject *)__pyx_v_p_m)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_11, ((PyObject *)__pyx_v_p_m)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_p_m)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_12 = PyTuple_New(3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_INCREF(__pyx_slice__47); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_slice__47); + __Pyx_GIVEREF(__pyx_slice__47); + __Pyx_INCREF(__pyx_slice__48); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_slice__48); + __Pyx_GIVEREF(__pyx_slice__48); + PyTuple_SET_ITEM(__pyx_t_12, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_p_dm), __pyx_t_12); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + __pyx_t_11 = 1; + } + } + __pyx_t_8 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_12) { + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_11, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_11, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__49); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__49); + __Pyx_GIVEREF(__pyx_slice__49); + __Pyx_INCREF(__pyx_slice__50); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__50); + __Pyx_GIVEREF(__pyx_slice__50); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dm_pred), __pyx_t_1, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":634 + * # prediction step derivatives for current parameter: + * + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) # <<<<<<<<<<<<<< + * dP_pred[:,:,j] += dP_pred[:,:,j].T + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A), __pyx_n_s_T); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_12 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_11 = 1; + } + } + __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_12) { + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_Prev_cov)); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, ((PyObject *)__pyx_v_Prev_cov)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_Prev_cov)); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_11 = 1; + } + } + __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (__pyx_t_9) { + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dA)); + PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, ((PyObject *)__pyx_v_dA)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dA)); + PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_slice__51); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__51); + __Pyx_GIVEREF(__pyx_slice__51); + __Pyx_INCREF(__pyx_slice__52); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__52); + __Pyx_GIVEREF(__pyx_slice__52); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_10, __pyx_t_6) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + + /* "GPy/models/state_space_cython.pyx":635 + * + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + * dP_pred[:,:,j] += dP_pred[:,:,j].T # <<<<<<<<<<<<<< + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + * + */ + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_slice__53); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_slice__53); + __Pyx_GIVEREF(__pyx_slice__53); + __Pyx_INCREF(__pyx_slice__54); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_slice__54); + __Pyx_GIVEREF(__pyx_slice__54); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_10); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__55); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__55); + __Pyx_GIVEREF(__pyx_slice__55); + __Pyx_INCREF(__pyx_slice__56); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__56); + __Pyx_GIVEREF(__pyx_slice__56); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_10, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":636 + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + * dP_pred[:,:,j] += dP_pred[:,:,j].T + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ # <<<<<<<<<<<<<< + * + * dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + */ + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_slice__57); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__57); + __Pyx_GIVEREF(__pyx_slice__57); + __Pyx_INCREF(__pyx_slice__58); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__58); + __Pyx_GIVEREF(__pyx_slice__58); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_33 = PyTuple_New(3); if (unlikely(!__pyx_t_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_33); + __Pyx_INCREF(__pyx_slice__59); + PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_slice__59); + __Pyx_GIVEREF(__pyx_slice__59); + __Pyx_INCREF(__pyx_slice__60); + PyTuple_SET_ITEM(__pyx_t_33, 1, __pyx_slice__60); + __Pyx_GIVEREF(__pyx_slice__60); + PyTuple_SET_ITEM(__pyx_t_33, 2, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_GetItem(((PyObject *)__pyx_v_p_dP), __pyx_t_33); if (unlikely(__pyx_t_8 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0; + __pyx_t_33 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_A), __pyx_n_s_T); if (unlikely(!__pyx_t_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_33); + __pyx_t_34 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_34)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_34); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + __pyx_t_11 = 1; + } + } + __pyx_t_35 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_35); + if (__pyx_t_34) { + PyTuple_SET_ITEM(__pyx_t_35, 0, __pyx_t_34); __Pyx_GIVEREF(__pyx_t_34); __pyx_t_34 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_35, 0+__pyx_t_11, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_35, 1+__pyx_t_11, __pyx_t_33); + __Pyx_GIVEREF(__pyx_t_33); + __pyx_t_8 = 0; + __pyx_t_33 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_35, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_11 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_11 = 1; + } + } + __pyx_t_35 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_35); + if (__pyx_t_12) { + PyTuple_SET_ITEM(__pyx_t_35, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); __pyx_t_12 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_35, 0+__pyx_t_11, ((PyObject *)__pyx_v_A)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_A)); + PyTuple_SET_ITEM(__pyx_t_35, 1+__pyx_t_11, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_35, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(__pyx_t_1, ((PyObject *)__pyx_v_dQ)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":638 + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + * + * dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize # <<<<<<<<<<<<<< + * else: + * dm_pred = None + */ + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__61); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__61); + __Pyx_GIVEREF(__pyx_slice__61); + __Pyx_INCREF(__pyx_slice__62); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__62); + __Pyx_GIVEREF(__pyx_slice__62); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_1); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__63); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__63); + __Pyx_GIVEREF(__pyx_slice__63); + __Pyx_INCREF(__pyx_slice__64); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__64); + __Pyx_GIVEREF(__pyx_slice__64); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_9); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_T); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_slice__65); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__65); + __Pyx_GIVEREF(__pyx_slice__65); + __Pyx_INCREF(__pyx_slice__66); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__66); + __Pyx_GIVEREF(__pyx_slice__66); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_pred), __pyx_t_7, __pyx_t_9) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":640 + * dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + * else: + * dm_pred = None # <<<<<<<<<<<<<< + * dP_pred = None + * + */ + __pyx_t_27 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_27, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_23); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_25); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_23, __pyx_t_24, __pyx_t_25); + } + } + __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_27 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_dm_pred = ((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":641 + * else: + * dm_pred = None + * dP_pred = None # <<<<<<<<<<<<<< + * + * ret = (P_pred, S_new, Vh.T) + */ + __pyx_t_28 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_28, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_25); Py_XDECREF(__pyx_t_24); Py_XDECREF(__pyx_t_23); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_25, __pyx_t_24, __pyx_t_23); + } + } + __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_28 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_dP_pred = ((PyArrayObject *)Py_None); + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":643 + * dP_pred = None + * + * ret = (P_pred, S_new, Vh.T) # <<<<<<<<<<<<<< + * return m_pred, ret, dm_pred, dP_pred + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_S_new)); + PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_v_S_new)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S_new)); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_v_ret = ((PyObject*)__pyx_t_7); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":644 + * + * ret = (P_pred, S_new, Vh.T) + * return m_pred, ret, dm_pred, dP_pred # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(__pyx_v_ret); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_ret); + __Pyx_GIVEREF(__pyx_v_ret); + __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 2, ((PyObject *)__pyx_v_dm_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred)); + PyTuple_SET_ITEM(__pyx_t_7, 3, ((PyObject *)__pyx_v_dP_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred)); + __pyx_r = __pyx_t_7; + __pyx_t_7 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":510 + * + * @cython.boundscheck(False) + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, # <<<<<<<<<<<<<< + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_33); + __Pyx_XDECREF(__pyx_t_34); + __Pyx_XDECREF(__pyx_t_35); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_prediction_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_A.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Prev_cov.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Q_sr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_new.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_old.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_new.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_old.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dA_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dQ_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_1_matr.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_Prev_cov); + __Pyx_XDECREF((PyObject *)__pyx_v_S_old); + __Pyx_XDECREF((PyObject *)__pyx_v_V_old); + __Pyx_XDECREF((PyObject *)__pyx_v_A); + __Pyx_XDECREF((PyObject *)__pyx_v_Q); + __Pyx_XDECREF((PyObject *)__pyx_v_Q_sr); + __Pyx_XDECREF((PyObject *)__pyx_v_m_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_svd_1_matr); + __Pyx_XDECREF(__pyx_v_res); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XDECREF((PyObject *)__pyx_v_V_new); + __Pyx_XDECREF((PyObject *)__pyx_v_S_new); + __Pyx_XDECREF((PyObject *)__pyx_v_P_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dA_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dQ_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred); + __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XDECREF((PyObject *)__pyx_v_dA); + __Pyx_XDECREF((PyObject *)__pyx_v_dQ); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":649 + * + * @cython.boundscheck(False) + * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython[] = "\n Input:\n \n k: int\n Iteration No. Starts at 0. Total number of iterations equal to the \n number of measurements.\n \n m_P: matrix of size (state_dim, time_series_no)\n Mean value from the previous step. For \"multiple time series mode\" \n it is matrix, second dimension of which correspond to different\n time series.\n \n p_P: tuple (P_pred, S, V)\n Covariance matrix from the prediction step and its SVD decomposition.\n P_pred = V * S * V.T The tuple is (P_pred, S, V)\n \n p_h: function (k, x_{k}, H_{k}). Measurement function.\n k (iteration number), starts at 0\n x_{k} state \n H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}.\n \n p_f_H: function (k, m, P) return Jacobian of dynamic function, it is\n passed into p_h.\n k (iteration number), starts at 0\n m: point where Jacobian is evaluated\n P: parameter for Jacobian, usually covariance matrix.\n \n p_f_R: function (k). Returns noise matrix of measurement equation \n on iteration k.\n k (iteration number). starts at 0\n \n p_f_iRsr: function (k). Returns the square root of the noise matrix of \n measurement equation on iteration k. \n k (iteration number). starts at 0\n \n measurement: (measurement_dim, time_series_no) matrix\n One measurement used on the current update step. For \n \"multiple time series mode\" it is matrix, second dimension of \n which correspond to different time series.\n \n calc_log_likelihood: boolean\n Whether to calculate marginal likelihood of the state-space model.\n \n calc_grad_log_likelihood: boolean\n Whether to calculate gradient of the marginal likelihood \n of the state-space model. If true then the next parameter must \n provide the extra parameters for gradient cal""culation.\n \n p_dm: 3D array (state_dim, time_series_no, parameters_no)\n Mean derivatives from the prediction step. For \"multiple time series mode\" \n it is 3D array, second dimension of which correspond to different\n time series.\n \n p_dP: array\n Covariance derivatives from the prediction step.\n \n grad_calc_params_2: List or None\n List with derivatives. The first component is 'f_dH' - function(k)\n which returns the derivative of H. The second element is 'f_dR'\n - function(k). Function which returns the derivative of R.\n \n Output:\n ----------------------------\n m_upd, P_upd, dm_upd, dP_upd: metrices, 3D objects\n Results of the prediction steps.\n \n log_likelihood_update: double or 1D array\n Update to the log_likelihood from this step \n \n d_log_likelihood_update: (grad_params_no, time_series_no) matrix\n Update to the gradient of log_likelihood, \"multiple time series mode\"\n adds extra columns to the gradient.\n \n "; +static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython = {"_kalman_update_step_SVD_Cython", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython}; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + long __pyx_v_k; + PyArrayObject *__pyx_v_p_m = 0; + PyObject *__pyx_v_p_P = 0; + struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables = 0; + PyArrayObject *__pyx_v_measurement = 0; + int __pyx_v_calc_log_likelihood; + int __pyx_v_calc_grad_log_likelihood; + PyArrayObject *__pyx_v_p_dm = 0; + PyArrayObject *__pyx_v_p_dP = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_kalman_update_step_SVD_Cython (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_k,&__pyx_n_s_p_m,&__pyx_n_s_p_P,&__pyx_n_s_p_measurement_callables,&__pyx_n_s_measurement,&__pyx_n_s_calc_log_likelihood,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_p_dm,&__pyx_n_s_p_dP,0}; + PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":654 + * bint calc_log_likelihood= False, + * bint calc_grad_log_likelihood=False, + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): + * """ + */ + values[7] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":655 + * bint calc_grad_log_likelihood=False, + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): # <<<<<<<<<<<<<< + * """ + * Input: + */ + values[8] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_k)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_m)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_P)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_measurement_callables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_measurement)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_calc_log_likelihood); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dm); + if (value) { values[7] = value; kw_args--; } + } + case 8: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dP); + if (value) { values[8] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_kalman_update_step_SVD_Cython") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_k = __Pyx_PyInt_As_long(values[0]); if (unlikely((__pyx_v_k == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_p_m = ((PyArrayObject *)values[1]); + __pyx_v_p_P = ((PyObject*)values[2]); + __pyx_v_p_measurement_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)values[3]); + __pyx_v_measurement = ((PyArrayObject *)values[4]); + if (values[5]) { + __pyx_v_calc_log_likelihood = __Pyx_PyObject_IsTrue(values[5]); if (unlikely((__pyx_v_calc_log_likelihood == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "GPy/models/state_space_cython.pyx":652 + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + * bint calc_log_likelihood= False, # <<<<<<<<<<<<<< + * bint calc_grad_log_likelihood=False, + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, + */ + __pyx_v_calc_log_likelihood = ((int)0); + } + if (values[6]) { + __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[6]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 653; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "GPy/models/state_space_cython.pyx":653 + * np.ndarray[DTYPE_t, ndim=2] measurement, + * bint calc_log_likelihood= False, + * bint calc_grad_log_likelihood=False, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] p_dm = None, + * np.ndarray[DTYPE_t, ndim=3] p_dP = None): + */ + __pyx_v_calc_grad_log_likelihood = ((int)0); + } + __pyx_v_p_dm = ((PyArrayObject *)values[7]); + __pyx_v_p_dP = ((PyArrayObject *)values[8]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_kalman_update_step_SVD_Cython", 0, 5, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_update_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_m), __pyx_ptype_5numpy_ndarray, 1, "p_m", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_P), (&PyTuple_Type), 1, "p_P", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_measurement_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, 1, "p_measurement_callables", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_measurement), __pyx_ptype_5numpy_ndarray, 1, "measurement", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dm), __pyx_ptype_5numpy_ndarray, 1, "p_dm", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dP), __pyx_ptype_5numpy_ndarray, 1, "p_dP", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(__pyx_self, __pyx_v_k, __pyx_v_p_m, __pyx_v_p_P, __pyx_v_p_measurement_callables, __pyx_v_measurement, __pyx_v_calc_log_likelihood, __pyx_v_calc_grad_log_likelihood, __pyx_v_p_dm, __pyx_v_p_dP); + + /* "GPy/models/state_space_cython.pyx":649 + * + * @cython.boundscheck(False) + * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_2_kalman_update_step_SVD_Cython(CYTHON_UNUSED PyObject *__pyx_self, long __pyx_v_k, PyArrayObject *__pyx_v_p_m, PyObject *__pyx_v_p_P, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, PyArrayObject *__pyx_v_measurement, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, PyArrayObject *__pyx_v_p_dm, PyArrayObject *__pyx_v_p_dP) { + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_P_pred = 0; + PyArrayObject *__pyx_v_S_pred = 0; + PyArrayObject *__pyx_v_V_pred = 0; + PyArrayObject *__pyx_v_H = 0; + PyArrayObject *__pyx_v_R = 0; + PyArrayObject *__pyx_v_R_isr = 0; + int __pyx_v_time_series_no; + PyArrayObject *__pyx_v_log_likelihood_update = 0; + PyArrayObject *__pyx_v_v = 0; + PyArrayObject *__pyx_v_svd_2_matr = 0; + PyObject *__pyx_v_res = NULL; + CYTHON_UNUSED PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S_svd = 0; + PyArrayObject *__pyx_v_Vh = 0; + PyArrayObject *__pyx_v_U_upd = 0; + PyArrayObject *__pyx_v_S_upd = 0; + PyArrayObject *__pyx_v_P_upd = 0; + PyArrayObject *__pyx_v_S = 0; + PyArrayObject *__pyx_v_K = 0; + CYTHON_UNUSED int __pyx_v_measurement_dim_gt_one; + PyArrayObject *__pyx_v_dm_upd = 0; + PyArrayObject *__pyx_v_dP_upd = 0; + PyArrayObject *__pyx_v_d_log_likelihood_update = 0; + PyArrayObject *__pyx_v_dm_pred_all_params = 0; + PyArrayObject *__pyx_v_dP_pred_all_params = 0; + int __pyx_v_param_number; + PyArrayObject *__pyx_v_dH_all_params = 0; + PyArrayObject *__pyx_v_dR_all_params = 0; + int __pyx_v_param; + PyArrayObject *__pyx_v_dH = 0; + PyArrayObject *__pyx_v_dR = 0; + PyArrayObject *__pyx_v_dm_pred = 0; + PyArrayObject *__pyx_v_dP_pred = 0; + PyArrayObject *__pyx_v_dv = 0; + PyArrayObject *__pyx_v_dS = 0; + PyArrayObject *__pyx_v_tmp1 = 0; + PyArrayObject *__pyx_v_tmp2 = 0; + PyArrayObject *__pyx_v_tmp3 = 0; + PyArrayObject *__pyx_v_dK = 0; + PyArrayObject *__pyx_v_tmp5 = 0; + PyObject *__pyx_v_ret = 0; + PyObject *__pyx_v_m_upd = NULL; + __Pyx_LocalBuf_ND __pyx_pybuffernd_H; + __Pyx_Buffer __pyx_pybuffer_H; + __Pyx_LocalBuf_ND __pyx_pybuffernd_K; + __Pyx_Buffer __pyx_pybuffer_K; + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_pred; + __Pyx_Buffer __pyx_pybuffer_P_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_upd; + __Pyx_Buffer __pyx_pybuffer_P_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_R; + __Pyx_Buffer __pyx_pybuffer_R; + __Pyx_LocalBuf_ND __pyx_pybuffernd_R_isr; + __Pyx_Buffer __pyx_pybuffer_R_isr; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S_pred; + __Pyx_Buffer __pyx_pybuffer_S_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S_svd; + __Pyx_Buffer __pyx_pybuffer_S_svd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S_upd; + __Pyx_Buffer __pyx_pybuffer_S_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U_upd; + __Pyx_Buffer __pyx_pybuffer_U_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_V_pred; + __Pyx_Buffer __pyx_pybuffer_V_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dH; + __Pyx_Buffer __pyx_pybuffer_dH; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dH_all_params; + __Pyx_Buffer __pyx_pybuffer_dH_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dK; + __Pyx_Buffer __pyx_pybuffer_dK; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred; + __Pyx_Buffer __pyx_pybuffer_dP_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred_all_params; + __Pyx_Buffer __pyx_pybuffer_dP_pred_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_upd; + __Pyx_Buffer __pyx_pybuffer_dP_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dR; + __Pyx_Buffer __pyx_pybuffer_dR; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dR_all_params; + __Pyx_Buffer __pyx_pybuffer_dR_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dS; + __Pyx_Buffer __pyx_pybuffer_dS; + __Pyx_LocalBuf_ND __pyx_pybuffernd_d_log_likelihood_update; + __Pyx_Buffer __pyx_pybuffer_d_log_likelihood_update; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred; + __Pyx_Buffer __pyx_pybuffer_dm_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred_all_params; + __Pyx_Buffer __pyx_pybuffer_dm_pred_all_params; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_upd; + __Pyx_Buffer __pyx_pybuffer_dm_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dv; + __Pyx_Buffer __pyx_pybuffer_dv; + __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood_update; + __Pyx_Buffer __pyx_pybuffer_log_likelihood_update; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_measurement; + __Pyx_Buffer __pyx_pybuffer_measurement; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dP; + __Pyx_Buffer __pyx_pybuffer_p_dP; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_dm; + __Pyx_Buffer __pyx_pybuffer_p_dm; + __Pyx_LocalBuf_ND __pyx_pybuffernd_p_m; + __Pyx_Buffer __pyx_pybuffer_p_m; + __Pyx_LocalBuf_ND __pyx_pybuffernd_svd_2_matr; + __Pyx_Buffer __pyx_pybuffer_svd_2_matr; + __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp1; + __Pyx_Buffer __pyx_pybuffer_tmp1; + __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp2; + __Pyx_Buffer __pyx_pybuffer_tmp2; + __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp3; + __Pyx_Buffer __pyx_pybuffer_tmp3; + __Pyx_LocalBuf_ND __pyx_pybuffernd_tmp5; + __Pyx_Buffer __pyx_pybuffer_tmp5; + __Pyx_LocalBuf_ND __pyx_pybuffernd_v; + __Pyx_Buffer __pyx_pybuffer_v; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyArrayObject *__pyx_t_2 = NULL; + PyArrayObject *__pyx_t_3 = NULL; + PyArrayObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyArrayObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + Py_ssize_t __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + PyArrayObject *__pyx_t_18 = NULL; + PyArrayObject *__pyx_t_19 = NULL; + PyArrayObject *__pyx_t_20 = NULL; + PyArrayObject *__pyx_t_21 = NULL; + PyArrayObject *__pyx_t_22 = NULL; + int __pyx_t_23; + PyArrayObject *__pyx_t_24 = NULL; + int __pyx_t_25; + PyObject *__pyx_t_26 = NULL; + PyObject *__pyx_t_27 = NULL; + PyObject *__pyx_t_28 = NULL; + PyArrayObject *__pyx_t_29 = NULL; + PyArrayObject *__pyx_t_30 = NULL; + PyArrayObject *__pyx_t_31 = NULL; + PyArrayObject *__pyx_t_32 = NULL; + PyArrayObject *__pyx_t_33 = NULL; + PyArrayObject *__pyx_t_34 = NULL; + int __pyx_t_35; + PyArrayObject *__pyx_t_36 = NULL; + int __pyx_t_37; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_kalman_update_step_SVD_Cython", 0); + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_P_pred.pybuffer.buf = NULL; + __pyx_pybuffer_P_pred.refcount = 0; + __pyx_pybuffernd_P_pred.data = NULL; + __pyx_pybuffernd_P_pred.rcbuffer = &__pyx_pybuffer_P_pred; + __pyx_pybuffer_S_pred.pybuffer.buf = NULL; + __pyx_pybuffer_S_pred.refcount = 0; + __pyx_pybuffernd_S_pred.data = NULL; + __pyx_pybuffernd_S_pred.rcbuffer = &__pyx_pybuffer_S_pred; + __pyx_pybuffer_V_pred.pybuffer.buf = NULL; + __pyx_pybuffer_V_pred.refcount = 0; + __pyx_pybuffernd_V_pred.data = NULL; + __pyx_pybuffernd_V_pred.rcbuffer = &__pyx_pybuffer_V_pred; + __pyx_pybuffer_H.pybuffer.buf = NULL; + __pyx_pybuffer_H.refcount = 0; + __pyx_pybuffernd_H.data = NULL; + __pyx_pybuffernd_H.rcbuffer = &__pyx_pybuffer_H; + __pyx_pybuffer_R.pybuffer.buf = NULL; + __pyx_pybuffer_R.refcount = 0; + __pyx_pybuffernd_R.data = NULL; + __pyx_pybuffernd_R.rcbuffer = &__pyx_pybuffer_R; + __pyx_pybuffer_R_isr.pybuffer.buf = NULL; + __pyx_pybuffer_R_isr.refcount = 0; + __pyx_pybuffernd_R_isr.data = NULL; + __pyx_pybuffernd_R_isr.rcbuffer = &__pyx_pybuffer_R_isr; + __pyx_pybuffer_log_likelihood_update.pybuffer.buf = NULL; + __pyx_pybuffer_log_likelihood_update.refcount = 0; + __pyx_pybuffernd_log_likelihood_update.data = NULL; + __pyx_pybuffernd_log_likelihood_update.rcbuffer = &__pyx_pybuffer_log_likelihood_update; + __pyx_pybuffer_v.pybuffer.buf = NULL; + __pyx_pybuffer_v.refcount = 0; + __pyx_pybuffernd_v.data = NULL; + __pyx_pybuffernd_v.rcbuffer = &__pyx_pybuffer_v; + __pyx_pybuffer_svd_2_matr.pybuffer.buf = NULL; + __pyx_pybuffer_svd_2_matr.refcount = 0; + __pyx_pybuffernd_svd_2_matr.data = NULL; + __pyx_pybuffernd_svd_2_matr.rcbuffer = &__pyx_pybuffer_svd_2_matr; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S_svd.pybuffer.buf = NULL; + __pyx_pybuffer_S_svd.refcount = 0; + __pyx_pybuffernd_S_svd.data = NULL; + __pyx_pybuffernd_S_svd.rcbuffer = &__pyx_pybuffer_S_svd; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + __pyx_pybuffer_U_upd.pybuffer.buf = NULL; + __pyx_pybuffer_U_upd.refcount = 0; + __pyx_pybuffernd_U_upd.data = NULL; + __pyx_pybuffernd_U_upd.rcbuffer = &__pyx_pybuffer_U_upd; + __pyx_pybuffer_S_upd.pybuffer.buf = NULL; + __pyx_pybuffer_S_upd.refcount = 0; + __pyx_pybuffernd_S_upd.data = NULL; + __pyx_pybuffernd_S_upd.rcbuffer = &__pyx_pybuffer_S_upd; + __pyx_pybuffer_P_upd.pybuffer.buf = NULL; + __pyx_pybuffer_P_upd.refcount = 0; + __pyx_pybuffernd_P_upd.data = NULL; + __pyx_pybuffernd_P_upd.rcbuffer = &__pyx_pybuffer_P_upd; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_K.pybuffer.buf = NULL; + __pyx_pybuffer_K.refcount = 0; + __pyx_pybuffernd_K.data = NULL; + __pyx_pybuffernd_K.rcbuffer = &__pyx_pybuffer_K; + __pyx_pybuffer_dm_upd.pybuffer.buf = NULL; + __pyx_pybuffer_dm_upd.refcount = 0; + __pyx_pybuffernd_dm_upd.data = NULL; + __pyx_pybuffernd_dm_upd.rcbuffer = &__pyx_pybuffer_dm_upd; + __pyx_pybuffer_dP_upd.pybuffer.buf = NULL; + __pyx_pybuffer_dP_upd.refcount = 0; + __pyx_pybuffernd_dP_upd.data = NULL; + __pyx_pybuffernd_dP_upd.rcbuffer = &__pyx_pybuffer_dP_upd; + __pyx_pybuffer_d_log_likelihood_update.pybuffer.buf = NULL; + __pyx_pybuffer_d_log_likelihood_update.refcount = 0; + __pyx_pybuffernd_d_log_likelihood_update.data = NULL; + __pyx_pybuffernd_d_log_likelihood_update.rcbuffer = &__pyx_pybuffer_d_log_likelihood_update; + __pyx_pybuffer_dm_pred_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dm_pred_all_params.refcount = 0; + __pyx_pybuffernd_dm_pred_all_params.data = NULL; + __pyx_pybuffernd_dm_pred_all_params.rcbuffer = &__pyx_pybuffer_dm_pred_all_params; + __pyx_pybuffer_dP_pred_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dP_pred_all_params.refcount = 0; + __pyx_pybuffernd_dP_pred_all_params.data = NULL; + __pyx_pybuffernd_dP_pred_all_params.rcbuffer = &__pyx_pybuffer_dP_pred_all_params; + __pyx_pybuffer_dH_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dH_all_params.refcount = 0; + __pyx_pybuffernd_dH_all_params.data = NULL; + __pyx_pybuffernd_dH_all_params.rcbuffer = &__pyx_pybuffer_dH_all_params; + __pyx_pybuffer_dR_all_params.pybuffer.buf = NULL; + __pyx_pybuffer_dR_all_params.refcount = 0; + __pyx_pybuffernd_dR_all_params.data = NULL; + __pyx_pybuffernd_dR_all_params.rcbuffer = &__pyx_pybuffer_dR_all_params; + __pyx_pybuffer_dH.pybuffer.buf = NULL; + __pyx_pybuffer_dH.refcount = 0; + __pyx_pybuffernd_dH.data = NULL; + __pyx_pybuffernd_dH.rcbuffer = &__pyx_pybuffer_dH; + __pyx_pybuffer_dR.pybuffer.buf = NULL; + __pyx_pybuffer_dR.refcount = 0; + __pyx_pybuffernd_dR.data = NULL; + __pyx_pybuffernd_dR.rcbuffer = &__pyx_pybuffer_dR; + __pyx_pybuffer_dm_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dm_pred.refcount = 0; + __pyx_pybuffernd_dm_pred.data = NULL; + __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred; + __pyx_pybuffer_dP_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dP_pred.refcount = 0; + __pyx_pybuffernd_dP_pred.data = NULL; + __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred; + __pyx_pybuffer_dv.pybuffer.buf = NULL; + __pyx_pybuffer_dv.refcount = 0; + __pyx_pybuffernd_dv.data = NULL; + __pyx_pybuffernd_dv.rcbuffer = &__pyx_pybuffer_dv; + __pyx_pybuffer_dS.pybuffer.buf = NULL; + __pyx_pybuffer_dS.refcount = 0; + __pyx_pybuffernd_dS.data = NULL; + __pyx_pybuffernd_dS.rcbuffer = &__pyx_pybuffer_dS; + __pyx_pybuffer_tmp1.pybuffer.buf = NULL; + __pyx_pybuffer_tmp1.refcount = 0; + __pyx_pybuffernd_tmp1.data = NULL; + __pyx_pybuffernd_tmp1.rcbuffer = &__pyx_pybuffer_tmp1; + __pyx_pybuffer_tmp2.pybuffer.buf = NULL; + __pyx_pybuffer_tmp2.refcount = 0; + __pyx_pybuffernd_tmp2.data = NULL; + __pyx_pybuffernd_tmp2.rcbuffer = &__pyx_pybuffer_tmp2; + __pyx_pybuffer_tmp3.pybuffer.buf = NULL; + __pyx_pybuffer_tmp3.refcount = 0; + __pyx_pybuffernd_tmp3.data = NULL; + __pyx_pybuffernd_tmp3.rcbuffer = &__pyx_pybuffer_tmp3; + __pyx_pybuffer_dK.pybuffer.buf = NULL; + __pyx_pybuffer_dK.refcount = 0; + __pyx_pybuffernd_dK.data = NULL; + __pyx_pybuffernd_dK.rcbuffer = &__pyx_pybuffer_dK; + __pyx_pybuffer_tmp5.pybuffer.buf = NULL; + __pyx_pybuffer_tmp5.refcount = 0; + __pyx_pybuffernd_tmp5.data = NULL; + __pyx_pybuffernd_tmp5.rcbuffer = &__pyx_pybuffer_tmp5; + __pyx_pybuffer_p_m.pybuffer.buf = NULL; + __pyx_pybuffer_p_m.refcount = 0; + __pyx_pybuffernd_p_m.data = NULL; + __pyx_pybuffernd_p_m.rcbuffer = &__pyx_pybuffer_p_m; + __pyx_pybuffer_measurement.pybuffer.buf = NULL; + __pyx_pybuffer_measurement.refcount = 0; + __pyx_pybuffernd_measurement.data = NULL; + __pyx_pybuffernd_measurement.rcbuffer = &__pyx_pybuffer_measurement; + __pyx_pybuffer_p_dm.pybuffer.buf = NULL; + __pyx_pybuffer_p_dm.refcount = 0; + __pyx_pybuffernd_p_dm.data = NULL; + __pyx_pybuffernd_p_dm.rcbuffer = &__pyx_pybuffer_p_dm; + __pyx_pybuffer_p_dP.pybuffer.buf = NULL; + __pyx_pybuffer_p_dP.refcount = 0; + __pyx_pybuffernd_p_dP.data = NULL; + __pyx_pybuffernd_p_dP.rcbuffer = &__pyx_pybuffer_p_dP; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_m, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_m.diminfo[0].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_m.diminfo[0].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_m.diminfo[1].strides = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_m.diminfo[1].shape = __pyx_pybuffernd_p_m.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer, (PyObject*)__pyx_v_measurement, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_measurement.diminfo[0].strides = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_measurement.diminfo[0].shape = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_measurement.diminfo[1].strides = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_measurement.diminfo[1].shape = __pyx_pybuffernd_measurement.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dm, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_dm.diminfo[0].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dm.diminfo[0].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dm.diminfo[1].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dm.diminfo[1].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dm.diminfo[2].strides = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dm.diminfo[2].shape = __pyx_pybuffernd_p_dm.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer, (PyObject*)__pyx_v_p_dP, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_p_dP.diminfo[0].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_p_dP.diminfo[0].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_p_dP.diminfo[1].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_p_dP.diminfo[1].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_p_dP.diminfo[2].strides = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_p_dP.diminfo[2].shape = __pyx_pybuffernd_p_dP.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":731 + * """ + * + * cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_m # from prediction step # <<<<<<<<<<<<<< + * #P_pred,S_pred,V_pred = p_P # from prediction step + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0] + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_m), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_m_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + } + } + __Pyx_INCREF(((PyObject *)__pyx_v_p_m)); + __pyx_v_m_pred = ((PyArrayObject *)__pyx_v_p_m); + + /* "GPy/models/state_space_cython.pyx":733 + * cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_m # from prediction step + * #P_pred,S_pred,V_pred = p_P # from prediction step + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1] + * cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2] + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 0)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 0), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 0); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_P_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_P_pred.diminfo[0].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_pred.diminfo[0].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_pred.diminfo[1].strides = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_pred.diminfo[1].shape = __pyx_pybuffernd_P_pred.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_v_P_pred = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":734 + * #P_pred,S_pred,V_pred = p_P # from prediction step + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2] + * + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 1)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 1), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 1); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S_pred.diminfo[0].strides = __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_pred.diminfo[0].shape = __pyx_pybuffernd_S_pred.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_v_S_pred = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":735 + * cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1] + * cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2] # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred) + */ + if (unlikely(__pyx_v_p_P == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((PyTuple_GET_ITEM(__pyx_v_p_P, 2)) == Py_None) || likely(__Pyx_TypeTest(PyTuple_GET_ITEM(__pyx_v_p_P, 2), __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_v_p_P, 2); + __Pyx_INCREF(__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_t_1), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_V_pred = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_V_pred.diminfo[0].strides = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_V_pred.diminfo[0].shape = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_V_pred.diminfo[1].strides = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_V_pred.diminfo[1].shape = __pyx_pybuffernd_V_pred.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_v_V_pred = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":737 + * cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2] + * + * cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k) + * cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->Hk(__pyx_v_p_measurement_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_P_pred), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_H.rcbuffer->pybuffer, (PyObject*)__pyx_t_2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_H = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_H.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_H.diminfo[0].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_H.diminfo[0].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_H.diminfo[1].strides = __pyx_pybuffernd_H.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_H.diminfo[1].shape = __pyx_pybuffernd_H.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_2 = 0; + __pyx_v_H = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":738 + * + * cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred) + * cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix + * + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->Rk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R.rcbuffer->pybuffer, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_R = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_R.diminfo[0].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R.diminfo[0].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R.diminfo[1].strides = __pyx_pybuffernd_R.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R.diminfo[1].shape = __pyx_pybuffernd_R.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_3 = 0; + __pyx_v_R = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":739 + * cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred) + * cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k) + * cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix # <<<<<<<<<<<<<< + * + * cdef int time_series_no = p_m.shape[1] # number of time serieses + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->R_isrk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((PyArrayObject *)__pyx_t_1); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer, (PyObject*)__pyx_t_4, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_R_isr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_R_isr.diminfo[0].strides = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_R_isr.diminfo[0].shape = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_R_isr.diminfo[1].strides = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_R_isr.diminfo[1].shape = __pyx_pybuffernd_R_isr.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_4 = 0; + __pyx_v_R_isr = ((PyArrayObject *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":741 + * cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix + * + * cdef int time_series_no = p_m.shape[1] # number of time serieses # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood_update # log_likelihood_update=None; + */ + __pyx_v_time_series_no = (__pyx_v_p_m->dimensions[1]); + + /* "GPy/models/state_space_cython.pyx":746 + * # Update step (only if there is data) + * #if not np.any(np.isnan(measurement)): # TODO: if some dimensions are missing, do properly computations for other. + * cdef np.ndarray[DTYPE_t, ndim=2] v = measurement-p_measurement_callables.f_h(k, m_pred, H) # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->f_h(__pyx_v_p_measurement_callables, __pyx_v_k, ((PyArrayObject *)__pyx_v_m_pred), ((PyArrayObject *)__pyx_v_H), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_measurement), __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_v.rcbuffer->pybuffer, (PyObject*)__pyx_t_6, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_v = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_v.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_v.diminfo[0].strides = __pyx_pybuffernd_v.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_v.diminfo[0].shape = __pyx_pybuffernd_v.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_v.diminfo[1].strides = __pyx_pybuffernd_v.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_v.diminfo[1].shape = __pyx_pybuffernd_v.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_6 = 0; + __pyx_v_v = ((PyArrayObject *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":748 + * cdef np.ndarray[DTYPE_t, ndim=2] v = measurement-p_measurement_callables.f_h(k, m_pred, H) + * + * cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) # <<<<<<<<<<<<<< + * + * res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_vstack); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_R_isr), __pyx_n_s_T); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + __pyx_t_13 = 1; + } + } + __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + if (__pyx_t_11) { + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, ((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + __Pyx_INCREF(((PyObject *)__pyx_v_V_pred)); + PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, ((PyObject *)__pyx_v_V_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_V_pred)); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_14, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_12)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_12); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_13 = 1; + } + } + __pyx_t_14 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + if (__pyx_t_12) { + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12); __Pyx_GIVEREF(__pyx_t_12); __pyx_t_12 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_14, 0+__pyx_t_13, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_14, 1+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_8 = 0; + __pyx_t_10 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_14, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_14 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_n_s_diag); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sqrt); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + } + } + if (!__pyx_t_8) { + __pyx_t_14 = __Pyx_PyObject_CallOneArg(__pyx_t_12, ((PyObject *)__pyx_v_S_pred)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + } else { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S_pred)); + PyTuple_SET_ITEM(__pyx_t_11, 0+1, ((PyObject *)__pyx_v_S_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S_pred)); + __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_11, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyNumber_Divide(__pyx_float_1_0, __pyx_t_14); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_14)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (!__pyx_t_14) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_12); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_GOTREF(__pyx_t_9); + } else { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = NULL; + PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_11, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_1 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_9) { + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_5); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_svd_2_matr = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_svd_2_matr.diminfo[0].strides = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_svd_2_matr.diminfo[0].shape = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_svd_2_matr.diminfo[1].strides = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_svd_2_matr.diminfo[1].shape = __pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_15 = 0; + __pyx_v_svd_2_matr = ((PyArrayObject *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":750 + * cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) + * + * res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_linalg); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_svd); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(((PyObject *)__pyx_v_svd_2_matr)); + PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_svd_2_matr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_svd_2_matr)); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":751 + * + * res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * + * #(U,S,Vh) + */ + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":750 + * cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) + * + * res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * + */ + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 750; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_res = __pyx_t_10; + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":754 + * + * #(U,S,Vh) + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1] + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + */ + __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_16 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_U = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_16 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":755 + * #(U,S,Vh) + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1] # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + * + */ + __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S_svd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S_svd.diminfo[0].strides = __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_svd.diminfo[0].shape = __pyx_pybuffernd_S_svd.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_17 = 0; + __pyx_v_S_svd = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":756 + * cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + * cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1] + * cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] # <<<<<<<<<<<<<< + * + * # P_upd = U_upd S_upd**2 U_upd.T + */ + __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_res, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_18 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_Vh = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_Vh.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_18 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":759 + * + * # P_upd = U_upd S_upd**2 U_upd.T + * cdef np.ndarray[DTYPE_t, ndim=2] U_upd = np.dot(V_pred, Vh.T) # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2 + * + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_Vh), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_13 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_V_pred)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, ((PyObject *)__pyx_v_V_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_V_pred)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_U_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_U_upd.diminfo[0].strides = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U_upd.diminfo[0].shape = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U_upd.diminfo[1].strides = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U_upd.diminfo[1].shape = __pyx_pybuffernd_U_upd.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_19 = 0; + __pyx_v_U_upd = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":760 + * # P_upd = U_upd S_upd**2 U_upd.T + * cdef np.ndarray[DTYPE_t, ndim=2] U_upd = np.dot(V_pred, Vh.T) + * cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2 # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance + */ + __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_float_1_0, ((PyObject *)__pyx_v_S_svd)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = PyNumber_Power(__pyx_t_10, __pyx_int_2, Py_None); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_20 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_20, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + __pyx_v_S_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S_upd.diminfo[0].strides = __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S_upd.diminfo[0].shape = __pyx_pybuffernd_S_upd.rcbuffer->pybuffer.shape[0]; + } + } + __pyx_t_20 = 0; + __pyx_v_S_upd = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":762 + * cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2 + * + * cdef np.ndarray[DTYPE_t, ndim=2] P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance # <<<<<<<<<<<<<< + * #P_upd = (P_upd,S_upd,U_upd) # tuple to pass to the next step + * + */ + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyNumber_Multiply(((PyObject *)__pyx_v_U_upd), ((PyObject *)__pyx_v_S_upd)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_U_upd), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_13 = 1; + } + } + __pyx_t_11 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_13, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_10 = 0; + __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_P_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 762; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_P_upd.diminfo[0].strides = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_upd.diminfo[0].shape = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_upd.diminfo[1].strides = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_upd.diminfo[1].shape = __pyx_pybuffernd_P_upd.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_21 = 0; + __pyx_v_P_upd = ((PyArrayObject *)__pyx_t_7); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":766 + * + * # stil need to compute S and K for derivative computation + * cdef np.ndarray[DTYPE_t, ndim=2] S = H.dot(P_pred).dot(H.T) + R # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] K + * cdef bint measurement_dim_gt_one = False + */ + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + } + } + if (!__pyx_t_1) { + __pyx_t_9 = __Pyx_PyObject_CallOneArg(__pyx_t_11, ((PyObject *)__pyx_v_P_pred)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + } else { + __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_10, 0+1, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + } + } + if (!__pyx_t_10) { + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_t_7); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = NULL; + PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_v_R)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_22 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_22, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_S = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_S.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_S.diminfo[1].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_S.diminfo[1].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_22 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_11); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":768 + * cdef np.ndarray[DTYPE_t, ndim=2] S = H.dot(P_pred).dot(H.T) + R + * cdef np.ndarray[DTYPE_t, ndim=2] K + * cdef bint measurement_dim_gt_one = False # <<<<<<<<<<<<<< + * if measurement.shape[0]==1: # measurements are one dimensional + * if (S < 0): + */ + __pyx_v_measurement_dim_gt_one = 0; + + /* "GPy/models/state_space_cython.pyx":769 + * cdef np.ndarray[DTYPE_t, ndim=2] K + * cdef bint measurement_dim_gt_one = False + * if measurement.shape[0]==1: # measurements are one dimensional # <<<<<<<<<<<<<< + * if (S < 0): + * raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k ) + */ + __pyx_t_23 = (((__pyx_v_measurement->dimensions[0]) == 1) != 0); + if (__pyx_t_23) { + + /* "GPy/models/state_space_cython.pyx":770 + * cdef bint measurement_dim_gt_one = False + * if measurement.shape[0]==1: # measurements are one dimensional + * if (S < 0): # <<<<<<<<<<<<<< + * raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k ) + * #import pdb; pdb.set_trace() + */ + __pyx_t_11 = PyObject_RichCompare(((PyObject *)__pyx_v_S), __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_23 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (__pyx_t_23) { + + /* "GPy/models/state_space_cython.pyx":771 + * if measurement.shape[0]==1: # measurements are one dimensional + * if (S < 0): + * raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k ) # <<<<<<<<<<<<<< + * #import pdb; pdb.set_trace() + * + */ + __pyx_t_11 = __Pyx_PyInt_From_long(__pyx_v_k); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne, __pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_Raise(__pyx_t_7, 0, 0, 0); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "GPy/models/state_space_cython.pyx":774 + * #import pdb; pdb.set_trace() + * + * K = P_pred.dot(H.T) / S # <<<<<<<<<<<<<< + * if calc_log_likelihood: + * log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + */ + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_P_pred), __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + } + } + if (!__pyx_t_9) { + __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_11, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_7); + } else { + __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_7, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_K.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_K.rcbuffer->pybuffer, (PyObject*)__pyx_v_K, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_K.diminfo[0].strides = __pyx_pybuffernd_K.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_K.diminfo[0].shape = __pyx_pybuffernd_K.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_K.diminfo[1].strides = __pyx_pybuffernd_K.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_K.diminfo[1].shape = __pyx_pybuffernd_K.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_24 = 0; + __pyx_v_K = ((PyArrayObject *)__pyx_t_11); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":775 + * + * K = P_pred.dot(H.T) / S + * if calc_log_likelihood: # <<<<<<<<<<<<<< + * log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + * v*v / S) + */ + __pyx_t_23 = (__pyx_v_calc_log_likelihood != 0); + if (__pyx_t_23) { + + /* "GPy/models/state_space_cython.pyx":776 + * K = P_pred.dot(H.T) / S + * if calc_log_likelihood: + * log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + # <<<<<<<<<<<<<< + * v*v / S) + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_log); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_pi); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Multiply(__pyx_int_2, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + } + } + if (!__pyx_t_1) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_GOTREF(__pyx_t_11); + } else { + __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_9, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_log); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_9) { + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_7, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_1, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(__pyx_t_11, __pyx_t_10); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":777 + * if calc_log_likelihood: + * log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + * v*v / S) # <<<<<<<<<<<<<< + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + * if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + */ + __pyx_t_10 = PyNumber_Multiply(((PyObject *)__pyx_v_v), ((PyObject *)__pyx_v_v)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyNumber_Divide(__pyx_t_10, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":776 + * K = P_pred.dot(H.T) / S + * if calc_log_likelihood: + * log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + # <<<<<<<<<<<<<< + * v*v / S) + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + */ + __pyx_t_10 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Multiply(__pyx_float_neg_0_5, __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __pyx_v_log_likelihood_update = ((PyArrayObject *)__pyx_t_11); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":779 + * v*v / S) + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + * if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. # <<<<<<<<<<<<<< + * raise ValueError("Nan values in likelihood update!") + * else: + */ + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_any); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_isnan); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + } + } + if (!__pyx_t_1) { + __pyx_t_10 = __Pyx_PyObject_CallOneArg(__pyx_t_9, ((PyObject *)__pyx_v_log_likelihood_update)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + } else { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_log_likelihood_update)); + PyTuple_SET_ITEM(__pyx_t_5, 0+1, ((PyObject *)__pyx_v_log_likelihood_update)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_log_likelihood_update)); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_9) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_t_11); + } else { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely(__pyx_t_23 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (__pyx_t_23) { + + /* "GPy/models/state_space_cython.pyx":780 + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + * if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + * raise ValueError("Nan values in likelihood update!") # <<<<<<<<<<<<<< + * else: + * log_likelihood_update = None + */ + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__67, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_Raise(__pyx_t_11, 0, 0, 0); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + goto __pyx_L5; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":782 + * raise ValueError("Nan values in likelihood update!") + * else: + * log_likelihood_update = None # <<<<<<<<<<<<<< + * #LL = None; islower = None + * else: + */ + __pyx_t_29 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_log_likelihood_update = ((PyArrayObject *)Py_None); + } + __pyx_L5:; + goto __pyx_L3; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":785 + * #LL = None; islower = None + * else: + * measurement_dim_gt_one = True # <<<<<<<<<<<<<< + * raise ValueError("""Measurement dimension larger then 1 is currently not supported""") + * + */ + __pyx_v_measurement_dim_gt_one = 1; + + /* "GPy/models/state_space_cython.pyx":786 + * else: + * measurement_dim_gt_one = True + * raise ValueError("""Measurement dimension larger then 1 is currently not supported""") # <<<<<<<<<<<<<< + * + * # Old method of computing updated covariance (for testing) -> + */ + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_Raise(__pyx_t_11, 0, 0, 0); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L3:; + + /* "GPy/models/state_space_cython.pyx":809 + * cdef tuple ret + * + * if calc_grad_log_likelihood: # <<<<<<<<<<<<<< + * dm_pred_all_params = p_dm # derivativas of the prediction phase + * dP_pred_all_params = p_dP + */ + __pyx_t_23 = (__pyx_v_calc_grad_log_likelihood != 0); + if (__pyx_t_23) { + + /* "GPy/models/state_space_cython.pyx":810 + * + * if calc_grad_log_likelihood: + * dm_pred_all_params = p_dm # derivativas of the prediction phase # <<<<<<<<<<<<<< + * dP_pred_all_params = p_dP + * + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_dm), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dm_pred_all_params.diminfo[0].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred_all_params.diminfo[0].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred_all_params.diminfo[1].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred_all_params.diminfo[1].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred_all_params.diminfo[2].strides = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred_all_params.diminfo[2].shape = __pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(((PyObject *)__pyx_v_p_dm)); + __pyx_v_dm_pred_all_params = ((PyArrayObject *)__pyx_v_p_dm); + + /* "GPy/models/state_space_cython.pyx":811 + * if calc_grad_log_likelihood: + * dm_pred_all_params = p_dm # derivativas of the prediction phase + * dP_pred_all_params = p_dP # <<<<<<<<<<<<<< + * + * param_number = p_dP.shape[2] + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_p_dP), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dP_pred_all_params.diminfo[0].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred_all_params.diminfo[0].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred_all_params.diminfo[1].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred_all_params.diminfo[1].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred_all_params.diminfo[2].strides = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred_all_params.diminfo[2].shape = __pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(((PyObject *)__pyx_v_p_dP)); + __pyx_v_dP_pred_all_params = ((PyArrayObject *)__pyx_v_p_dP); + + /* "GPy/models/state_space_cython.pyx":813 + * dP_pred_all_params = p_dP + * + * param_number = p_dP.shape[2] # <<<<<<<<<<<<<< + * + * dH_all_params = p_measurement_callables.dHk(k) + */ + __pyx_v_param_number = (__pyx_v_p_dP->dimensions[2]); + + /* "GPy/models/state_space_cython.pyx":815 + * param_number = p_dP.shape[2] + * + * dH_all_params = p_measurement_callables.dHk(k) # <<<<<<<<<<<<<< + * dR_all_params = p_measurement_callables.dRk(k) + * + */ + __pyx_t_11 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->dHk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_30 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dH_all_params.diminfo[0].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH_all_params.diminfo[0].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH_all_params.diminfo[1].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH_all_params.diminfo[1].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dH_all_params.diminfo[2].strides = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dH_all_params.diminfo[2].shape = __pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 815; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_30 = 0; + __pyx_v_dH_all_params = ((PyArrayObject *)__pyx_t_11); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":816 + * + * dH_all_params = p_measurement_callables.dHk(k) + * dR_all_params = p_measurement_callables.dRk(k) # <<<<<<<<<<<<<< + * + * dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE) + */ + __pyx_t_11 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)__pyx_v_p_measurement_callables->__pyx_vtab)->dRk(__pyx_v_p_measurement_callables, __pyx_v_k, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_31 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR_all_params, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dR_all_params.diminfo[0].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR_all_params.diminfo[0].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR_all_params.diminfo[1].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR_all_params.diminfo[1].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dR_all_params.diminfo[2].strides = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dR_all_params.diminfo[2].shape = __pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_31 = 0; + __pyx_v_dR_all_params = ((PyArrayObject *)__pyx_t_11); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":818 + * dR_all_params = p_measurement_callables.dRk(k) + * + * dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE) # <<<<<<<<<<<<<< + * dP_upd = np.empty((dP_pred_all_params.shape[0], dP_pred_all_params.shape[1], dP_pred_all_params.shape[2]), dtype = DTYPE) + * + */ + __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_empty); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[0])); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_5 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[1])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dm_pred_all_params->dimensions[2])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_11 = 0; + __pyx_t_5 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_10, __pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_32 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_32 = 0; + __pyx_v_dm_upd = ((PyArrayObject *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":819 + * + * dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE) + * dP_upd = np.empty((dP_pred_all_params.shape[0], dP_pred_all_params.shape[1], dP_pred_all_params.shape[2]), dtype = DTYPE) # <<<<<<<<<<<<<< + * + * # firts dimension parameter_no, second - time series number + */ + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_empty); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[0])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_10 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[1])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = __Pyx_PyInt_From_Py_intptr_t((__pyx_v_dP_pred_all_params->dimensions[2])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = PyTuple_New(3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_5 = 0; + __pyx_t_10 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_dtype, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_33 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_33, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_33 = 0; + __pyx_v_dP_upd = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":822 + * + * # firts dimension parameter_no, second - time series number + * d_log_likelihood_update = np.empty((param_number,time_series_no), dtype = DTYPE) # <<<<<<<<<<<<<< + * for param in range(param_number): + * + */ + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_empty); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param_number); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_10 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (PyDict_SetItem(__pyx_t_9, __pyx_n_s_dtype, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_34 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_34, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_34 = 0; + __pyx_v_d_log_likelihood_update = ((PyArrayObject *)__pyx_t_10); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":823 + * # firts dimension parameter_no, second - time series number + * d_log_likelihood_update = np.empty((param_number,time_series_no), dtype = DTYPE) + * for param in range(param_number): # <<<<<<<<<<<<<< + * + * dH = dH_all_params[:,:,param] + */ + __pyx_t_25 = __pyx_v_param_number; + for (__pyx_t_35 = 0; __pyx_t_35 < __pyx_t_25; __pyx_t_35+=1) { + __pyx_v_param = __pyx_t_35; + + /* "GPy/models/state_space_cython.pyx":825 + * for param in range(param_number): + * + * dH = dH_all_params[:,:,param] # <<<<<<<<<<<<<< + * dR = dR_all_params[:,:,param] + * + */ + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__69); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__69); + __Pyx_GIVEREF(__pyx_slice__69); + __Pyx_INCREF(__pyx_slice__70); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__70); + __Pyx_GIVEREF(__pyx_slice__70); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_dH_all_params), __pyx_t_9); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dH.rcbuffer->pybuffer, (PyObject*)__pyx_v_dH, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dH.diminfo[0].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dH.diminfo[0].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dH.diminfo[1].strides = __pyx_pybuffernd_dH.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dH.diminfo[1].shape = __pyx_pybuffernd_dH.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dH, ((PyArrayObject *)__pyx_t_10)); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":826 + * + * dH = dH_all_params[:,:,param] + * dR = dR_all_params[:,:,param] # <<<<<<<<<<<<<< + * + * dm_pred = dm_pred_all_params[:,:,param] + */ + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__71); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__71); + __Pyx_GIVEREF(__pyx_slice__71); + __Pyx_INCREF(__pyx_slice__72); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__72); + __Pyx_GIVEREF(__pyx_slice__72); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_dR_all_params), __pyx_t_9); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dR.rcbuffer->pybuffer, (PyObject*)__pyx_v_dR, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dR.diminfo[0].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dR.diminfo[0].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dR.diminfo[1].strides = __pyx_pybuffernd_dR.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dR.diminfo[1].shape = __pyx_pybuffernd_dR.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dR, ((PyArrayObject *)__pyx_t_10)); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":828 + * dR = dR_all_params[:,:,param] + * + * dm_pred = dm_pred_all_params[:,:,param] # <<<<<<<<<<<<<< + * dP_pred = dP_pred_all_params[:,:,param] + * + */ + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__73); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__73); + __Pyx_GIVEREF(__pyx_slice__73); + __Pyx_INCREF(__pyx_slice__74); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__74); + __Pyx_GIVEREF(__pyx_slice__74); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_dm_pred_all_params), __pyx_t_9); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dm_pred, ((PyArrayObject *)__pyx_t_10)); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":829 + * + * dm_pred = dm_pred_all_params[:,:,param] + * dP_pred = dP_pred_all_params[:,:,param] # <<<<<<<<<<<<<< + * + * # Terms in the likelihood derivatives + */ + __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__75); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__75); + __Pyx_GIVEREF(__pyx_slice__75); + __Pyx_INCREF(__pyx_slice__76); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__76); + __Pyx_GIVEREF(__pyx_slice__76); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_GetItem(((PyObject *)__pyx_v_dP_pred_all_params), __pyx_t_9); if (unlikely(__pyx_t_10 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_10); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dP_pred, ((PyArrayObject *)__pyx_t_10)); + __pyx_t_10 = 0; + + /* "GPy/models/state_space_cython.pyx":832 + * + * # Terms in the likelihood derivatives + * dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) # <<<<<<<<<<<<<< + * dS = np.dot(dH, np.dot( P_pred, H.T)) + * dS += dS.T + */ + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_13 = 1; + } + } + __pyx_t_11 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_9) { + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dH)); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_13, ((PyObject *)__pyx_v_dH)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dH)); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_13, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Negative(__pyx_t_10); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_9); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_9, function); + __pyx_t_13 = 1; + } + } + __pyx_t_5 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_11) { + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_13, ((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred)); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_13, ((PyObject *)__pyx_v_dm_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_pred)); + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_5, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Subtract(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_9); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dv.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dv.rcbuffer->pybuffer, (PyObject*)__pyx_v_dv, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dv.diminfo[0].strides = __pyx_pybuffernd_dv.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dv.diminfo[0].shape = __pyx_pybuffernd_dv.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dv.diminfo[1].strides = __pyx_pybuffernd_dv.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dv.diminfo[1].shape = __pyx_pybuffernd_dv.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dv, ((PyArrayObject *)__pyx_t_9)); + __pyx_t_9 = 0; + + /* "GPy/models/state_space_cython.pyx":833 + * # Terms in the likelihood derivatives + * dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) + * dS = np.dot(dH, np.dot( P_pred, H.T)) # <<<<<<<<<<<<<< + * dS += dS.T + * dS += np.dot(H, np.dot( dP_pred, H.T)) + dR + */ + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_13 = 1; + } + } + __pyx_t_12 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_1) { + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_12, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_13 = 1; + } + } + __pyx_t_12 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_11) { + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dH)); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, ((PyObject *)__pyx_v_dH)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dH)); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_12, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_9) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_9, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_9); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_9)); + __pyx_t_9 = 0; + + /* "GPy/models/state_space_cython.pyx":834 + * dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) + * dS = np.dot(dH, np.dot( P_pred, H.T)) + * dS += dS.T # <<<<<<<<<<<<<< + * dS += np.dot(H, np.dot( dP_pred, H.T)) + dR + * + */ + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dS), __pyx_n_s_T); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_dS), __pyx_t_9); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_7)); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":835 + * dS = np.dot(dH, np.dot( P_pred, H.T)) + * dS += dS.T + * dS += np.dot(H, np.dot( dP_pred, H.T)) + dR # <<<<<<<<<<<<<< + * + * # TODO: maybe symmetrize dS + */ + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_10 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_5 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_13 = 1; + } + } + __pyx_t_1 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred)); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_13, ((PyObject *)__pyx_v_dP_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred)); + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_13, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_12))) { + __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12); + if (likely(__pyx_t_11)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_12); + __Pyx_INCREF(__pyx_t_11); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_12, function); + __pyx_t_13 = 1; + } + } + __pyx_t_1 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__pyx_t_11) { + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); __Pyx_GIVEREF(__pyx_t_11); __pyx_t_11 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_1, 0+__pyx_t_13, ((PyObject *)__pyx_v_H)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_H)); + PyTuple_SET_ITEM(__pyx_t_1, 1+__pyx_t_13, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_v_dR)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_dS), __pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dS.rcbuffer->pybuffer, (PyObject*)__pyx_v_dS, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dS.diminfo[0].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dS.diminfo[0].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dS.diminfo[1].strides = __pyx_pybuffernd_dS.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dS.diminfo[1].shape = __pyx_pybuffernd_dS.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_DECREF_SET(__pyx_v_dS, ((PyArrayObject *)__pyx_t_7)); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":839 + * # TODO: maybe symmetrize dS + * + * tmp1 = H.T / S # <<<<<<<<<<<<<< + * tmp2 = dH.T / S + * tmp3 = dS.T / S + */ + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_H), __pyx_n_s_T); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_12 = __Pyx_PyNumber_Divide(__pyx_t_7, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_12); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp1, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_tmp1.diminfo[0].strides = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp1.diminfo[0].shape = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp1.diminfo[1].strides = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp1.diminfo[1].shape = __pyx_pybuffernd_tmp1.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_tmp1, ((PyArrayObject *)__pyx_t_12)); + __pyx_t_12 = 0; + + /* "GPy/models/state_space_cython.pyx":840 + * + * tmp1 = H.T / S + * tmp2 = dH.T / S # <<<<<<<<<<<<<< + * tmp3 = dS.T / S + * + */ + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dH), __pyx_n_s_T); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_7 = __Pyx_PyNumber_Divide(__pyx_t_12, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + if (!(likely(((__pyx_t_7) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_7, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_7); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp2, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_tmp2.diminfo[0].strides = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp2.diminfo[0].shape = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp2.diminfo[1].strides = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp2.diminfo[1].shape = __pyx_pybuffernd_tmp2.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_tmp2, ((PyArrayObject *)__pyx_t_7)); + __pyx_t_7 = 0; + + /* "GPy/models/state_space_cython.pyx":841 + * tmp1 = H.T / S + * tmp2 = dH.T / S + * tmp3 = dS.T / S # <<<<<<<<<<<<<< + * + * dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ + */ + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dS), __pyx_n_s_T); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_12 = __Pyx_PyNumber_Divide(__pyx_t_7, ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (!(likely(((__pyx_t_12) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_12, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_12); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp3, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_tmp3.diminfo[0].strides = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp3.diminfo[0].shape = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp3.diminfo[1].strides = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp3.diminfo[1].shape = __pyx_pybuffernd_tmp3.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_tmp3, ((PyArrayObject *)__pyx_t_12)); + __pyx_t_12 = 0; + + /* "GPy/models/state_space_cython.pyx":843 + * tmp3 = dS.T / S + * + * dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ # <<<<<<<<<<<<<< + * np.dot( P_pred, np.dot( tmp1, tmp3 ) ) + * + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_7)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_13 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_7) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); __pyx_t_7 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, ((PyObject *)__pyx_v_dP_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_tmp1)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, ((PyObject *)__pyx_v_tmp1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp1)); + __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_13 = 1; + } + } + __pyx_t_11 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (__pyx_t_9) { + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_11, 0+__pyx_t_13, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + __Pyx_INCREF(((PyObject *)__pyx_v_tmp2)); + PyTuple_SET_ITEM(__pyx_t_11, 1+__pyx_t_13, ((PyObject *)__pyx_v_tmp2)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp2)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(__pyx_t_12, __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":844 + * + * dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ + * np.dot( P_pred, np.dot( tmp1, tmp3 ) ) # <<<<<<<<<<<<<< + * + * # terms required for the next step, save this for each parameter + */ + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_13 = 1; + } + } + __pyx_t_5 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_9) { + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_tmp1)); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_13, ((PyObject *)__pyx_v_tmp1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp1)); + __Pyx_INCREF(((PyObject *)__pyx_v_tmp3)); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_13, ((PyObject *)__pyx_v_tmp3)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp3)); + __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_5, NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_13 = 1; + } + } + __pyx_t_5 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_10) { + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_13, ((PyObject *)__pyx_v_P_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_pred)); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_13, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":843 + * tmp3 = dS.T / S + * + * dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ # <<<<<<<<<<<<<< + * np.dot( P_pred, np.dot( tmp1, tmp3 ) ) + * + */ + __pyx_t_11 = PyNumber_Subtract(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_11) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_11, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_11); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dK.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dK.rcbuffer->pybuffer, (PyObject*)__pyx_v_dK, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dK.diminfo[0].strides = __pyx_pybuffernd_dK.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dK.diminfo[0].shape = __pyx_pybuffernd_dK.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dK.diminfo[1].strides = __pyx_pybuffernd_dK.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dK.diminfo[1].shape = __pyx_pybuffernd_dK.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_dK, ((PyArrayObject *)__pyx_t_11)); + __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":847 + * + * # terms required for the next step, save this for each parameter + * dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) # <<<<<<<<<<<<<< + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + __pyx_t_13 = 1; + } + } + __pyx_t_5 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (__pyx_t_1) { + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dK)); + PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_13, ((PyObject *)__pyx_v_dK)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dK)); + __Pyx_INCREF(((PyObject *)__pyx_v_v)); + PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_13, ((PyObject *)__pyx_v_v)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_v)); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(((PyObject *)__pyx_v_dm_pred), __pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + __pyx_t_13 = 1; + } + } + __pyx_t_12 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_K)); + PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_13, ((PyObject *)__pyx_v_K)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_K)); + __Pyx_INCREF(((PyObject *)__pyx_v_dv)); + PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_13, ((PyObject *)__pyx_v_dv)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dv)); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Add(__pyx_t_7, __pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_slice__77); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__77); + __Pyx_GIVEREF(__pyx_slice__77); + __Pyx_INCREF(__pyx_slice__78); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__78); + __Pyx_GIVEREF(__pyx_slice__78); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dm_upd), __pyx_t_7, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":849 + * dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) # <<<<<<<<<<<<<< + * dP_upd[:,:,param] += dP_upd[:,:,param].T + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + */ + __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_T); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_10 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_13 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_10) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_13 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_5) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dK)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, ((PyObject *)__pyx_v_dK)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dK)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__79); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__79); + __Pyx_GIVEREF(__pyx_slice__79); + __Pyx_INCREF(__pyx_slice__80); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__80); + __Pyx_GIVEREF(__pyx_slice__80); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_9, __pyx_t_11) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":850 + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + * dP_upd[:,:,param] += dP_upd[:,:,param].T # <<<<<<<<<<<<<< + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + * + */ + __pyx_t_11 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__81); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_slice__81); + __Pyx_GIVEREF(__pyx_slice__81); + __Pyx_INCREF(__pyx_slice__82); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_slice__82); + __Pyx_GIVEREF(__pyx_slice__82); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_9); if (unlikely(__pyx_t_11 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_slice__83); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__83); + __Pyx_GIVEREF(__pyx_slice__83); + __Pyx_INCREF(__pyx_slice__84); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__84); + __Pyx_GIVEREF(__pyx_slice__84); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_7); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_T); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_11, __pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_9, __pyx_t_1) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "GPy/models/state_space_cython.pyx":851 + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + * dP_upd[:,:,param] += dP_upd[:,:,param].T + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) # <<<<<<<<<<<<<< + * + * dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + */ + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__85); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__85); + __Pyx_GIVEREF(__pyx_slice__85); + __Pyx_INCREF(__pyx_slice__86); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__86); + __Pyx_GIVEREF(__pyx_slice__86); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_1); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_11 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_12 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_n_s_dot); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_T); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_14 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_10))) { + __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_10); + if (likely(__pyx_t_14)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_10, function); + __pyx_t_13 = 1; + } + } + __pyx_t_8 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_14) { + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_14); __Pyx_GIVEREF(__pyx_t_14); __pyx_t_14 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dS)); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_13, ((PyObject *)__pyx_v_dS)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dS)); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_13, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_12 = 0; + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_8, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_10)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + __pyx_t_13 = 1; + } + } + __pyx_t_8 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (__pyx_t_10) { + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_K)); + PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_13, ((PyObject *)__pyx_v_K)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_K)); + PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_13, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_v_dP_pred), __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_1, __pyx_t_7) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":853 + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + * + * dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize # <<<<<<<<<<<<<< + * # computing the likelihood change for each parameter: + * tmp5 = v / S + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_INCREF(__pyx_slice__87); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_slice__87); + __Pyx_GIVEREF(__pyx_slice__87); + __Pyx_INCREF(__pyx_slice__88); + PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_slice__88); + __Pyx_GIVEREF(__pyx_slice__88); + PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_7); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_slice__89); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_slice__89); + __Pyx_GIVEREF(__pyx_slice__89); + __Pyx_INCREF(__pyx_slice__90); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__90); + __Pyx_GIVEREF(__pyx_slice__90); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_5); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_T); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_slice__91); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_slice__91); + __Pyx_GIVEREF(__pyx_slice__91); + __Pyx_INCREF(__pyx_slice__92); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__92); + __Pyx_GIVEREF(__pyx_slice__92); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_dP_upd), __pyx_t_1, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":855 + * dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + * # computing the likelihood change for each parameter: + * tmp5 = v / S # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_5 = __Pyx_PyNumber_Divide(((PyObject *)__pyx_v_v), ((PyObject *)__pyx_v_S)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_36 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer); + __pyx_t_37 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer, (PyObject*)__pyx_t_36, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_37 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer, (PyObject*)__pyx_v_tmp5, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_tmp5.diminfo[0].strides = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_tmp5.diminfo[0].shape = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_tmp5.diminfo[1].strides = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_tmp5.diminfo[1].shape = __pyx_pybuffernd_tmp5.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_37 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_36 = 0; + __Pyx_XDECREF_SET(__pyx_v_tmp5, ((PyArrayObject *)__pyx_t_5)); + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":858 + * + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ # <<<<<<<<<<<<<< + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + * + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_sum); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_diag); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_8))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_8, function); + } + } + if (!__pyx_t_9) { + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, ((PyObject *)__pyx_v_tmp3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + } else { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_tmp3)); + PyTuple_SET_ITEM(__pyx_t_11, 0+1, ((PyObject *)__pyx_v_tmp3)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp3)); + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_11, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) { + __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7); + if (likely(__pyx_t_8)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); + __Pyx_INCREF(__pyx_t_8); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_7, function); + } + } + if (!__pyx_t_8) { + __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_t_5); + } else { + __pyx_t_11 = PyTuple_New(1+1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = NULL; + PyTuple_SET_ITEM(__pyx_t_11, 0+1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_11, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":859 + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) # <<<<<<<<<<<<<< + * + * # Compute the actual updates for mean of the states. Variance update + */ + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_sum); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Multiply(((PyObject *)__pyx_v_tmp5), ((PyObject *)__pyx_v_dv)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":858 + * + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ # <<<<<<<<<<<<<< + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + * + */ + __pyx_t_5 = PyNumber_Add(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":859 + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) # <<<<<<<<<<<<<< + * + * # Compute the actual updates for mean of the states. Variance update + */ + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_sum); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_dot); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = NULL; + __pyx_t_13 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_11))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_11); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_11, function); + __pyx_t_13 = 1; + } + } + __pyx_t_9 = PyTuple_New(2+__pyx_t_13); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__pyx_t_1) { + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + } + __Pyx_INCREF(((PyObject *)__pyx_v_dS)); + PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_13, ((PyObject *)__pyx_v_dS)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dS)); + __Pyx_INCREF(((PyObject *)__pyx_v_tmp5)); + PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_13, ((PyObject *)__pyx_v_tmp5)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_tmp5)); + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_9, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Multiply(((PyObject *)__pyx_v_tmp5), __pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __pyx_t_11 = 0; + __pyx_t_11 = PyDict_New(); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + if (PyDict_SetItem(__pyx_t_11, __pyx_n_s_axis, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_8, __pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_11 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Subtract(__pyx_t_5, __pyx_t_11); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + + /* "GPy/models/state_space_cython.pyx":858 + * + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ # <<<<<<<<<<<<<< + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + * + */ + __pyx_t_11 = PyNumber_Negative(__pyx_t_9); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_param); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __Pyx_INCREF(__pyx_slice__93); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__93); + __Pyx_GIVEREF(__pyx_slice__93); + __pyx_t_9 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_d_log_likelihood_update), __pyx_t_5, __pyx_t_11) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + } + goto __pyx_L7; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":864 + * # is computed earlier. + * else: + * dm_upd = None # <<<<<<<<<<<<<< + * dP_upd = None + * d_log_likelihood_update = None + */ + __pyx_t_32 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_32, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_32 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_dm_upd = ((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":865 + * else: + * dm_upd = None + * dP_upd = None # <<<<<<<<<<<<<< + * d_log_likelihood_update = None + * + */ + __pyx_t_33 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_33, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_26); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_28); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_26, __pyx_t_27, __pyx_t_28); + } + } + __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_33 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_dP_upd = ((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":866 + * dm_upd = None + * dP_upd = None + * d_log_likelihood_update = None # <<<<<<<<<<<<<< + * + * m_upd = m_pred + K.dot( v ) + */ + __pyx_t_34 = ((PyArrayObject *)Py_None); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_25 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_34, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_25 < 0)) { + PyErr_Fetch(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_28); Py_XDECREF(__pyx_t_27); Py_XDECREF(__pyx_t_26); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_28, __pyx_t_27, __pyx_t_26); + } + } + __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_25 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_34 = 0; + __Pyx_INCREF(Py_None); + __pyx_v_d_log_likelihood_update = ((PyArrayObject *)Py_None); + } + __pyx_L7:; + + /* "GPy/models/state_space_cython.pyx":868 + * d_log_likelihood_update = None + * + * m_upd = m_pred + K.dot( v ) # <<<<<<<<<<<<<< + * + * ret = (P_upd,S_upd,U_upd) + */ + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_K), __pyx_n_s_dot); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_9)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_9) { + __pyx_t_11 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_v)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + } else { + __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_v)); + PyTuple_SET_ITEM(__pyx_t_8, 0+1, ((PyObject *)__pyx_v_v)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_v)); + __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_v_m_pred), __pyx_t_11); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_v_m_upd = __pyx_t_5; + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":870 + * m_upd = m_pred + K.dot( v ) + * + * ret = (P_upd,S_upd,U_upd) # <<<<<<<<<<<<<< + * return m_upd, ret, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update + * + */ + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_v_P_upd)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_P_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_upd)); + __Pyx_INCREF(((PyObject *)__pyx_v_S_upd)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_S_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S_upd)); + __Pyx_INCREF(((PyObject *)__pyx_v_U_upd)); + PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_U_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_U_upd)); + __pyx_v_ret = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":871 + * + * ret = (P_upd,S_upd,U_upd) + * return m_upd, ret, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update # <<<<<<<<<<<<<< + * + * + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyTuple_New(6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_m_upd); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_m_upd); + __Pyx_GIVEREF(__pyx_v_m_upd); + __Pyx_INCREF(__pyx_v_ret); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_ret); + __Pyx_GIVEREF(__pyx_v_ret); + __Pyx_INCREF(((PyObject *)__pyx_v_log_likelihood_update)); + PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_log_likelihood_update)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_log_likelihood_update)); + __Pyx_INCREF(((PyObject *)__pyx_v_dm_upd)); + PyTuple_SET_ITEM(__pyx_t_5, 3, ((PyObject *)__pyx_v_dm_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_upd)); + __Pyx_INCREF(((PyObject *)__pyx_v_dP_upd)); + PyTuple_SET_ITEM(__pyx_t_5, 4, ((PyObject *)__pyx_v_dP_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_upd)); + __Pyx_INCREF(((PyObject *)__pyx_v_d_log_likelihood_update)); + PyTuple_SET_ITEM(__pyx_t_5, 5, ((PyObject *)__pyx_v_d_log_likelihood_update)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_d_log_likelihood_update)); + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":649 + * + * @cython.boundscheck(False) + * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_14); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_v.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython._kalman_update_step_SVD_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_H.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_K.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_R_isr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_svd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_V_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dH_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dK.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dR_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dS.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred_all_params.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dv.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_measurement.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dP.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_dm.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_p_m.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_svd_2_matr.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp1.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp2.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp3.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_tmp5.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_v.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_m_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_P_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_S_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_V_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_H); + __Pyx_XDECREF((PyObject *)__pyx_v_R); + __Pyx_XDECREF((PyObject *)__pyx_v_R_isr); + __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood_update); + __Pyx_XDECREF((PyObject *)__pyx_v_v); + __Pyx_XDECREF((PyObject *)__pyx_v_svd_2_matr); + __Pyx_XDECREF(__pyx_v_res); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S_svd); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XDECREF((PyObject *)__pyx_v_U_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_S_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_P_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_K); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_d_log_likelihood_update); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dH_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dR_all_params); + __Pyx_XDECREF((PyObject *)__pyx_v_dH); + __Pyx_XDECREF((PyObject *)__pyx_v_dR); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dv); + __Pyx_XDECREF((PyObject *)__pyx_v_dS); + __Pyx_XDECREF((PyObject *)__pyx_v_tmp1); + __Pyx_XDECREF((PyObject *)__pyx_v_tmp2); + __Pyx_XDECREF((PyObject *)__pyx_v_tmp3); + __Pyx_XDECREF((PyObject *)__pyx_v_dK); + __Pyx_XDECREF((PyObject *)__pyx_v_tmp5); + __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XDECREF(__pyx_v_m_upd); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "GPy/models/state_space_cython.pyx":875 + * + * @cython.boundscheck(False) + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + */ + +/* Python wrapper */ +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyMethodDef __pyx_mdef_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython = {"_cont_discr_kalman_filter_raw_Cython", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython, METH_VARARGS|METH_KEYWORDS, 0}; +static PyObject *__pyx_pw_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_state_dim; + struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables = 0; + struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables = 0; + CYTHON_UNUSED PyObject *__pyx_v_X = 0; + PyObject *__pyx_v_Y = 0; + PyArrayObject *__pyx_v_m_init = 0; + PyArrayObject *__pyx_v_P_init = 0; + CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type = 0; + int __pyx_v_calc_log_likelihood; + int __pyx_v_calc_grad_log_likelihood; + int __pyx_v_grad_params_no; + PyArrayObject *__pyx_v_dm_init = 0; + PyArrayObject *__pyx_v_dP_init = 0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("_cont_discr_kalman_filter_raw_Cython (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_state_dim,&__pyx_n_s_p_dynamic_callables,&__pyx_n_s_p_measurement_callables,&__pyx_n_s_X,&__pyx_n_s_Y,&__pyx_n_s_m_init,&__pyx_n_s_P_init,&__pyx_n_s_p_kalman_filter_type,&__pyx_n_s_calc_log_likelihood,&__pyx_n_s_calc_grad_log_likelihood,&__pyx_n_s_grad_params_no,&__pyx_n_s_dm_init,&__pyx_n_s_dP_init,0}; + PyObject* values[13] = {0,0,0,0,0,0,0,0,0,0,0,0,0}; + + /* "GPy/models/state_space_cython.pyx":877 + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, # <<<<<<<<<<<<<< + * p_kalman_filter_type='regular', + * bint calc_log_likelihood=False, + */ + values[5] = (PyObject *)((PyArrayObject *)Py_None); + values[6] = (PyObject *)((PyArrayObject *)Py_None); + values[7] = ((PyObject *)__pyx_n_s_regular); + + /* "GPy/models/state_space_cython.pyx":882 + * bint calc_grad_log_likelihood=False, + * int grad_params_no=0, + * np.ndarray[DTYPE_t, ndim=3] dm_init=None, # <<<<<<<<<<<<<< + * np.ndarray[DTYPE_t, ndim=3] dP_init=None): + * + */ + values[11] = (PyObject *)((PyArrayObject *)Py_None); + + /* "GPy/models/state_space_cython.pyx":883 + * int grad_params_no=0, + * np.ndarray[DTYPE_t, ndim=3] dm_init=None, + * np.ndarray[DTYPE_t, ndim=3] dP_init=None): # <<<<<<<<<<<<<< + * + * cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter + */ + values[12] = (PyObject *)((PyArrayObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); + case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); + case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); + case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_state_dim)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_dynamic_callables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_measurement_callables)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_X)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_Y)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_m_init); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_P_init); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_p_kalman_filter_type); + if (value) { values[7] = value; kw_args--; } + } + case 8: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_calc_log_likelihood); + if (value) { values[8] = value; kw_args--; } + } + case 9: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_calc_grad_log_likelihood); + if (value) { values[9] = value; kw_args--; } + } + case 10: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_grad_params_no); + if (value) { values[10] = value; kw_args--; } + } + case 11: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dm_init); + if (value) { values[11] = value; kw_args--; } + } + case 12: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_dP_init); + if (value) { values[12] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_cont_discr_kalman_filter_raw_Cython") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); + case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); + case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); + case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v_state_dim = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_state_dim == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_p_dynamic_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)values[1]); + __pyx_v_p_measurement_callables = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)values[2]); + __pyx_v_X = values[3]; + __pyx_v_Y = values[4]; + __pyx_v_m_init = ((PyArrayObject *)values[5]); + __pyx_v_P_init = ((PyArrayObject *)values[6]); + __pyx_v_p_kalman_filter_type = values[7]; + if (values[8]) { + __pyx_v_calc_log_likelihood = __Pyx_PyObject_IsTrue(values[8]); if (unlikely((__pyx_v_calc_log_likelihood == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "GPy/models/state_space_cython.pyx":879 + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + * p_kalman_filter_type='regular', + * bint calc_log_likelihood=False, # <<<<<<<<<<<<<< + * bint calc_grad_log_likelihood=False, + * int grad_params_no=0, + */ + __pyx_v_calc_log_likelihood = ((int)0); + } + if (values[9]) { + __pyx_v_calc_grad_log_likelihood = __Pyx_PyObject_IsTrue(values[9]); if (unlikely((__pyx_v_calc_grad_log_likelihood == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + + /* "GPy/models/state_space_cython.pyx":880 + * p_kalman_filter_type='regular', + * bint calc_log_likelihood=False, + * bint calc_grad_log_likelihood=False, # <<<<<<<<<<<<<< + * int grad_params_no=0, + * np.ndarray[DTYPE_t, ndim=3] dm_init=None, + */ + __pyx_v_calc_grad_log_likelihood = ((int)0); + } + if (values[10]) { + __pyx_v_grad_params_no = __Pyx_PyInt_As_int(values[10]); if (unlikely((__pyx_v_grad_params_no == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_grad_params_no = ((int)0); + } + __pyx_v_dm_init = ((PyArrayObject *)values[11]); + __pyx_v_dP_init = ((PyArrayObject *)values[12]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("_cont_discr_kalman_filter_raw_Cython", 0, 5, 13, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("GPy.models.state_space_cython._cont_discr_kalman_filter_raw_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_dynamic_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, 1, "p_dynamic_callables", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_p_measurement_callables), __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, 1, "p_measurement_callables", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_m_init), __pyx_ptype_5numpy_ndarray, 1, "m_init", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_P_init), __pyx_ptype_5numpy_ndarray, 1, "P_init", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dm_init), __pyx_ptype_5numpy_ndarray, 1, "dm_init", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dP_init), __pyx_ptype_5numpy_ndarray, 1, "dP_init", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(__pyx_self, __pyx_v_state_dim, __pyx_v_p_dynamic_callables, __pyx_v_p_measurement_callables, __pyx_v_X, __pyx_v_Y, __pyx_v_m_init, __pyx_v_P_init, __pyx_v_p_kalman_filter_type, __pyx_v_calc_log_likelihood, __pyx_v_calc_grad_log_likelihood, __pyx_v_grad_params_no, __pyx_v_dm_init, __pyx_v_dP_init); + + /* "GPy/models/state_space_cython.pyx":875 + * + * @cython.boundscheck(False) + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + */ + + /* function exit code */ + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_pf_3GPy_6models_18state_space_cython_4_cont_discr_kalman_filter_raw_Cython(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_v_state_dim, struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *__pyx_v_p_dynamic_callables, struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *__pyx_v_p_measurement_callables, CYTHON_UNUSED PyObject *__pyx_v_X, PyObject *__pyx_v_Y, PyArrayObject *__pyx_v_m_init, PyArrayObject *__pyx_v_P_init, CYTHON_UNUSED PyObject *__pyx_v_p_kalman_filter_type, int __pyx_v_calc_log_likelihood, int __pyx_v_calc_grad_log_likelihood, int __pyx_v_grad_params_no, PyArrayObject *__pyx_v_dm_init, PyArrayObject *__pyx_v_dP_init) { + int __pyx_v_steps_no; + int __pyx_v_time_series_no; + PyArrayObject *__pyx_v_M = 0; + PyArrayObject *__pyx_v_P = 0; + PyArrayObject *__pyx_v_U = 0; + PyArrayObject *__pyx_v_S = 0; + CYTHON_UNUSED PyArrayObject *__pyx_v_Vh = 0; + PyObject *__pyx_v_P_upd = 0; + PyArrayObject *__pyx_v_log_likelihood = 0; + PyArrayObject *__pyx_v_grad_log_likelihood = 0; + PyArrayObject *__pyx_v_dm_upd = 0; + PyArrayObject *__pyx_v_dP_upd = 0; + PyArrayObject *__pyx_v_prev_mean = 0; + PyArrayObject *__pyx_v_k_measurment = 0; + PyArrayObject *__pyx_v_m_pred = 0; + PyArrayObject *__pyx_v_m_upd = 0; + PyObject *__pyx_v_P_pred = 0; + PyArrayObject *__pyx_v_dm_pred = 0; + PyArrayObject *__pyx_v_dP_pred = 0; + PyArrayObject *__pyx_v_log_likelihood_update = 0; + PyArrayObject *__pyx_v_d_log_likelihood_update = 0; + int __pyx_v_k; + __Pyx_LocalBuf_ND __pyx_pybuffernd_M; + __Pyx_Buffer __pyx_pybuffer_M; + __Pyx_LocalBuf_ND __pyx_pybuffernd_P; + __Pyx_Buffer __pyx_pybuffer_P; + __Pyx_LocalBuf_ND __pyx_pybuffernd_P_init; + __Pyx_Buffer __pyx_pybuffer_P_init; + __Pyx_LocalBuf_ND __pyx_pybuffernd_S; + __Pyx_Buffer __pyx_pybuffer_S; + __Pyx_LocalBuf_ND __pyx_pybuffernd_U; + __Pyx_Buffer __pyx_pybuffer_U; + __Pyx_LocalBuf_ND __pyx_pybuffernd_Vh; + __Pyx_Buffer __pyx_pybuffer_Vh; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_init; + __Pyx_Buffer __pyx_pybuffer_dP_init; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_pred; + __Pyx_Buffer __pyx_pybuffer_dP_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dP_upd; + __Pyx_Buffer __pyx_pybuffer_dP_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_d_log_likelihood_update; + __Pyx_Buffer __pyx_pybuffer_d_log_likelihood_update; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_init; + __Pyx_Buffer __pyx_pybuffer_dm_init; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_pred; + __Pyx_Buffer __pyx_pybuffer_dm_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_dm_upd; + __Pyx_Buffer __pyx_pybuffer_dm_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_grad_log_likelihood; + __Pyx_Buffer __pyx_pybuffer_grad_log_likelihood; + __Pyx_LocalBuf_ND __pyx_pybuffernd_k_measurment; + __Pyx_Buffer __pyx_pybuffer_k_measurment; + __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood; + __Pyx_Buffer __pyx_pybuffer_log_likelihood; + __Pyx_LocalBuf_ND __pyx_pybuffernd_log_likelihood_update; + __Pyx_Buffer __pyx_pybuffer_log_likelihood_update; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_init; + __Pyx_Buffer __pyx_pybuffer_m_init; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_pred; + __Pyx_Buffer __pyx_pybuffer_m_pred; + __Pyx_LocalBuf_ND __pyx_pybuffernd_m_upd; + __Pyx_Buffer __pyx_pybuffer_m_upd; + __Pyx_LocalBuf_ND __pyx_pybuffernd_prev_mean; + __Pyx_Buffer __pyx_pybuffer_prev_mean; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyArrayObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyArrayObject *__pyx_t_9 = NULL; + PyArrayObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *(*__pyx_t_14)(PyObject *); + PyArrayObject *__pyx_t_15 = NULL; + PyArrayObject *__pyx_t_16 = NULL; + PyArrayObject *__pyx_t_17 = NULL; + PyArrayObject *__pyx_t_18 = NULL; + PyArrayObject *__pyx_t_19 = NULL; + int __pyx_t_20; + PyArrayObject *__pyx_t_21 = NULL; + int __pyx_t_22; + Py_ssize_t __pyx_t_23; + PyArrayObject *__pyx_t_24 = NULL; + PyArrayObject *__pyx_t_25 = NULL; + int __pyx_t_26; + PyObject *__pyx_t_27 = NULL; + PyObject *__pyx_t_28 = NULL; + PyArrayObject *__pyx_t_29 = NULL; + PyArrayObject *__pyx_t_30 = NULL; + PyArrayObject *__pyx_t_31 = NULL; + int __pyx_t_32; + struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset __pyx_t_33; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_cont_discr_kalman_filter_raw_Cython", 0); + __Pyx_INCREF((PyObject *)__pyx_v_P_init); + __pyx_pybuffer_M.pybuffer.buf = NULL; + __pyx_pybuffer_M.refcount = 0; + __pyx_pybuffernd_M.data = NULL; + __pyx_pybuffernd_M.rcbuffer = &__pyx_pybuffer_M; + __pyx_pybuffer_P.pybuffer.buf = NULL; + __pyx_pybuffer_P.refcount = 0; + __pyx_pybuffernd_P.data = NULL; + __pyx_pybuffernd_P.rcbuffer = &__pyx_pybuffer_P; + __pyx_pybuffer_U.pybuffer.buf = NULL; + __pyx_pybuffer_U.refcount = 0; + __pyx_pybuffernd_U.data = NULL; + __pyx_pybuffernd_U.rcbuffer = &__pyx_pybuffer_U; + __pyx_pybuffer_S.pybuffer.buf = NULL; + __pyx_pybuffer_S.refcount = 0; + __pyx_pybuffernd_S.data = NULL; + __pyx_pybuffernd_S.rcbuffer = &__pyx_pybuffer_S; + __pyx_pybuffer_Vh.pybuffer.buf = NULL; + __pyx_pybuffer_Vh.refcount = 0; + __pyx_pybuffernd_Vh.data = NULL; + __pyx_pybuffernd_Vh.rcbuffer = &__pyx_pybuffer_Vh; + __pyx_pybuffer_log_likelihood.pybuffer.buf = NULL; + __pyx_pybuffer_log_likelihood.refcount = 0; + __pyx_pybuffernd_log_likelihood.data = NULL; + __pyx_pybuffernd_log_likelihood.rcbuffer = &__pyx_pybuffer_log_likelihood; + __pyx_pybuffer_grad_log_likelihood.pybuffer.buf = NULL; + __pyx_pybuffer_grad_log_likelihood.refcount = 0; + __pyx_pybuffernd_grad_log_likelihood.data = NULL; + __pyx_pybuffernd_grad_log_likelihood.rcbuffer = &__pyx_pybuffer_grad_log_likelihood; + __pyx_pybuffer_dm_upd.pybuffer.buf = NULL; + __pyx_pybuffer_dm_upd.refcount = 0; + __pyx_pybuffernd_dm_upd.data = NULL; + __pyx_pybuffernd_dm_upd.rcbuffer = &__pyx_pybuffer_dm_upd; + __pyx_pybuffer_dP_upd.pybuffer.buf = NULL; + __pyx_pybuffer_dP_upd.refcount = 0; + __pyx_pybuffernd_dP_upd.data = NULL; + __pyx_pybuffernd_dP_upd.rcbuffer = &__pyx_pybuffer_dP_upd; + __pyx_pybuffer_prev_mean.pybuffer.buf = NULL; + __pyx_pybuffer_prev_mean.refcount = 0; + __pyx_pybuffernd_prev_mean.data = NULL; + __pyx_pybuffernd_prev_mean.rcbuffer = &__pyx_pybuffer_prev_mean; + __pyx_pybuffer_k_measurment.pybuffer.buf = NULL; + __pyx_pybuffer_k_measurment.refcount = 0; + __pyx_pybuffernd_k_measurment.data = NULL; + __pyx_pybuffernd_k_measurment.rcbuffer = &__pyx_pybuffer_k_measurment; + __pyx_pybuffer_m_pred.pybuffer.buf = NULL; + __pyx_pybuffer_m_pred.refcount = 0; + __pyx_pybuffernd_m_pred.data = NULL; + __pyx_pybuffernd_m_pred.rcbuffer = &__pyx_pybuffer_m_pred; + __pyx_pybuffer_m_upd.pybuffer.buf = NULL; + __pyx_pybuffer_m_upd.refcount = 0; + __pyx_pybuffernd_m_upd.data = NULL; + __pyx_pybuffernd_m_upd.rcbuffer = &__pyx_pybuffer_m_upd; + __pyx_pybuffer_dm_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dm_pred.refcount = 0; + __pyx_pybuffernd_dm_pred.data = NULL; + __pyx_pybuffernd_dm_pred.rcbuffer = &__pyx_pybuffer_dm_pred; + __pyx_pybuffer_dP_pred.pybuffer.buf = NULL; + __pyx_pybuffer_dP_pred.refcount = 0; + __pyx_pybuffernd_dP_pred.data = NULL; + __pyx_pybuffernd_dP_pred.rcbuffer = &__pyx_pybuffer_dP_pred; + __pyx_pybuffer_log_likelihood_update.pybuffer.buf = NULL; + __pyx_pybuffer_log_likelihood_update.refcount = 0; + __pyx_pybuffernd_log_likelihood_update.data = NULL; + __pyx_pybuffernd_log_likelihood_update.rcbuffer = &__pyx_pybuffer_log_likelihood_update; + __pyx_pybuffer_d_log_likelihood_update.pybuffer.buf = NULL; + __pyx_pybuffer_d_log_likelihood_update.refcount = 0; + __pyx_pybuffernd_d_log_likelihood_update.data = NULL; + __pyx_pybuffernd_d_log_likelihood_update.rcbuffer = &__pyx_pybuffer_d_log_likelihood_update; + __pyx_pybuffer_m_init.pybuffer.buf = NULL; + __pyx_pybuffer_m_init.refcount = 0; + __pyx_pybuffernd_m_init.data = NULL; + __pyx_pybuffernd_m_init.rcbuffer = &__pyx_pybuffer_m_init; + __pyx_pybuffer_P_init.pybuffer.buf = NULL; + __pyx_pybuffer_P_init.refcount = 0; + __pyx_pybuffernd_P_init.data = NULL; + __pyx_pybuffernd_P_init.rcbuffer = &__pyx_pybuffer_P_init; + __pyx_pybuffer_dm_init.pybuffer.buf = NULL; + __pyx_pybuffer_dm_init.refcount = 0; + __pyx_pybuffernd_dm_init.data = NULL; + __pyx_pybuffernd_dm_init.rcbuffer = &__pyx_pybuffer_dm_init; + __pyx_pybuffer_dP_init.pybuffer.buf = NULL; + __pyx_pybuffer_dP_init.refcount = 0; + __pyx_pybuffernd_dP_init.data = NULL; + __pyx_pybuffernd_dP_init.rcbuffer = &__pyx_pybuffer_dP_init; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_m_init.diminfo[0].strides = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_init.diminfo[0].shape = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_init.diminfo[1].strides = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_init.diminfo[1].shape = __pyx_pybuffernd_m_init.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_P_init.diminfo[0].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_init.diminfo[0].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_init.diminfo[1].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_init.diminfo[1].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[1]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dm_init.diminfo[0].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_init.diminfo[0].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_init.diminfo[1].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_init.diminfo[1].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_init.diminfo[2].strides = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_init.diminfo[2].shape = __pyx_pybuffernd_dm_init.rcbuffer->pybuffer.shape[2]; + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_pybuffernd_dP_init.diminfo[0].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_init.diminfo[0].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_init.diminfo[1].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_init.diminfo[1].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_init.diminfo[2].strides = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_init.diminfo[2].shape = __pyx_pybuffernd_dP_init.rcbuffer->pybuffer.shape[2]; + + /* "GPy/models/state_space_cython.pyx":885 + * np.ndarray[DTYPE_t, ndim=3] dP_init=None): + * + * cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter # <<<<<<<<<<<<<< + * cdef int time_series_no = Y.shape[2] # multiple time series mode + * + */ + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_Y, __pyx_n_s_shape); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_steps_no = __pyx_t_3; + + /* "GPy/models/state_space_cython.pyx":886 + * + * cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter + * cdef int time_series_no = Y.shape[2] # multiple time series mode # <<<<<<<<<<<<<< + * + * # Allocate space for results + */ + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_Y, __pyx_n_s_shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 0); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_time_series_no = __pyx_t_3; + + /* "GPy/models/state_space_cython.pyx":890 + * # Allocate space for results + * # Mean estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE) # <<<<<<<<<<<<<< + * M[0,:,:] = m_init # Initialize mean values + * # Variance estimations. Initial values will be included + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_empty); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_long((__pyx_v_steps_no + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __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 = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_1 = 0; + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_6, __pyx_n_s_dtype, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_M.rcbuffer->pybuffer, (PyObject*)__pyx_t_7, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + __pyx_v_M = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_M.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 890; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_M.diminfo[0].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_M.diminfo[0].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_M.diminfo[1].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_M.diminfo[1].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_M.diminfo[2].strides = __pyx_pybuffernd_M.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_M.diminfo[2].shape = __pyx_pybuffernd_M.rcbuffer->pybuffer.shape[2]; + } + } + __pyx_t_7 = 0; + __pyx_v_M = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":891 + * # Mean estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE) + * M[0,:,:] = m_init # Initialize mean values # <<<<<<<<<<<<<< + * # Variance estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + */ + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_M), __pyx_tuple__96, ((PyObject *)__pyx_v_m_init)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":893 + * M[0,:,:] = m_init # Initialize mean values + * # Variance estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) # <<<<<<<<<<<<<< + * P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + * P[0,:,:] = P_init # Initialize initial covariance matrix + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_empty); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_v_steps_no + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_state_dim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_6 = 0; + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_1) { + __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_4); + } else { + __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __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 = NULL; + PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P.rcbuffer->pybuffer, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + __pyx_v_P = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_P.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_P.diminfo[0].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P.diminfo[0].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P.diminfo[1].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P.diminfo[1].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_P.diminfo[2].strides = __pyx_pybuffernd_P.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_P.diminfo[2].shape = __pyx_pybuffernd_P.rcbuffer->pybuffer.shape[2]; + } + } + __pyx_t_9 = 0; + __pyx_v_P = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":894 + * # Variance estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + * P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful # <<<<<<<<<<<<<< + * P[0,:,:] = P_init # Initialize initial covariance matrix + * + */ + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_P_init), __pyx_n_s_T); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_v_P_init), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Multiply(__pyx_float_0_5, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer); + __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_3 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer, (PyObject*)__pyx_v_P_init, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_P_init.diminfo[0].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_P_init.diminfo[0].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_P_init.diminfo[1].strides = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_P_init.diminfo[1].shape = __pyx_pybuffernd_P_init.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 894; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_10 = 0; + __Pyx_DECREF_SET(__pyx_v_P_init, ((PyArrayObject *)__pyx_t_4)); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":895 + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + * P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + * P[0,:,:] = P_init # Initialize initial covariance matrix # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] U + */ + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_P), __pyx_tuple__99, ((PyObject *)__pyx_v_P_init)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":901 + * cdef np.ndarray[DTYPE_t, ndim=2] Vh + * + * U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_sp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_linalg); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_svd); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_v_P_init)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_P_init)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_init)); + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_full_matrices, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_compute_uv, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":902 + * + * U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) # <<<<<<<<<<<<<< + * S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + * cdef tuple P_upd = (P_init, S,U) + */ + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_overwrite_a, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_check_finite, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":901 + * cdef np.ndarray[DTYPE_t, ndim=2] Vh + * + * U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, # <<<<<<<<<<<<<< + * overwrite_a=False,check_finite=True) + * S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { + PyObject* sequence = __pyx_t_8; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_2 = PyList_GET_ITEM(sequence, 0); + __pyx_t_5 = PyList_GET_ITEM(sequence, 1); + __pyx_t_4 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else { + Py_ssize_t index = -1; + __pyx_t_1 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_1)->tp_iternext; + index = 0; __pyx_t_2 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L3_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + index = 1; __pyx_t_5 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_5)) goto __pyx_L3_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 2; __pyx_t_4 = __pyx_t_14(__pyx_t_1); if (unlikely(!__pyx_t_4)) goto __pyx_L3_unpacking_failed; + __Pyx_GOTREF(__pyx_t_4); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_1), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L4_unpacking_done; + __pyx_L3_unpacking_failed:; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L4_unpacking_done:; + } + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_3 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_U.rcbuffer->pybuffer, (PyObject*)__pyx_v_U, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_U.diminfo[0].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_U.diminfo[0].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_U.diminfo[1].strides = __pyx_pybuffernd_U.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_U.diminfo[1].shape = __pyx_pybuffernd_U.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = 0; + __pyx_v_U = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_16 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_t_16, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack); + if (unlikely(__pyx_t_3 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_S.rcbuffer->pybuffer, (PyObject*)__pyx_v_S, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_S.diminfo[0].strides = __pyx_pybuffernd_S.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_S.diminfo[0].shape = __pyx_pybuffernd_S.rcbuffer->pybuffer.shape[0]; + if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_16 = 0; + __pyx_v_S = ((PyArrayObject *)__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_17 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __pyx_t_3 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_t_17, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_3 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer, (PyObject*)__pyx_v_Vh, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_Vh.diminfo[0].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_Vh.diminfo[0].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_Vh.diminfo[1].strides = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_Vh.diminfo[1].shape = __pyx_pybuffernd_Vh.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_17 = 0; + __pyx_v_Vh = ((PyArrayObject *)__pyx_t_4); + __pyx_t_4 = 0; + + /* "GPy/models/state_space_cython.pyx":903 + * U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, + * overwrite_a=False,check_finite=True) + * S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance # <<<<<<<<<<<<<< + * cdef tuple P_upd = (P_init, S,U) + * #log_likelihood = 0 + */ + __pyx_t_8 = PyObject_RichCompare(((PyObject *)__pyx_v_S), __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_S), __pyx_t_8, __pyx_float_1eneg_17) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":904 + * overwrite_a=False,check_finite=True) + * S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + * cdef tuple P_upd = (P_init, S,U) # <<<<<<<<<<<<<< + * #log_likelihood = 0 + * #grad_log_likelihood = np.zeros((grad_params_no,1)) + */ + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(((PyObject *)__pyx_v_P_init)); + PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_P_init)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P_init)); + __Pyx_INCREF(((PyObject *)__pyx_v_S)); + PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_v_S)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_S)); + __Pyx_INCREF(((PyObject *)__pyx_v_U)); + PyTuple_SET_ITEM(__pyx_t_8, 2, ((PyObject *)__pyx_v_U)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_U)); + __pyx_v_P_upd = ((PyObject*)__pyx_t_8); + __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":907 + * #log_likelihood = 0 + * #grad_log_likelihood = np.zeros((grad_params_no,1)) + * cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood = np.zeros((1, time_series_no), dtype = DTYPE) #if calc_log_likelihood else None # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=2] grad_log_likelihood = np.zeros((grad_params_no, time_series_no), dtype = DTYPE) #if calc_grad_log_likelihood else None + * + */ + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_18 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_log_likelihood = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_18 = 0; + __pyx_v_log_likelihood = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":908 + * #grad_log_likelihood = np.zeros((grad_params_no,1)) + * cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood = np.zeros((1, time_series_no), dtype = DTYPE) #if calc_log_likelihood else None + * cdef np.ndarray[DTYPE_t, ndim=2] grad_log_likelihood = np.zeros((grad_params_no, time_series_no), dtype = DTYPE) #if calc_grad_log_likelihood else None # <<<<<<<<<<<<<< + * + * #setting initial values for derivatives update + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_grad_params_no); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_2 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_DTYPE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_4, __pyx_n_s_dtype, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __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_8); __pyx_t_8 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + __pyx_v_grad_log_likelihood = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_grad_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[1]; + } + } + __pyx_t_19 = 0; + __pyx_v_grad_log_likelihood = ((PyArrayObject *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":911 + * + * #setting initial values for derivatives update + * cdef np.ndarray[DTYPE_t, ndim=3] dm_upd = dm_init # <<<<<<<<<<<<<< + * cdef np.ndarray[DTYPE_t, ndim=3] dP_upd = dP_init + * # Main loop of the Kalman filter + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dm_init), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + __pyx_v_dm_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2]; + } + } + __Pyx_INCREF(((PyObject *)__pyx_v_dm_init)); + __pyx_v_dm_upd = ((PyArrayObject *)__pyx_v_dm_init); + + /* "GPy/models/state_space_cython.pyx":912 + * #setting initial values for derivatives update + * cdef np.ndarray[DTYPE_t, ndim=3] dm_upd = dm_init + * cdef np.ndarray[DTYPE_t, ndim=3] dP_upd = dP_init # <<<<<<<<<<<<<< + * # Main loop of the Kalman filter + * cdef np.ndarray[DTYPE_t, ndim=2] prev_mean, k_measurment + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dP_init), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + __pyx_v_dP_upd = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None); __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.buf = NULL; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } else {__pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2]; + } + } + __Pyx_INCREF(((PyObject *)__pyx_v_dP_init)); + __pyx_v_dP_upd = ((PyArrayObject *)__pyx_v_dP_init); + + /* "GPy/models/state_space_cython.pyx":922 + * + * #print "Hi I am cython" + * for k in range(0,steps_no): # <<<<<<<<<<<<<< + * # In this loop index for new estimations is (k+1), old - (k) + * # This happened because initial values are stored at 0-th index. + */ + __pyx_t_3 = __pyx_v_steps_no; + for (__pyx_t_20 = 0; __pyx_t_20 < __pyx_t_3; __pyx_t_20+=1) { + __pyx_v_k = __pyx_t_20; + + /* "GPy/models/state_space_cython.pyx":927 + * #import pdb; pdb.set_trace() + * + * prev_mean = M[k,:,:] # mean from the previous step # <<<<<<<<<<<<<< + * + * m_pred, P_pred, dm_pred, dP_pred = \ + */ + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__100); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_slice__100); + __Pyx_GIVEREF(__pyx_slice__100); + __Pyx_INCREF(__pyx_slice__101); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_slice__101); + __Pyx_GIVEREF(__pyx_slice__101); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(((PyObject *)__pyx_v_M), __pyx_t_4); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer, (PyObject*)__pyx_v_prev_mean, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_prev_mean.diminfo[0].strides = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_prev_mean.diminfo[0].shape = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_prev_mean.diminfo[1].strides = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_prev_mean.diminfo[1].shape = __pyx_pybuffernd_prev_mean.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_21 = 0; + __Pyx_XDECREF_SET(__pyx_v_prev_mean, ((PyArrayObject *)__pyx_t_2)); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":930 + * + * m_pred, P_pred, dm_pred, dP_pred = \ + * _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables, # <<<<<<<<<<<<<< + * calc_grad_log_likelihood, dm_upd, dP_upd) + * + */ + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_kalman_prediction_step_SVD_Cyth); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + + /* "GPy/models/state_space_cython.pyx":931 + * m_pred, P_pred, dm_pred, dP_pred = \ + * _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables, + * calc_grad_log_likelihood, dm_upd, dP_upd) # <<<<<<<<<<<<<< + * + * k_measurment = Y[k,:,:] + */ + __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_v_calc_grad_log_likelihood); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 931; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = NULL; + __pyx_t_23 = 0; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_1)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + __pyx_t_23 = 1; + } + } + __pyx_t_6 = PyTuple_New(7+__pyx_t_23); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + if (__pyx_t_1) { + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = NULL; + } + PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_23, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __Pyx_INCREF(((PyObject *)__pyx_v_prev_mean)); + PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_23, ((PyObject *)__pyx_v_prev_mean)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_prev_mean)); + __Pyx_INCREF(__pyx_v_P_upd); + PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_23, __pyx_v_P_upd); + __Pyx_GIVEREF(__pyx_v_P_upd); + __Pyx_INCREF(((PyObject *)__pyx_v_p_dynamic_callables)); + PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_23, ((PyObject *)__pyx_v_p_dynamic_callables)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_p_dynamic_callables)); + PyTuple_SET_ITEM(__pyx_t_6, 4+__pyx_t_23, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_v_dm_upd)); + PyTuple_SET_ITEM(__pyx_t_6, 5+__pyx_t_23, ((PyObject *)__pyx_v_dm_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dm_upd)); + __Pyx_INCREF(((PyObject *)__pyx_v_dP_upd)); + PyTuple_SET_ITEM(__pyx_t_6, 6+__pyx_t_23, ((PyObject *)__pyx_v_dP_upd)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_dP_upd)); + __pyx_t_8 = 0; + __pyx_t_5 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { + PyObject* sequence = __pyx_t_2; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 4)) { + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_8 = PyTuple_GET_ITEM(sequence, 3); + } else { + __pyx_t_4 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + __pyx_t_5 = PyList_GET_ITEM(sequence, 2); + __pyx_t_8 = PyList_GET_ITEM(sequence, 3); + } + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_8); + #else + { + Py_ssize_t i; + PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_6,&__pyx_t_5,&__pyx_t_8}; + for (i=0; i < 4; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[4] = {&__pyx_t_4,&__pyx_t_6,&__pyx_t_5,&__pyx_t_8}; + __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_1)->tp_iternext; + for (index=0; index < 4; index++) { + PyObject* item = __pyx_t_14(__pyx_t_1); if (unlikely(!item)) goto __pyx_L7_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_1), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L8_unpacking_done; + __pyx_L7_unpacking_failed:; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L8_unpacking_done:; + } + + /* "GPy/models/state_space_cython.pyx":929 + * prev_mean = M[k,:,:] # mean from the previous step + * + * m_pred, P_pred, dm_pred, dP_pred = \ # <<<<<<<<<<<<<< + * _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables, + * calc_grad_log_likelihood, dm_upd, dP_upd) + */ + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyTuple_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_6)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_m_pred.diminfo[0].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_pred.diminfo[0].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_pred.diminfo[1].strides = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_pred.diminfo[1].shape = __pyx_pybuffernd_m_pred.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_24 = 0; + __Pyx_XDECREF_SET(__pyx_v_m_pred, ((PyArrayObject *)__pyx_t_4)); + __pyx_t_4 = 0; + __Pyx_XDECREF_SET(__pyx_v_P_pred, ((PyObject*)__pyx_t_6)); + __pyx_t_6 = 0; + __pyx_t_25 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_dm_pred.diminfo[0].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_pred.diminfo[0].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_pred.diminfo[1].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_pred.diminfo[1].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_pred.diminfo[2].strides = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_pred.diminfo[2].shape = __pyx_pybuffernd_dm_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_25 = 0; + __Pyx_XDECREF_SET(__pyx_v_dm_pred, ((PyArrayObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_25 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_t_25, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_dP_pred.diminfo[0].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_pred.diminfo[0].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_pred.diminfo[1].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_pred.diminfo[1].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_pred.diminfo[2].strides = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_pred.diminfo[2].shape = __pyx_pybuffernd_dP_pred.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_25 = 0; + __Pyx_XDECREF_SET(__pyx_v_dP_pred, ((PyArrayObject *)__pyx_t_8)); + __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":933 + * calc_grad_log_likelihood, dm_upd, dP_upd) + * + * k_measurment = Y[k,:,:] # <<<<<<<<<<<<<< + * if (np.any(np.isnan(k_measurment)) == False): + * # if np.any(np.isnan(k_measurment)): + */ + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_slice__102); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_slice__102); + __Pyx_GIVEREF(__pyx_slice__102); + __Pyx_INCREF(__pyx_slice__103); + PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_slice__103); + __Pyx_GIVEREF(__pyx_slice__103); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(__pyx_v_Y, __pyx_t_8); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_21 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer, (PyObject*)__pyx_t_21, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer, (PyObject*)__pyx_v_k_measurment, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_k_measurment.diminfo[0].strides = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_k_measurment.diminfo[0].shape = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_k_measurment.diminfo[1].strides = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_k_measurment.diminfo[1].shape = __pyx_pybuffernd_k_measurment.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_21 = 0; + __Pyx_XDECREF_SET(__pyx_v_k_measurment, ((PyArrayObject *)__pyx_t_2)); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":934 + * + * k_measurment = Y[k,:,:] + * if (np.any(np.isnan(k_measurment)) == False): # <<<<<<<<<<<<<< + * # if np.any(np.isnan(k_measurment)): + * # raise ValueError("Nan measurements are currently not supported") + */ + __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_any); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_isnan); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_4, function); + } + } + if (!__pyx_t_6) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_4, ((PyObject *)__pyx_v_k_measurment)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_k_measurment)); + PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_k_measurment)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_k_measurment)); + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_GOTREF(__pyx_t_2); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; + PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_26 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_26) { + + /* "GPy/models/state_space_cython.pyx":939 + * + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, # <<<<<<<<<<<<<< + * k_measurment, calc_log_likelihood=calc_log_likelihood, + * calc_grad_log_likelihood=calc_grad_log_likelihood, + */ + __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_kalman_update_step_SVD_Cython); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + + /* "GPy/models/state_space_cython.pyx":940 + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, + * k_measurment, calc_log_likelihood=calc_log_likelihood, # <<<<<<<<<<<<<< + * calc_grad_log_likelihood=calc_grad_log_likelihood, + * p_dm = dm_pred, p_dP = dP_pred) + */ + __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_m_pred)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_INCREF(__pyx_v_P_pred); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_P_pred); + __Pyx_GIVEREF(__pyx_v_P_pred); + __Pyx_INCREF(((PyObject *)__pyx_v_p_measurement_callables)); + PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_p_measurement_callables)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_p_measurement_callables)); + __Pyx_INCREF(((PyObject *)__pyx_v_k_measurment)); + PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_k_measurment)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_k_measurment)); + __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":939 + * + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, # <<<<<<<<<<<<<< + * k_measurment, calc_log_likelihood=calc_log_likelihood, + * calc_grad_log_likelihood=calc_grad_log_likelihood, + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + + /* "GPy/models/state_space_cython.pyx":940 + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, + * k_measurment, calc_log_likelihood=calc_log_likelihood, # <<<<<<<<<<<<<< + * calc_grad_log_likelihood=calc_grad_log_likelihood, + * p_dm = dm_pred, p_dP = dP_pred) + */ + __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_calc_log_likelihood); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_calc_log_likelihood, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":941 + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, + * k_measurment, calc_log_likelihood=calc_log_likelihood, + * calc_grad_log_likelihood=calc_grad_log_likelihood, # <<<<<<<<<<<<<< + * p_dm = dm_pred, p_dP = dP_pred) + * else: + */ + __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_v_calc_grad_log_likelihood); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_calc_grad_log_likelihood, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + + /* "GPy/models/state_space_cython.pyx":942 + * k_measurment, calc_log_likelihood=calc_log_likelihood, + * calc_grad_log_likelihood=calc_grad_log_likelihood, + * p_dm = dm_pred, p_dP = dP_pred) # <<<<<<<<<<<<<< + * else: + * if not np.all(np.isnan(k_measurment)): + */ + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_p_dm, ((PyObject *)__pyx_v_dm_pred)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_p_dP, ((PyObject *)__pyx_v_dP_pred)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":939 + * + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, # <<<<<<<<<<<<<< + * k_measurment, calc_log_likelihood=calc_log_likelihood, + * calc_grad_log_likelihood=calc_grad_log_likelihood, + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { + PyObject* sequence = __pyx_t_8; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 6)) { + if (size > 6) __Pyx_RaiseTooManyValuesError(6); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_27 = PyTuple_GET_ITEM(sequence, 5); + } else { + __pyx_t_2 = PyList_GET_ITEM(sequence, 0); + __pyx_t_1 = PyList_GET_ITEM(sequence, 1); + __pyx_t_5 = PyList_GET_ITEM(sequence, 2); + __pyx_t_4 = PyList_GET_ITEM(sequence, 3); + __pyx_t_6 = PyList_GET_ITEM(sequence, 4); + __pyx_t_27 = PyList_GET_ITEM(sequence, 5); + } + __Pyx_INCREF(__pyx_t_2); + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(__pyx_t_27); + #else + { + Py_ssize_t i; + PyObject** temps[6] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_5,&__pyx_t_4,&__pyx_t_6,&__pyx_t_27}; + for (i=0; i < 6; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(item); + *(temps[i]) = item; + } + } + #endif + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + } else { + Py_ssize_t index = -1; + PyObject** temps[6] = {&__pyx_t_2,&__pyx_t_1,&__pyx_t_5,&__pyx_t_4,&__pyx_t_6,&__pyx_t_27}; + __pyx_t_28 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_28); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_14 = Py_TYPE(__pyx_t_28)->tp_iternext; + for (index=0; index < 6; index++) { + PyObject* item = __pyx_t_14(__pyx_t_28); if (unlikely(!item)) goto __pyx_L10_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_14(__pyx_t_28), 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = NULL; + __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; + goto __pyx_L11_unpacking_done; + __pyx_L10_unpacking_failed:; + __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0; + __pyx_t_14 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L11_unpacking_done:; + } + + /* "GPy/models/state_space_cython.pyx":938 + * # raise ValueError("Nan measurements are currently not supported") + * + * m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ # <<<<<<<<<<<<<< + * _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, + * k_measurment, calc_log_likelihood=calc_log_likelihood, + */ + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyTuple_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_6) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_27) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_27, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_24 = ((PyArrayObject *)__pyx_t_2); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_24, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_m_upd.diminfo[0].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_upd.diminfo[0].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_upd.diminfo[1].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_upd.diminfo[1].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_24 = 0; + __Pyx_XDECREF_SET(__pyx_v_m_upd, ((PyArrayObject *)__pyx_t_2)); + __pyx_t_2 = 0; + __Pyx_DECREF_SET(__pyx_v_P_upd, ((PyObject*)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_29 = ((PyArrayObject *)__pyx_t_5); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __Pyx_XDECREF_SET(__pyx_v_log_likelihood_update, ((PyArrayObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_30 = ((PyArrayObject *)__pyx_t_4); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_30, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_30 = 0; + __Pyx_DECREF_SET(__pyx_v_dm_upd, ((PyArrayObject *)__pyx_t_4)); + __pyx_t_4 = 0; + __pyx_t_31 = ((PyArrayObject *)__pyx_t_6); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_t_31, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_31 = 0; + __Pyx_DECREF_SET(__pyx_v_dP_upd, ((PyArrayObject *)__pyx_t_6)); + __pyx_t_6 = 0; + __pyx_t_29 = ((PyArrayObject *)__pyx_t_27); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __Pyx_XDECREF_SET(__pyx_v_d_log_likelihood_update, ((PyArrayObject *)__pyx_t_27)); + __pyx_t_27 = 0; + goto __pyx_L9; + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":944 + * p_dm = dm_pred, p_dP = dP_pred) + * else: + * if not np.all(np.isnan(k_measurment)): # <<<<<<<<<<<<<< + * raise ValueError("""Nan measurements are currently not supported if + * they are intermixed with not NaN measurements""") + */ + __pyx_t_27 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_27); + __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_n_s_all); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_isnan); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_4)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_4); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_4) { + __pyx_t_27 = __Pyx_PyObject_CallOneArg(__pyx_t_5, ((PyObject *)__pyx_v_k_measurment)); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_27); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL; + __Pyx_INCREF(((PyObject *)__pyx_v_k_measurment)); + PyTuple_SET_ITEM(__pyx_t_1, 0+1, ((PyObject *)__pyx_v_k_measurment)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_k_measurment)); + __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_27); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) { + __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); + if (likely(__pyx_t_5)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_6, function); + } + } + if (!__pyx_t_5) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_27); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + __Pyx_GOTREF(__pyx_t_8); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; + PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_27); + __Pyx_GIVEREF(__pyx_t_27); + __pyx_t_27 = 0; + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_26 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_32 = ((!__pyx_t_26) != 0); + if (__pyx_t_32) { + + /* "GPy/models/state_space_cython.pyx":945 + * else: + * if not np.all(np.isnan(k_measurment)): + * raise ValueError("""Nan measurements are currently not supported if # <<<<<<<<<<<<<< + * they are intermixed with not NaN measurements""") + * else: + */ + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__104, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_Raise(__pyx_t_8, 0, 0, 0); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + /*else*/ { + + /* "GPy/models/state_space_cython.pyx":948 + * they are intermixed with not NaN measurements""") + * else: + * m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred # <<<<<<<<<<<<<< + * if calc_log_likelihood: + * log_likelihood_update = np.zeros((1,time_series_no)) + */ + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_pred, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_m_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_m_upd.diminfo[0].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_m_upd.diminfo[0].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_m_upd.diminfo[1].strides = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_m_upd.diminfo[1].shape = __pyx_pybuffernd_m_upd.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(((PyObject *)__pyx_v_m_pred)); + __Pyx_XDECREF_SET(__pyx_v_m_upd, __pyx_v_m_pred); + __Pyx_INCREF(__pyx_v_P_pred); + __Pyx_DECREF_SET(__pyx_v_P_upd, __pyx_v_P_pred); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dm_pred), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dm_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_dm_upd.diminfo[0].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dm_upd.diminfo[0].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dm_upd.diminfo[1].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dm_upd.diminfo[1].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dm_upd.diminfo[2].strides = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dm_upd.diminfo[2].shape = __pyx_pybuffernd_dm_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(((PyObject *)__pyx_v_dm_pred)); + __Pyx_DECREF_SET(__pyx_v_dm_upd, ((PyArrayObject *)__pyx_v_dm_pred)); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)((PyArrayObject *)__pyx_v_dP_pred), &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer, (PyObject*)__pyx_v_dP_upd, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 3, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_dP_upd.diminfo[0].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_dP_upd.diminfo[0].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_dP_upd.diminfo[1].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_dP_upd.diminfo[1].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[1]; __pyx_pybuffernd_dP_upd.diminfo[2].strides = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.strides[2]; __pyx_pybuffernd_dP_upd.diminfo[2].shape = __pyx_pybuffernd_dP_upd.rcbuffer->pybuffer.shape[2]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_INCREF(((PyObject *)__pyx_v_dP_pred)); + __Pyx_DECREF_SET(__pyx_v_dP_upd, ((PyArrayObject *)__pyx_v_dP_pred)); + + /* "GPy/models/state_space_cython.pyx":949 + * else: + * m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred + * if calc_log_likelihood: # <<<<<<<<<<<<<< + * log_likelihood_update = np.zeros((1,time_series_no)) + * if calc_grad_log_likelihood: + */ + __pyx_t_32 = (__pyx_v_calc_log_likelihood != 0); + if (__pyx_t_32) { + + /* "GPy/models/state_space_cython.pyx":950 + * m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred + * if calc_log_likelihood: + * log_likelihood_update = np.zeros((1,time_series_no)) # <<<<<<<<<<<<<< + * if calc_grad_log_likelihood: + * d_log_likelihood_update = np.zeros((grad_params_no,time_series_no)) + */ + __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_27 = PyTuple_New(2); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_27); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_27, 0, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_27, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) { + __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1); + if (likely(__pyx_t_6)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); + __Pyx_INCREF(__pyx_t_6); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_1, function); + } + } + if (!__pyx_t_6) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_27); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0; + __Pyx_GOTREF(__pyx_t_8); + } else { + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL; + PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_27); + __Pyx_GIVEREF(__pyx_t_27); + __pyx_t_27 = 0; + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __Pyx_XDECREF_SET(__pyx_v_log_likelihood_update, ((PyArrayObject *)__pyx_t_8)); + __pyx_t_8 = 0; + goto __pyx_L13; + } + __pyx_L13:; + + /* "GPy/models/state_space_cython.pyx":951 + * if calc_log_likelihood: + * log_likelihood_update = np.zeros((1,time_series_no)) + * if calc_grad_log_likelihood: # <<<<<<<<<<<<<< + * d_log_likelihood_update = np.zeros((grad_params_no,time_series_no)) + * + */ + __pyx_t_32 = (__pyx_v_calc_grad_log_likelihood != 0); + if (__pyx_t_32) { + + /* "GPy/models/state_space_cython.pyx":952 + * log_likelihood_update = np.zeros((1,time_series_no)) + * if calc_grad_log_likelihood: + * d_log_likelihood_update = np.zeros((grad_params_no,time_series_no)) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_grad_params_no); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_27 = __Pyx_PyInt_From_int(__pyx_v_time_series_no); if (unlikely(!__pyx_t_27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_27); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_27); + __Pyx_GIVEREF(__pyx_t_27); + __pyx_t_1 = 0; + __pyx_t_27 = 0; + __pyx_t_27 = NULL; + if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) { + __pyx_t_27 = PyMethod_GET_SELF(__pyx_t_5); + if (likely(__pyx_t_27)) { + PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); + __Pyx_INCREF(__pyx_t_27); + __Pyx_INCREF(function); + __Pyx_DECREF_SET(__pyx_t_5, function); + } + } + if (!__pyx_t_27) { + __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_GOTREF(__pyx_t_8); + } else { + __pyx_t_1 = PyTuple_New(1+1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_27); __Pyx_GIVEREF(__pyx_t_27); __pyx_t_27 = NULL; + PyTuple_SET_ITEM(__pyx_t_1, 0+1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_29 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_t_29, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer, (PyObject*)__pyx_v_d_log_likelihood_update, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[0].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].strides = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_d_log_likelihood_update.diminfo[1].shape = __pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_29 = 0; + __Pyx_XDECREF_SET(__pyx_v_d_log_likelihood_update, ((PyArrayObject *)__pyx_t_8)); + __pyx_t_8 = 0; + goto __pyx_L14; + } + __pyx_L14:; + } + } + __pyx_L9:; + + /* "GPy/models/state_space_cython.pyx":955 + * + * + * if calc_log_likelihood: # <<<<<<<<<<<<<< + * log_likelihood += log_likelihood_update + * + */ + __pyx_t_32 = (__pyx_v_calc_log_likelihood != 0); + if (__pyx_t_32) { + + /* "GPy/models/state_space_cython.pyx":956 + * + * if calc_log_likelihood: + * log_likelihood += log_likelihood_update # <<<<<<<<<<<<<< + * + * if calc_grad_log_likelihood: + */ + __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_log_likelihood), ((PyObject *)__pyx_v_log_likelihood_update)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_18 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_18, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_v_log_likelihood, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_13); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_11); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_13, __pyx_t_12, __pyx_t_11); + } + } + __pyx_pybuffernd_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_18 = 0; + __Pyx_DECREF_SET(__pyx_v_log_likelihood, ((PyArrayObject *)__pyx_t_8)); + __pyx_t_8 = 0; + goto __pyx_L15; + } + __pyx_L15:; + + /* "GPy/models/state_space_cython.pyx":958 + * log_likelihood += log_likelihood_update + * + * if calc_grad_log_likelihood: # <<<<<<<<<<<<<< + * grad_log_likelihood += d_log_likelihood_update + * + */ + __pyx_t_32 = (__pyx_v_calc_grad_log_likelihood != 0); + if (__pyx_t_32) { + + /* "GPy/models/state_space_cython.pyx":959 + * + * if calc_grad_log_likelihood: + * grad_log_likelihood += d_log_likelihood_update # <<<<<<<<<<<<<< + * + * M[k+1,:,:] = m_upd # separate mean value for each time series + */ + __pyx_t_8 = PyNumber_InPlaceAdd(((PyObject *)__pyx_v_grad_log_likelihood), ((PyObject *)__pyx_v_d_log_likelihood_update)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + if (!(likely(((__pyx_t_8) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_8, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = ((PyArrayObject *)__pyx_t_8); + { + __Pyx_BufFmt_StackElem __pyx_stack[1]; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer); + __pyx_t_22 = __Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_t_19, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack); + if (unlikely(__pyx_t_22 < 0)) { + PyErr_Fetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13); + if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer, (PyObject*)__pyx_v_grad_log_likelihood, &__Pyx_TypeInfo_nn___pyx_t_3GPy_6models_18state_space_cython_DTYPE_t, PyBUF_FORMAT| PyBUF_STRIDES, 2, 0, __pyx_stack) == -1)) { + Py_XDECREF(__pyx_t_11); Py_XDECREF(__pyx_t_12); Py_XDECREF(__pyx_t_13); + __Pyx_RaiseBufferFallbackError(); + } else { + PyErr_Restore(__pyx_t_11, __pyx_t_12, __pyx_t_13); + } + } + __pyx_pybuffernd_grad_log_likelihood.diminfo[0].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[0].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].strides = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_grad_log_likelihood.diminfo[1].shape = __pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer.shape[1]; + if (unlikely(__pyx_t_22 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_19 = 0; + __Pyx_DECREF_SET(__pyx_v_grad_log_likelihood, ((PyArrayObject *)__pyx_t_8)); + __pyx_t_8 = 0; + goto __pyx_L16; + } + __pyx_L16:; + + /* "GPy/models/state_space_cython.pyx":961 + * grad_log_likelihood += d_log_likelihood_update + * + * M[k+1,:,:] = m_upd # separate mean value for each time series # <<<<<<<<<<<<<< + * P[k+1,:,:] = P_upd[0] + * + */ + __pyx_t_8 = __Pyx_PyInt_From_long((__pyx_v_k + 1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __Pyx_INCREF(__pyx_slice__105); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_slice__105); + __Pyx_GIVEREF(__pyx_slice__105); + __Pyx_INCREF(__pyx_slice__106); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_slice__106); + __Pyx_GIVEREF(__pyx_slice__106); + __pyx_t_8 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_M), __pyx_t_5, ((PyObject *)__pyx_v_m_upd)) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + + /* "GPy/models/state_space_cython.pyx":962 + * + * M[k+1,:,:] = m_upd # separate mean value for each time series + * P[k+1,:,:] = P_upd[0] # <<<<<<<<<<<<<< + * + * return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) + */ + if (unlikely(__pyx_v_P_upd == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_v_P_upd, 0); + __Pyx_INCREF(__pyx_t_5); + __pyx_t_8 = __Pyx_PyInt_From_long((__pyx_v_k + 1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __Pyx_INCREF(__pyx_slice__107); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_slice__107); + __Pyx_GIVEREF(__pyx_slice__107); + __Pyx_INCREF(__pyx_slice__108); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_slice__108); + __Pyx_GIVEREF(__pyx_slice__108); + __pyx_t_8 = 0; + if (unlikely(PyObject_SetItem(((PyObject *)__pyx_v_P), __pyx_t_1, __pyx_t_5) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + + /* "GPy/models/state_space_cython.pyx":964 + * P[k+1,:,:] = P_upd[0] + * + * return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_33.__pyx_n = 1; + __pyx_t_33.compute_derivatives = 0; + __pyx_t_5 = ((struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)__pyx_v_p_dynamic_callables->__pyx_vtab)->reset(__pyx_v_p_dynamic_callables, 0, &__pyx_t_33); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_M)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_M)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_M)); + __Pyx_INCREF(((PyObject *)__pyx_v_P)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_P)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_P)); + __Pyx_INCREF(((PyObject *)__pyx_v_log_likelihood)); + PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_log_likelihood)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_log_likelihood)); + __Pyx_INCREF(((PyObject *)__pyx_v_grad_log_likelihood)); + PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_grad_log_likelihood)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_grad_log_likelihood)); + PyTuple_SET_ITEM(__pyx_t_1, 4, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "GPy/models/state_space_cython.pyx":875 + * + * @cython.boundscheck(False) + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_27); + __Pyx_XDECREF(__pyx_t_28); + { PyObject *__pyx_type, *__pyx_value, *__pyx_tb; + __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_M.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer); + __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);} + __Pyx_AddTraceback("GPy.models.state_space_cython._cont_discr_kalman_filter_raw_Cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + goto __pyx_L2; + __pyx_L0:; + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_M.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_P_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_S.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_U.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_Vh.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dP_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_d_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_dm_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_grad_log_likelihood.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_k_measurment.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_log_likelihood_update.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_init.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_pred.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_m_upd.rcbuffer->pybuffer); + __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_prev_mean.rcbuffer->pybuffer); + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_M); + __Pyx_XDECREF((PyObject *)__pyx_v_P); + __Pyx_XDECREF((PyObject *)__pyx_v_U); + __Pyx_XDECREF((PyObject *)__pyx_v_S); + __Pyx_XDECREF((PyObject *)__pyx_v_Vh); + __Pyx_XDECREF(__pyx_v_P_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood); + __Pyx_XDECREF((PyObject *)__pyx_v_grad_log_likelihood); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_upd); + __Pyx_XDECREF((PyObject *)__pyx_v_prev_mean); + __Pyx_XDECREF((PyObject *)__pyx_v_k_measurment); + __Pyx_XDECREF((PyObject *)__pyx_v_m_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_m_upd); + __Pyx_XDECREF(__pyx_v_P_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dm_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_dP_pred); + __Pyx_XDECREF((PyObject *)__pyx_v_log_likelihood_update); + __Pyx_XDECREF((PyObject *)__pyx_v_d_log_likelihood_update); + __Pyx_XDECREF((PyObject *)__pyx_v_P_init); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + +/* Python wrapper */ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /*proto*/ +static CYTHON_UNUSED int __pyx_pw_5numpy_7ndarray_1__getbuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); + __pyx_r = __pyx_pf_5numpy_7ndarray___getbuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { + int __pyx_v_copy_shape; + int __pyx_v_i; + int __pyx_v_ndim; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + int __pyx_v_t; + char *__pyx_v_f; + PyArray_Descr *__pyx_v_descr = 0; + int __pyx_v_offset; + int __pyx_v_hasfields; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + char *__pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__getbuffer__", 0); + if (__pyx_v_info != NULL) { + __pyx_v_info->obj = Py_None; __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(__pyx_v_info->obj); + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 + * # of flags + * + * if info == NULL: return # <<<<<<<<<<<<<< + * + * cdef int copy_shape, i, ndim + */ + __pyx_t_1 = ((__pyx_v_info == NULL) != 0); + if (__pyx_t_1) { + __pyx_r = 0; + goto __pyx_L0; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 + * + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + */ + __pyx_v_endian_detector = 1; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 + * cdef int copy_shape, i, ndim + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * + * ndim = PyArray_NDIM(self) + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * + * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 + * ndim = PyArray_NDIM(self) + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * copy_shape = 1 + * else: + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 + * + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * copy_shape = 1 # <<<<<<<<<<<<<< + * else: + * copy_shape = 0 + */ + __pyx_v_copy_shape = 1; + goto __pyx_L4; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 + * copy_shape = 1 + * else: + * copy_shape = 0 # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + */ + __pyx_v_copy_shape = 0; + } + __pyx_L4:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 + * copy_shape = 0 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L6_bool_binop_done; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 + * + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not C contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_C_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L6_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__109, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 + * raise ValueError(u"ndarray is not C contiguous") + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") + */ + __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L9_bool_binop_done; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< + * raise ValueError(u"ndarray is not Fortran contiguous") + * + */ + __pyx_t_2 = ((!(PyArray_CHKFLAGS(__pyx_v_self, NPY_F_CONTIGUOUS) != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L9_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__110, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 + * raise ValueError(u"ndarray is not Fortran contiguous") + * + * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< + * info.ndim = ndim + * if copy_shape: + */ + __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 + * + * info.buf = PyArray_DATA(self) + * info.ndim = ndim # <<<<<<<<<<<<<< + * if copy_shape: + * # Allocate new buffer for strides and shape info. + */ + __pyx_v_info->ndim = __pyx_v_ndim; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 + * info.buf = PyArray_DATA(self) + * info.ndim = ndim + * if copy_shape: # <<<<<<<<<<<<<< + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + */ + __pyx_t_1 = (__pyx_v_copy_shape != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 + * # Allocate new buffer for strides and shape info. + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< + * info.shape = info.strides + ndim + * for i in range(ndim): + */ + __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 + * # This is allocated as one block, strides first. + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim # <<<<<<<<<<<<<< + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + */ + __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 + * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) + * info.shape = info.strides + ndim + * for i in range(ndim): # <<<<<<<<<<<<<< + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] + */ + __pyx_t_4 = __pyx_v_ndim; + for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { + __pyx_v_i = __pyx_t_5; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 + * info.shape = info.strides + ndim + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + */ + (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 + * for i in range(ndim): + * info.strides[i] = PyArray_STRIDES(self)[i] + * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< + * else: + * info.strides = PyArray_STRIDES(self) + */ + (__pyx_v_info->shape[__pyx_v_i]) = (PyArray_DIMS(__pyx_v_self)[__pyx_v_i]); + } + goto __pyx_L11; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 + * info.shape[i] = PyArray_DIMS(self)[i] + * else: + * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + */ + __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 + * else: + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + */ + __pyx_v_info->shape = ((Py_ssize_t *)PyArray_DIMS(__pyx_v_self)); + } + __pyx_L11:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 + * info.strides = PyArray_STRIDES(self) + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL # <<<<<<<<<<<<<< + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) + */ + __pyx_v_info->suboffsets = NULL; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 + * info.shape = PyArray_DIMS(self) + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< + * info.readonly = not PyArray_ISWRITEABLE(self) + * + */ + __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 + * info.suboffsets = NULL + * info.itemsize = PyArray_ITEMSIZE(self) + * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< + * + * cdef int t + */ + __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 + * + * cdef int t + * cdef char* f = NULL # <<<<<<<<<<<<<< + * cdef dtype descr = self.descr + * cdef list stack + */ + __pyx_v_f = NULL; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 + * cdef int t + * cdef char* f = NULL + * cdef dtype descr = self.descr # <<<<<<<<<<<<<< + * cdef list stack + * cdef int offset + */ + __pyx_t_3 = ((PyObject *)__pyx_v_self->descr); + __Pyx_INCREF(__pyx_t_3); + __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":247 + * cdef int offset + * + * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< + * + * if not hasfields and not copy_shape: + */ + __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":249 + * cdef bint hasfields = PyDataType_HASFIELDS(descr) + * + * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< + * # do not call releasebuffer + * info.obj = None + */ + __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L15_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L15_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":251 + * if not hasfields and not copy_shape: + * # do not call releasebuffer + * info.obj = None # <<<<<<<<<<<<<< + * else: + * # need to call releasebuffer + */ + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = Py_None; + goto __pyx_L14; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":254 + * else: + * # need to call releasebuffer + * info.obj = self # <<<<<<<<<<<<<< + * + * if not hasfields: + */ + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); + __pyx_v_info->obj = ((PyObject *)__pyx_v_self); + } + __pyx_L14:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 + * info.obj = self + * + * if not hasfields: # <<<<<<<<<<<<<< + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + */ + __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 + * + * if not hasfields: + * t = descr.type_num # <<<<<<<<<<<<<< + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + */ + __pyx_t_4 = __pyx_v_descr->type_num; + __pyx_v_t = __pyx_t_4; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + * if not hasfields: + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '>') != 0); + if (!__pyx_t_2) { + goto __pyx_L20_next_or; + } else { + } + __pyx_t_2 = (__pyx_v_little_endian != 0); + if (!__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_L20_next_or:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 + * t = descr.type_num + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + */ + __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); + if (__pyx_t_2) { + } else { + __pyx_t_1 = __pyx_t_2; + goto __pyx_L19_bool_binop_done; + } + __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_1 = __pyx_t_2; + __pyx_L19_bool_binop_done:; + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__111, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + switch (__pyx_v_t) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + */ + case NPY_BYTE: + __pyx_v_f = __pyx_k_b; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 + * raise ValueError(u"Non-native byte order not supported") + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + */ + case NPY_UBYTE: + __pyx_v_f = __pyx_k_B; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + */ + case NPY_SHORT: + __pyx_v_f = __pyx_k_h; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 + * elif t == NPY_UBYTE: f = "B" + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + */ + case NPY_USHORT: + __pyx_v_f = __pyx_k_H; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + * elif t == NPY_SHORT: f = "h" + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + */ + case NPY_INT: + __pyx_v_f = __pyx_k_i; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + * elif t == NPY_USHORT: f = "H" + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + */ + case NPY_UINT: + __pyx_v_f = __pyx_k_I; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 + * elif t == NPY_INT: f = "i" + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + */ + case NPY_LONG: + __pyx_v_f = __pyx_k_l; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + * elif t == NPY_UINT: f = "I" + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + */ + case NPY_ULONG: + __pyx_v_f = __pyx_k_L; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 + * elif t == NPY_LONG: f = "l" + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + */ + case NPY_LONGLONG: + __pyx_v_f = __pyx_k_q; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + * elif t == NPY_ULONG: f = "L" + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + */ + case NPY_ULONGLONG: + __pyx_v_f = __pyx_k_Q; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + * elif t == NPY_LONGLONG: f = "q" + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + */ + case NPY_FLOAT: + __pyx_v_f = __pyx_k_f; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + * elif t == NPY_ULONGLONG: f = "Q" + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + */ + case NPY_DOUBLE: + __pyx_v_f = __pyx_k_d; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 + * elif t == NPY_FLOAT: f = "f" + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + */ + case NPY_LONGDOUBLE: + __pyx_v_f = __pyx_k_g; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + * elif t == NPY_DOUBLE: f = "d" + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + */ + case NPY_CFLOAT: + __pyx_v_f = __pyx_k_Zf; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + * elif t == NPY_LONGDOUBLE: f = "g" + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" + */ + case NPY_CDOUBLE: + __pyx_v_f = __pyx_k_Zd; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + * elif t == NPY_CFLOAT: f = "Zf" + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f = "O" + * else: + */ + case NPY_CLONGDOUBLE: + __pyx_v_f = __pyx_k_Zg; + break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 + * elif t == NPY_CDOUBLE: f = "Zd" + * elif t == NPY_CLONGDOUBLE: f = "Zg" + * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + case NPY_OBJECT: + __pyx_v_f = __pyx_k_O; + break; + default: + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + * elif t == NPY_OBJECT: f = "O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * info.format = f + * return + */ + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_Raise(__pyx_t_6, 0, 0, 0); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + break; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f # <<<<<<<<<<<<<< + * return + * else: + */ + __pyx_v_info->format = __pyx_v_f; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":281 + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * info.format = f + * return # <<<<<<<<<<<<<< + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + */ + __pyx_r = 0; + goto __pyx_L0; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + * return + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + */ + __pyx_v_info->format = ((char *)malloc(255)); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + * else: + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, + */ + (__pyx_v_info->format[0]) = '^'; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + * info.format = stdlib.malloc(_buffer_format_string_len) + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 # <<<<<<<<<<<<<< + * f = _util_dtypestring(descr, info.format + 1, + * info.format + _buffer_format_string_len, + */ + __pyx_v_offset = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 + * info.format[0] = c'^' # Native data types, manual alignment + * offset = 0 + * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< + * info.format + _buffer_format_string_len, + * &offset) + */ + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_7; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 + * info.format + _buffer_format_string_len, + * &offset) + * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + */ + (__pyx_v_f[0]) = '\x00'; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 + * # experimental exception made for __getbuffer__ and __releasebuffer__ + * # -- the details of this may change. + * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< + * # This implementation of getbuffer is geared towards Cython + * # requirements, and does not yet fullfill the PEP. + */ + + /* function exit code */ + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("numpy.ndarray.__getbuffer__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + if (__pyx_v_info != NULL && __pyx_v_info->obj != NULL) { + __Pyx_GOTREF(__pyx_v_info->obj); + __Pyx_DECREF(__pyx_v_info->obj); __pyx_v_info->obj = NULL; + } + goto __pyx_L2; + __pyx_L0:; + if (__pyx_v_info != NULL && __pyx_v_info->obj == Py_None) { + __Pyx_GOTREF(Py_None); + __Pyx_DECREF(Py_None); __pyx_v_info->obj = NULL; + } + __pyx_L2:; + __Pyx_XDECREF((PyObject *)__pyx_v_descr); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + +/* Python wrapper */ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info); /*proto*/ +static CYTHON_UNUSED void __pyx_pw_5numpy_7ndarray_3__releasebuffer__(PyObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__releasebuffer__ (wrapper)", 0); + __pyx_pf_5numpy_7ndarray_2__releasebuffer__(((PyArrayObject *)__pyx_v_self), ((Py_buffer *)__pyx_v_info)); + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info) { + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("__releasebuffer__", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + * + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + */ + __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + * def __releasebuffer__(ndarray self, Py_buffer* info): + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) # <<<<<<<<<<<<<< + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) + */ + free(__pyx_v_info->format); + goto __pyx_L3; + } + __pyx_L3:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< + * stdlib.free(info.strides) + * # info.shape was stored after info.strides in the same block + */ + __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":295 + * stdlib.free(info.format) + * if sizeof(npy_intp) != sizeof(Py_ssize_t): + * stdlib.free(info.strides) # <<<<<<<<<<<<<< + * # info.shape was stored after info.strides in the same block + * + */ + free(__pyx_v_info->strides); + goto __pyx_L4; + } + __pyx_L4:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + * f[0] = c'\0' # Terminate format string + * + * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< + * if PyArray_HASFIELDS(self): + * stdlib.free(info.format) + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__pyx_v_a) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":772 + * + * cdef inline object PyArray_MultiIterNew1(a): + * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew2(a, b): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 + * ctypedef npy_cdouble complex_t + * + * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(1, a) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__pyx_v_a, PyObject *__pyx_v_b) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 + * + * cdef inline object PyArray_MultiIterNew2(a, b): + * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 + * return PyArray_MultiIterNew(1, a) + * + * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(2, a, b) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew2", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): + * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 + * return PyArray_MultiIterNew(2, a, b) + * + * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(3, a, b, c) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew3", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): + * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 + * return PyArray_MultiIterNew(3, a, b, c) + * + * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(4, a, b, c, d) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew4", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_c, PyObject *__pyx_v_d, PyObject *__pyx_v_e) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): + * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 + * return PyArray_MultiIterNew(4, a, b, c, d) + * + * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("numpy.PyArray_MultiIterNew5", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + +static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx_v_descr, char *__pyx_v_f, char *__pyx_v_end, int *__pyx_v_offset) { + PyArray_Descr *__pyx_v_child = 0; + int __pyx_v_endian_detector; + int __pyx_v_little_endian; + PyObject *__pyx_v_fields = 0; + PyObject *__pyx_v_childname = NULL; + PyObject *__pyx_v_new_offset = NULL; + PyObject *__pyx_v_t = NULL; + char *__pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + long __pyx_t_8; + char *__pyx_t_9; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("_util_dtypestring", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":793 + * cdef int delta_offset + * cdef tuple i + * cdef int endian_detector = 1 # <<<<<<<<<<<<<< + * cdef bint little_endian = ((&endian_detector)[0] != 0) + * cdef tuple fields + */ + __pyx_v_endian_detector = 1; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 + * cdef tuple i + * cdef int endian_detector = 1 + * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< + * cdef tuple fields + * + */ + __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":797 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + if (unlikely(__pyx_v_descr->names == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + for (;;) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); + __pyx_t_3 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 + * + * for childname in descr.names: + * fields = descr.fields[childname] # <<<<<<<<<<<<<< + * child, new_offset = fields + * + */ + if (unlikely(__pyx_v_descr->fields == Py_None)) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); + __pyx_t_3 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 + * for childname in descr.names: + * fields = descr.fields[childname] + * child, new_offset = fields # <<<<<<<<<<<<<< + * + * if (end - f) - (new_offset - offset[0]) < 15: + */ + if (likely(__pyx_v_fields != Py_None)) { + PyObject* sequence = __pyx_v_fields; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_4); + #else + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + #endif + } else { + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); + __pyx_t_3 = 0; + __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + * child, new_offset = fields + * + * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + */ + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); + if (__pyx_t_6) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__112, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") + * + * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '>') != 0); + if (!__pyx_t_7) { + goto __pyx_L8_next_or; + } else { + } + __pyx_t_7 = (__pyx_v_little_endian != 0); + if (!__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_L8_next_or:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 + * + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< + * raise ValueError(u"Non-native byte order not supported") + * # One could encode it in the format string and have Cython + */ + __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); + if (__pyx_t_7) { + } else { + __pyx_t_6 = __pyx_t_7; + goto __pyx_L7_bool_binop_done; + } + __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); + __pyx_t_6 = __pyx_t_7; + __pyx_L7_bool_binop_done:; + if (__pyx_t_6) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 + * + * # Output padding bytes + * while offset[0] < new_offset: # <<<<<<<<<<<<<< + * f[0] = 120 # "x"; pad byte + * f += 1 + */ + while (1) { + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (!__pyx_t_6) break; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 + * # Output padding bytes + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< + * f += 1 + * offset[0] += 1 + */ + (__pyx_v_f[0]) = 120; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 + * while offset[0] < new_offset: + * f[0] = 120 # "x"; pad byte + * f += 1 # <<<<<<<<<<<<<< + * offset[0] += 1 + * + */ + __pyx_v_f = (__pyx_v_f + 1); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 + * f[0] = 120 # "x"; pad byte + * f += 1 + * offset[0] += 1 # <<<<<<<<<<<<<< + * + * offset[0] += child.itemsize + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + * offset[0] += 1 + * + * offset[0] += child.itemsize # <<<<<<<<<<<<<< + * + * if not PyDataType_HASFIELDS(child): + */ + __pyx_t_8 = 0; + (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 + * offset[0] += child.itemsize + * + * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< + * t = child.type_num + * if end - f < 5: + */ + __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); + if (__pyx_t_6) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + * + * if not PyDataType_HASFIELDS(child): + * t = child.type_num # <<<<<<<<<<<<<< + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") + */ + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); + __pyx_t_4 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 + * if not PyDataType_HASFIELDS(child): + * t = child.type_num + * if end - f < 5: # <<<<<<<<<<<<<< + * raise RuntimeError(u"Format string allocated too short.") + * + */ + __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); + if (__pyx_t_6) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__114, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 + * + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + */ + __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 98; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + * # Until ticket #99 is fixed, use integers to avoid warnings + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + */ + __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 66; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + * if t == NPY_BYTE: f[0] = 98 #"b" + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + */ + __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 104; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 + * elif t == NPY_UBYTE: f[0] = 66 #"B" + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + */ + __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 72; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + * elif t == NPY_SHORT: f[0] = 104 #"h" + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + */ + __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 105; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + * elif t == NPY_USHORT: f[0] = 72 #"H" + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + */ + __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 73; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 + * elif t == NPY_INT: f[0] = 105 #"i" + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + */ + __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 108; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + * elif t == NPY_UINT: f[0] = 73 #"I" + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + */ + __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 76; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + * elif t == NPY_LONG: f[0] = 108 #"l" + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + */ + __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 113; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + * elif t == NPY_ULONG: f[0] = 76 #"L" + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + */ + __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 81; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 + * elif t == NPY_LONGLONG: f[0] = 113 #"q" + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + */ + __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 102; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + */ + __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 100; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 + * elif t == NPY_FLOAT: f[0] = 102 #"f" + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + */ + __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 103; + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + * elif t == NPY_DOUBLE: f[0] = 100 #"d" + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + */ + __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 102; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":843 + * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" + */ + __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 100; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 + * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + */ + __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 90; + (__pyx_v_f[1]) = 103; + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L15; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 + * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd + * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg + * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + */ + __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_6) { + (__pyx_v_f[0]) = 79; + goto __pyx_L15; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 + * elif t == NPY_OBJECT: f[0] = 79 #"O" + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< + * f += 1 + * else: + */ + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L15:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 + * else: + * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) + * f += 1 # <<<<<<<<<<<<<< + * else: + * # Cython ignores struct boundary information ("T{...}"), + */ + __pyx_v_f = (__pyx_v_f + 1); + goto __pyx_L13; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 + * # Cython ignores struct boundary information ("T{...}"), + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< + * return f + * + */ + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f = __pyx_t_9; + } + __pyx_L13:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":797 + * cdef tuple fields + * + * for childname in descr.names: # <<<<<<<<<<<<<< + * fields = descr.fields[childname] + * child, new_offset = fields + */ + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 + * # so don't output it + * f = _util_dtypestring(child, f, end, offset) + * return f # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_f; + goto __pyx_L0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 + * return PyArray_MultiIterNew(5, a, b, c, d, e) + * + * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< + * # Recursive utility function used in __getbuffer__ to get format + * # string. The new location in the format string is returned. + */ + + /* function exit code */ + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("numpy._util_dtypestring", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_child); + __Pyx_XDECREF(__pyx_v_fields); + __Pyx_XDECREF(__pyx_v_childname); + __Pyx_XDECREF(__pyx_v_new_offset); + __Pyx_XDECREF(__pyx_v_t); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + +static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_arr, PyObject *__pyx_v_base) { + PyObject *__pyx_v_baseptr; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("set_array_base", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 + * cdef inline void set_array_base(ndarray arr, object base): + * cdef PyObject* baseptr + * if base is None: # <<<<<<<<<<<<<< + * baseptr = NULL + * else: + */ + __pyx_t_1 = (__pyx_v_base == Py_None); + __pyx_t_2 = (__pyx_t_1 != 0); + if (__pyx_t_2) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 + * cdef PyObject* baseptr + * if base is None: + * baseptr = NULL # <<<<<<<<<<<<<< + * else: + * Py_INCREF(base) # important to do this before decref below! + */ + __pyx_v_baseptr = NULL; + goto __pyx_L3; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 + * baseptr = NULL + * else: + * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< + * baseptr = base + * Py_XDECREF(arr.base) + */ + Py_INCREF(__pyx_v_base); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":975 + * else: + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base # <<<<<<<<<<<<<< + * Py_XDECREF(arr.base) + * arr.base = baseptr + */ + __pyx_v_baseptr = ((PyObject *)__pyx_v_base); + } + __pyx_L3:; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 + * Py_INCREF(base) # important to do this before decref below! + * baseptr = base + * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< + * arr.base = baseptr + * + */ + Py_XDECREF(__pyx_v_arr->base); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 + * baseptr = base + * Py_XDECREF(arr.base) + * arr.base = baseptr # <<<<<<<<<<<<<< + * + * cdef inline object get_array_base(ndarray arr): + */ + __pyx_v_arr->base = __pyx_v_baseptr; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 + * + * + * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< + * cdef PyObject* baseptr + * if base is None: + */ + + /* function exit code */ + __Pyx_RefNannyFinishContext(); +} + +/* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + +static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__pyx_v_arr) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + __Pyx_RefNannySetupContext("get_array_base", 0); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 + * + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: # <<<<<<<<<<<<<< + * return None + * else: + */ + __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); + if (__pyx_t_1) { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":981 + * cdef inline object get_array_base(ndarray arr): + * if arr.base is NULL: + * return None # <<<<<<<<<<<<<< + * else: + * return arr.base + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + } + /*else*/ { + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":983 + * return None + * else: + * return arr.base # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_arr->base)); + __pyx_r = ((PyObject *)__pyx_v_arr->base); + goto __pyx_L0; + } + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /* function exit code */ + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *)o); + p->__pyx_vtab = __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython[] = { + {"f_a", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_1f_a, METH_VARARGS|METH_KEYWORDS, 0}, + {"Ak", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_3Ak, METH_VARARGS|METH_KEYWORDS, 0}, + {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_5Qk, METH_O, 0}, + {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_7Q_srk, METH_O, 0}, + {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_9dAk, METH_O, 0}, + {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_11dQk, METH_O, 0}, + {"reset", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_13reset, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.Dynamic_Callables_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *p; + PyObject *o; + if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { + o = (*t->tp_alloc)(t, 0); + } else { + o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); + } + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *)o); + p->__pyx_vtab = __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(PyObject *o) { + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Measurement_Callables_Cython[] = { + {"f_h", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_1f_h, METH_VARARGS|METH_KEYWORDS, 0}, + {"Hk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_3Hk, METH_VARARGS|METH_KEYWORDS, 0}, + {"Rk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_5Rk, METH_O, 0}, + {"R_isrk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_7R_isrk, METH_O, 0}, + {"dHk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_9dHk, METH_O, 0}, + {"dRk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_11dRk, METH_O, 0}, + {"reset", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_13reset, METH_VARARGS|METH_KEYWORDS, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.Measurement_Callables_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_R_handling_Cython __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p; + PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython; + p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->R_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o) { + struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->R); + Py_CLEAR(p->index); + Py_CLEAR(p->dR); + Py_CLEAR(p->R_square_root); + #if CYTHON_COMPILING_IN_CPYTHON + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Measurement_Callables_Cython(o); +} + +static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o; + e = ((likely(__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython)) ? ((__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_traverse) ? __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython)); if (e) return e; + if (p->R) { + e = (*v)(((PyObject*)p->R), a); if (e) return e; + } + if (p->index) { + e = (*v)(((PyObject*)p->index), a); if (e) return e; + } + if (p->dR) { + e = (*v)(((PyObject*)p->dR), a); if (e) return e; + } + if (p->R_square_root) { + e = (*v)(p->R_square_root, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython *)o; + if (likely(__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython)) { if (__pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_clear) __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython); + tmp = ((PyObject*)p->R); + p->R = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->index); + p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dR); + p->dR = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->R_square_root); + p->R_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_R_handling_Cython[] = { + {"Rk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_3Rk, METH_O, 0}, + {"dRk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_5dRk, METH_O, 0}, + {"R_isrk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_7R_isrk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython_6R_isrk}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.R_handling_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_R_handling_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "\n The calss handles noise matrix R.\n ", /*tp_doc*/ + __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_traverse*/ + __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_3GPy_6models_18state_space_cython_17R_handling_Cython_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p; + PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_R_handling_Cython(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Measurement_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; + p->H = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dH = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->H); + Py_CLEAR(p->dH); + PyObject_GC_Track(o); + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_R_handling_Cython(o); +} + +static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o; + e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_R_handling_Cython(o, v, a); if (e) return e; + if (p->H) { + e = (*v)(((PyObject*)p->H), a); if (e) return e; + } + if (p->dH) { + e = (*v)(((PyObject*)p->dH), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython *)o; + __pyx_tp_clear_3GPy_6models_18state_space_cython_R_handling_Cython(o); + tmp = ((PyObject*)p->H); + p->H = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dH); + p->dH = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython[] = { + {"f_h", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_3f_h, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_2f_h}, + {"Hk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_5Hk, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_4Hk}, + {"dHk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_7dHk, METH_O, 0}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.Std_Measurement_Callables_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_traverse*/ + __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Q_handling_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p; + PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython; + p->Q = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dQ = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->Q_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->Q); + Py_CLEAR(p->index); + Py_CLEAR(p->dQ); + Py_CLEAR(p->Q_square_root); + #if CYTHON_COMPILING_IN_CPYTHON + if (PyType_IS_GC(Py_TYPE(o)->tp_base)) + #endif + PyObject_GC_Track(o); + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython(o); +} + +static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o; + e = ((likely(__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython)) ? ((__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_traverse) ? __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython)); if (e) return e; + if (p->Q) { + e = (*v)(((PyObject*)p->Q), a); if (e) return e; + } + if (p->index) { + e = (*v)(((PyObject*)p->index), a); if (e) return e; + } + if (p->dQ) { + e = (*v)(((PyObject*)p->dQ), a); if (e) return e; + } + if (p->Q_square_root) { + e = (*v)(p->Q_square_root, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython *)o; + if (likely(__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython)) { if (__pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_clear) __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython); + tmp = ((PyObject*)p->Q); + p->Q = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->index); + p->index = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dQ); + p->dQ = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->Q_square_root); + p->Q_square_root = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Q_handling_Cython[] = { + {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_3Qk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_2Qk}, + {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_5dQk, METH_O, 0}, + {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_7Q_srk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython_6Q_srk}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.Q_handling_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Q_handling_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_traverse*/ + __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_3GPy_6models_18state_space_cython_17Q_handling_Cython_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p; + PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; + p->A = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dA = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o) { + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->A); + Py_CLEAR(p->dA); + PyObject_GC_Track(o); + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(o); +} + +static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o; + e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(o, v, a); if (e) return e; + if (p->A) { + e = (*v)(((PyObject*)p->A), a); if (e) return e; + } + if (p->dA) { + e = (*v)(((PyObject*)p->dA), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython *)o; + __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(o); + tmp = ((PyObject*)p->A); + p->A = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dA); + p->dA = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython[] = { + {"f_a", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_3f_a, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_2f_a}, + {"Ak", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_5Ak, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_4Ak}, + {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_7dAk, METH_O, 0}, + {"reset", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_9reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_8reset}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.Std_Dynamic_Callables_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_traverse*/ + __pyx_tp_clear_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; +static struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_AQcompute_batch_Cython __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + +static PyObject *__pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p; + PyObject *o = __pyx_tp_new_3GPy_6models_18state_space_cython_Q_handling_Cython(t, a, k); + if (unlikely(!o)) return 0; + p = ((struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o); + p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython*)__pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + p->As = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->Qs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dAs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->dQs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->reconstruct_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + p->Q_svd_dict = ((PyObject*)Py_None); Py_INCREF(Py_None); + return o; +} + +static void __pyx_tp_dealloc_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o) { + struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o; + #if PY_VERSION_HEX >= 0x030400a1 + if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { + if (PyObject_CallFinalizerFromDealloc(o)) return; + } + #endif + PyObject_GC_UnTrack(o); + Py_CLEAR(p->As); + Py_CLEAR(p->Qs); + Py_CLEAR(p->dAs); + Py_CLEAR(p->dQs); + Py_CLEAR(p->reconstruct_indices); + Py_CLEAR(p->Q_svd_dict); + PyObject_GC_Track(o); + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_Q_handling_Cython(o); +} + +static int __pyx_tp_traverse_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o; + e = __pyx_tp_traverse_3GPy_6models_18state_space_cython_Q_handling_Cython(o, v, a); if (e) return e; + if (p->As) { + e = (*v)(((PyObject*)p->As), a); if (e) return e; + } + if (p->Qs) { + e = (*v)(((PyObject*)p->Qs), a); if (e) return e; + } + if (p->dAs) { + e = (*v)(((PyObject*)p->dAs), a); if (e) return e; + } + if (p->dQs) { + e = (*v)(((PyObject*)p->dQs), a); if (e) return e; + } + if (p->reconstruct_indices) { + e = (*v)(((PyObject*)p->reconstruct_indices), a); if (e) return e; + } + if (p->Q_svd_dict) { + e = (*v)(p->Q_svd_dict, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3GPy_6models_18state_space_cython_AQcompute_batch_Cython(PyObject *o) { + PyObject* tmp; + struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *p = (struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython *)o; + __pyx_tp_clear_3GPy_6models_18state_space_cython_Q_handling_Cython(o); + tmp = ((PyObject*)p->As); + p->As = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->Qs); + p->Qs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dAs); + p->dAs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->dQs); + p->dQs = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->reconstruct_indices); + p->reconstruct_indices = ((PyArrayObject *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->Q_svd_dict); + p->Q_svd_dict = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3GPy_6models_18state_space_cython_AQcompute_batch_Cython[] = { + {"f_a", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_3f_a, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_2f_a}, + {"reset", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_5reset, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_4reset}, + {"Ak", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_7Ak, METH_VARARGS|METH_KEYWORDS, 0}, + {"Qk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_9Qk, METH_O, 0}, + {"dAk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_11dAk, METH_O, 0}, + {"dQk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_13dQk, METH_O, 0}, + {"Q_srk", (PyCFunction)__pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_15Q_srk, METH_O, __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_14Q_srk}, + {0, 0, 0, 0} +}; + +static PyTypeObject __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = { + PyVarObject_HEAD_INIT(0, 0) + "GPy.models.state_space_cython.AQcompute_batch_Cython", /*tp_name*/ + sizeof(struct __pyx_obj_3GPy_6models_18state_space_cython_AQcompute_batch_Cython), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + "\n Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter\n from the matrices F, L, Qc, P_ing, dF, dQc, dP_inf of the continuos state\n equation. dt - time steps. \n \n It has the same interface as AQcompute_once.\n \n It computes matrices for all time steps. This object is used when\n there are not so many (controlled by internal variable) \n different time steps and storing all the matrices do not take too much memory.\n \n Since all the matrices are computed all together, this object can be used\n in smoother without repeating the computations. \n ", /*tp_doc*/ + __pyx_tp_traverse_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_traverse*/ + __pyx_tp_clear_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + __pyx_pw_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_1__init__, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + 0, /*tp_version_tag*/ + #if PY_VERSION_HEX >= 0x030400a1 + 0, /*tp_finalize*/ + #endif +}; + +static PyMethodDef __pyx_methods[] = { + {0, 0, 0, 0} +}; + +#if PY_MAJOR_VERSION >= 3 +static struct PyModuleDef __pyx_moduledef = { + #if PY_VERSION_HEX < 0x03020000 + { PyObject_HEAD_INIT(NULL) NULL, 0, NULL }, + #else + PyModuleDef_HEAD_INIT, + #endif + "state_space_cython", + __pyx_k_Contains_some_cython_code_for_s, /* m_doc */ + -1, /* m_size */ + __pyx_methods /* m_methods */, + NULL, /* m_reload */ + NULL, /* m_traverse */ + NULL, /* m_clear */ + NULL /* m_free */ +}; +#endif + +static __Pyx_StringTabEntry __pyx_string_tab[] = { + {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1}, + {&__pyx_n_s_A_time_var_index, __pyx_k_A_time_var_index, sizeof(__pyx_k_A_time_var_index), 0, 0, 1, 1}, + {&__pyx_n_s_Ak, __pyx_k_Ak, sizeof(__pyx_k_Ak), 0, 0, 1, 1}, + {&__pyx_n_s_As, __pyx_k_As, sizeof(__pyx_k_As), 0, 0, 1, 1}, + {&__pyx_n_s_DTYPE, __pyx_k_DTYPE, sizeof(__pyx_k_DTYPE), 0, 0, 1, 1}, + {&__pyx_n_s_DTYPE_int, __pyx_k_DTYPE_int, sizeof(__pyx_k_DTYPE_int), 0, 0, 1, 1}, + {&__pyx_kp_u_Format_string_allocated_too_shor, __pyx_k_Format_string_allocated_too_shor, sizeof(__pyx_k_Format_string_allocated_too_shor), 0, 1, 0, 0}, + {&__pyx_kp_u_Format_string_allocated_too_shor_2, __pyx_k_Format_string_allocated_too_shor_2, sizeof(__pyx_k_Format_string_allocated_too_shor_2), 0, 1, 0, 0}, + {&__pyx_n_s_GPy_models_state_space_cython, __pyx_k_GPy_models_state_space_cython, sizeof(__pyx_k_GPy_models_state_space_cython), 0, 0, 1, 1}, + {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1}, + {&__pyx_n_s_H_time_var_index, __pyx_k_H_time_var_index, sizeof(__pyx_k_H_time_var_index), 0, 0, 1, 1}, + {&__pyx_n_s_Hk, __pyx_k_Hk, sizeof(__pyx_k_Hk), 0, 0, 1, 1}, + {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1}, + {&__pyx_kp_s_Kalman_Filter_Update_SVD_S_is_ne, __pyx_k_Kalman_Filter_Update_SVD_S_is_ne, sizeof(__pyx_k_Kalman_Filter_Update_SVD_S_is_ne), 0, 0, 1, 0}, + {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1}, + {&__pyx_kp_s_Measurement_dimension_larger_the, __pyx_k_Measurement_dimension_larger_the, sizeof(__pyx_k_Measurement_dimension_larger_the), 0, 0, 1, 0}, + {&__pyx_kp_s_Nan_measurements_are_currently_n, __pyx_k_Nan_measurements_are_currently_n, sizeof(__pyx_k_Nan_measurements_are_currently_n), 0, 0, 1, 0}, + {&__pyx_kp_s_Nan_values_in_likelihood_update, __pyx_k_Nan_values_in_likelihood_update, sizeof(__pyx_k_Nan_values_in_likelihood_update), 0, 0, 1, 0}, + {&__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_NotImplemented, __pyx_k_NotImplemented, sizeof(__pyx_k_NotImplemented), 0, 0, 1, 1}, + {&__pyx_n_s_P, __pyx_k_P, sizeof(__pyx_k_P), 0, 0, 1, 1}, + {&__pyx_n_s_P_init, __pyx_k_P_init, sizeof(__pyx_k_P_init), 0, 0, 1, 1}, + {&__pyx_n_s_P_pred, __pyx_k_P_pred, sizeof(__pyx_k_P_pred), 0, 0, 1, 1}, + {&__pyx_n_s_P_upd, __pyx_k_P_upd, sizeof(__pyx_k_P_upd), 0, 0, 1, 1}, + {&__pyx_n_s_Prev_cov, __pyx_k_Prev_cov, sizeof(__pyx_k_Prev_cov), 0, 0, 1, 1}, + {&__pyx_n_s_Q, __pyx_k_Q, sizeof(__pyx_k_Q), 0, 0, 1, 1}, + {&__pyx_n_s_Q_sr, __pyx_k_Q_sr, sizeof(__pyx_k_Q_sr), 0, 0, 1, 1}, + {&__pyx_n_s_Q_srk, __pyx_k_Q_srk, sizeof(__pyx_k_Q_srk), 0, 0, 1, 1}, + {&__pyx_n_s_Q_time_var_index, __pyx_k_Q_time_var_index, sizeof(__pyx_k_Q_time_var_index), 0, 0, 1, 1}, + {&__pyx_n_s_Qk, __pyx_k_Qk, sizeof(__pyx_k_Qk), 0, 0, 1, 1}, + {&__pyx_n_s_Qs, __pyx_k_Qs, sizeof(__pyx_k_Qs), 0, 0, 1, 1}, + {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1}, + {&__pyx_n_s_R_isr, __pyx_k_R_isr, sizeof(__pyx_k_R_isr), 0, 0, 1, 1}, + {&__pyx_n_s_R_isrk, __pyx_k_R_isrk, sizeof(__pyx_k_R_isrk), 0, 0, 1, 1}, + {&__pyx_n_s_R_time_var_index, __pyx_k_R_time_var_index, sizeof(__pyx_k_R_time_var_index), 0, 0, 1, 1}, + {&__pyx_n_s_Rk, __pyx_k_Rk, sizeof(__pyx_k_Rk), 0, 0, 1, 1}, + {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, + {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1}, + {&__pyx_n_s_S_new, __pyx_k_S_new, sizeof(__pyx_k_S_new), 0, 0, 1, 1}, + {&__pyx_n_s_S_old, __pyx_k_S_old, sizeof(__pyx_k_S_old), 0, 0, 1, 1}, + {&__pyx_n_s_S_pred, __pyx_k_S_pred, sizeof(__pyx_k_S_pred), 0, 0, 1, 1}, + {&__pyx_n_s_S_svd, __pyx_k_S_svd, sizeof(__pyx_k_S_svd), 0, 0, 1, 1}, + {&__pyx_n_s_S_upd, __pyx_k_S_upd, sizeof(__pyx_k_S_upd), 0, 0, 1, 1}, + {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1}, + {&__pyx_n_s_U, __pyx_k_U, sizeof(__pyx_k_U), 0, 0, 1, 1}, + {&__pyx_n_s_U_upd, __pyx_k_U_upd, sizeof(__pyx_k_U_upd), 0, 0, 1, 1}, + {&__pyx_n_s_V_new, __pyx_k_V_new, sizeof(__pyx_k_V_new), 0, 0, 1, 1}, + {&__pyx_n_s_V_old, __pyx_k_V_old, sizeof(__pyx_k_V_old), 0, 0, 1, 1}, + {&__pyx_n_s_V_pred, __pyx_k_V_pred, sizeof(__pyx_k_V_pred), 0, 0, 1, 1}, + {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, + {&__pyx_n_s_Vh, __pyx_k_Vh, sizeof(__pyx_k_Vh), 0, 0, 1, 1}, + {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1}, + {&__pyx_n_s_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 1, 1}, + {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1}, + {&__pyx_n_s_any, __pyx_k_any, sizeof(__pyx_k_any), 0, 0, 1, 1}, + {&__pyx_n_s_axis, __pyx_k_axis, sizeof(__pyx_k_axis), 0, 0, 1, 1}, + {&__pyx_n_s_calc_grad_log_likelihood, __pyx_k_calc_grad_log_likelihood, sizeof(__pyx_k_calc_grad_log_likelihood), 0, 0, 1, 1}, + {&__pyx_n_s_calc_log_likelihood, __pyx_k_calc_log_likelihood, sizeof(__pyx_k_calc_log_likelihood), 0, 0, 1, 1}, + {&__pyx_n_s_check_finite, __pyx_k_check_finite, sizeof(__pyx_k_check_finite), 0, 0, 1, 1}, + {&__pyx_n_s_compute_derivatives, __pyx_k_compute_derivatives, sizeof(__pyx_k_compute_derivatives), 0, 0, 1, 1}, + {&__pyx_n_s_compute_uv, __pyx_k_compute_uv, sizeof(__pyx_k_compute_uv), 0, 0, 1, 1}, + {&__pyx_n_s_cont_discr_kalman_filter_raw_Cy, __pyx_k_cont_discr_kalman_filter_raw_Cy, sizeof(__pyx_k_cont_discr_kalman_filter_raw_Cy), 0, 0, 1, 1}, + {&__pyx_kp_s_cython_Ak_is_not_implemented, __pyx_k_cython_Ak_is_not_implemented, sizeof(__pyx_k_cython_Ak_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_Hk_is_not_implemented, __pyx_k_cython_Hk_is_not_implemented, sizeof(__pyx_k_cython_Hk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_Q_srk_is_not_implemented, __pyx_k_cython_Q_srk_is_not_implemented, sizeof(__pyx_k_cython_Q_srk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_Qk_is_not_implemented, __pyx_k_cython_Qk_is_not_implemented, sizeof(__pyx_k_cython_Qk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_Rk_is_not_implemented, __pyx_k_cython_Rk_is_not_implemented, sizeof(__pyx_k_cython_Rk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_dAk_is_not_implemented, __pyx_k_cython_dAk_is_not_implemented, sizeof(__pyx_k_cython_dAk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_dQk_is_not_implemented, __pyx_k_cython_dQk_is_not_implemented, sizeof(__pyx_k_cython_dQk_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_f_a_is_not_implemented, __pyx_k_cython_f_a_is_not_implemented, sizeof(__pyx_k_cython_f_a_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_kp_s_cython_reset_is_not_implemented, __pyx_k_cython_reset_is_not_implemented, sizeof(__pyx_k_cython_reset_is_not_implemented), 0, 0, 1, 0}, + {&__pyx_n_s_dA, __pyx_k_dA, sizeof(__pyx_k_dA), 0, 0, 1, 1}, + {&__pyx_n_s_dA_all_params, __pyx_k_dA_all_params, sizeof(__pyx_k_dA_all_params), 0, 0, 1, 1}, + {&__pyx_kp_s_dA_derivative_is_None, __pyx_k_dA_derivative_is_None, sizeof(__pyx_k_dA_derivative_is_None), 0, 0, 1, 0}, + {&__pyx_n_s_dAk, __pyx_k_dAk, sizeof(__pyx_k_dAk), 0, 0, 1, 1}, + {&__pyx_n_s_dAs, __pyx_k_dAs, sizeof(__pyx_k_dAs), 0, 0, 1, 1}, + {&__pyx_n_s_dH, __pyx_k_dH, sizeof(__pyx_k_dH), 0, 0, 1, 1}, + {&__pyx_n_s_dH_all_params, __pyx_k_dH_all_params, sizeof(__pyx_k_dH_all_params), 0, 0, 1, 1}, + {&__pyx_kp_s_dH_derivative_is_None, __pyx_k_dH_derivative_is_None, sizeof(__pyx_k_dH_derivative_is_None), 0, 0, 1, 0}, + {&__pyx_n_s_dHk, __pyx_k_dHk, sizeof(__pyx_k_dHk), 0, 0, 1, 1}, + {&__pyx_n_s_dK, __pyx_k_dK, sizeof(__pyx_k_dK), 0, 0, 1, 1}, + {&__pyx_n_s_dP_init, __pyx_k_dP_init, sizeof(__pyx_k_dP_init), 0, 0, 1, 1}, + {&__pyx_n_s_dP_pred, __pyx_k_dP_pred, sizeof(__pyx_k_dP_pred), 0, 0, 1, 1}, + {&__pyx_n_s_dP_pred_all_params, __pyx_k_dP_pred_all_params, sizeof(__pyx_k_dP_pred_all_params), 0, 0, 1, 1}, + {&__pyx_n_s_dP_upd, __pyx_k_dP_upd, sizeof(__pyx_k_dP_upd), 0, 0, 1, 1}, + {&__pyx_n_s_dQ, __pyx_k_dQ, sizeof(__pyx_k_dQ), 0, 0, 1, 1}, + {&__pyx_n_s_dQ_all_params, __pyx_k_dQ_all_params, sizeof(__pyx_k_dQ_all_params), 0, 0, 1, 1}, + {&__pyx_kp_s_dQ_derivative_is_None, __pyx_k_dQ_derivative_is_None, sizeof(__pyx_k_dQ_derivative_is_None), 0, 0, 1, 0}, + {&__pyx_n_s_dQk, __pyx_k_dQk, sizeof(__pyx_k_dQk), 0, 0, 1, 1}, + {&__pyx_n_s_dQs, __pyx_k_dQs, sizeof(__pyx_k_dQs), 0, 0, 1, 1}, + {&__pyx_n_s_dR, __pyx_k_dR, sizeof(__pyx_k_dR), 0, 0, 1, 1}, + {&__pyx_n_s_dR_all_params, __pyx_k_dR_all_params, sizeof(__pyx_k_dR_all_params), 0, 0, 1, 1}, + {&__pyx_kp_s_dR_derivative_is_None, __pyx_k_dR_derivative_is_None, sizeof(__pyx_k_dR_derivative_is_None), 0, 0, 1, 0}, + {&__pyx_n_s_dRk, __pyx_k_dRk, sizeof(__pyx_k_dRk), 0, 0, 1, 1}, + {&__pyx_n_s_dS, __pyx_k_dS, sizeof(__pyx_k_dS), 0, 0, 1, 1}, + {&__pyx_n_s_d_log_likelihood_update, __pyx_k_d_log_likelihood_update, sizeof(__pyx_k_d_log_likelihood_update), 0, 0, 1, 1}, + {&__pyx_n_s_diag, __pyx_k_diag, sizeof(__pyx_k_diag), 0, 0, 1, 1}, + {&__pyx_n_s_dm_init, __pyx_k_dm_init, sizeof(__pyx_k_dm_init), 0, 0, 1, 1}, + {&__pyx_n_s_dm_pred, __pyx_k_dm_pred, sizeof(__pyx_k_dm_pred), 0, 0, 1, 1}, + {&__pyx_n_s_dm_pred_all_params, __pyx_k_dm_pred_all_params, sizeof(__pyx_k_dm_pred_all_params), 0, 0, 1, 1}, + {&__pyx_n_s_dm_upd, __pyx_k_dm_upd, sizeof(__pyx_k_dm_upd), 0, 0, 1, 1}, + {&__pyx_n_s_dot, __pyx_k_dot, sizeof(__pyx_k_dot), 0, 0, 1, 1}, + {&__pyx_n_s_dtype, __pyx_k_dtype, sizeof(__pyx_k_dtype), 0, 0, 1, 1}, + {&__pyx_n_s_dv, __pyx_k_dv, sizeof(__pyx_k_dv), 0, 0, 1, 1}, + {&__pyx_n_s_empty, __pyx_k_empty, sizeof(__pyx_k_empty), 0, 0, 1, 1}, + {&__pyx_n_s_f_a, __pyx_k_f_a, sizeof(__pyx_k_f_a), 0, 0, 1, 1}, + {&__pyx_n_s_f_h, __pyx_k_f_h, sizeof(__pyx_k_f_h), 0, 0, 1, 1}, + {&__pyx_n_s_float64, __pyx_k_float64, sizeof(__pyx_k_float64), 0, 0, 1, 1}, + {&__pyx_n_s_full_matrices, __pyx_k_full_matrices, sizeof(__pyx_k_full_matrices), 0, 0, 1, 1}, + {&__pyx_n_s_grad_log_likelihood, __pyx_k_grad_log_likelihood, sizeof(__pyx_k_grad_log_likelihood), 0, 0, 1, 1}, + {&__pyx_n_s_grad_params_no, __pyx_k_grad_params_no, sizeof(__pyx_k_grad_params_no), 0, 0, 1, 1}, + {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, + {&__pyx_n_s_index, __pyx_k_index, sizeof(__pyx_k_index), 0, 0, 1, 1}, + {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1}, + {&__pyx_n_s_int64, __pyx_k_int64, sizeof(__pyx_k_int64), 0, 0, 1, 1}, + {&__pyx_n_s_isnan, __pyx_k_isnan, sizeof(__pyx_k_isnan), 0, 0, 1, 1}, + {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1}, + {&__pyx_n_s_k, __pyx_k_k, sizeof(__pyx_k_k), 0, 0, 1, 1}, + {&__pyx_n_s_k_measurment, __pyx_k_k_measurment, sizeof(__pyx_k_k_measurment), 0, 0, 1, 1}, + {&__pyx_n_s_kalman_prediction_step_SVD_Cyth, __pyx_k_kalman_prediction_step_SVD_Cyth, sizeof(__pyx_k_kalman_prediction_step_SVD_Cyth), 0, 0, 1, 1}, + {&__pyx_n_s_kalman_update_step_SVD_Cython, __pyx_k_kalman_update_step_SVD_Cython, sizeof(__pyx_k_kalman_update_step_SVD_Cython), 0, 0, 1, 1}, + {&__pyx_n_s_linalg, __pyx_k_linalg, sizeof(__pyx_k_linalg), 0, 0, 1, 1}, + {&__pyx_n_s_log, __pyx_k_log, sizeof(__pyx_k_log), 0, 0, 1, 1}, + {&__pyx_n_s_log_likelihood, __pyx_k_log_likelihood, sizeof(__pyx_k_log_likelihood), 0, 0, 1, 1}, + {&__pyx_n_s_log_likelihood_update, __pyx_k_log_likelihood_update, sizeof(__pyx_k_log_likelihood_update), 0, 0, 1, 1}, + {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1}, + {&__pyx_n_s_m_init, __pyx_k_m_init, sizeof(__pyx_k_m_init), 0, 0, 1, 1}, + {&__pyx_n_s_m_pred, __pyx_k_m_pred, sizeof(__pyx_k_m_pred), 0, 0, 1, 1}, + {&__pyx_n_s_m_upd, __pyx_k_m_upd, sizeof(__pyx_k_m_upd), 0, 0, 1, 1}, + {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, + {&__pyx_n_s_measurement, __pyx_k_measurement, sizeof(__pyx_k_measurement), 0, 0, 1, 1}, + {&__pyx_n_s_measurement_dim_gt_one, __pyx_k_measurement_dim_gt_one, sizeof(__pyx_k_measurement_dim_gt_one), 0, 0, 1, 1}, + {&__pyx_n_s_nbytes, __pyx_k_nbytes, sizeof(__pyx_k_nbytes), 0, 0, 1, 1}, + {&__pyx_kp_u_ndarray_is_not_C_contiguous, __pyx_k_ndarray_is_not_C_contiguous, sizeof(__pyx_k_ndarray_is_not_C_contiguous), 0, 1, 0, 0}, + {&__pyx_kp_u_ndarray_is_not_Fortran_contiguou, __pyx_k_ndarray_is_not_Fortran_contiguou, sizeof(__pyx_k_ndarray_is_not_Fortran_contiguou), 0, 1, 0, 0}, + {&__pyx_n_s_np, __pyx_k_np, sizeof(__pyx_k_np), 0, 0, 1, 1}, + {&__pyx_n_s_numpy, __pyx_k_numpy, sizeof(__pyx_k_numpy), 0, 0, 1, 1}, + {&__pyx_n_s_overwrite_a, __pyx_k_overwrite_a, sizeof(__pyx_k_overwrite_a), 0, 0, 1, 1}, + {&__pyx_n_s_p_P, __pyx_k_p_P, sizeof(__pyx_k_p_P), 0, 0, 1, 1}, + {&__pyx_n_s_p_dP, __pyx_k_p_dP, sizeof(__pyx_k_p_dP), 0, 0, 1, 1}, + {&__pyx_n_s_p_dm, __pyx_k_p_dm, sizeof(__pyx_k_p_dm), 0, 0, 1, 1}, + {&__pyx_n_s_p_dynamic_callables, __pyx_k_p_dynamic_callables, sizeof(__pyx_k_p_dynamic_callables), 0, 0, 1, 1}, + {&__pyx_n_s_p_kalman_filter_type, __pyx_k_p_kalman_filter_type, sizeof(__pyx_k_p_kalman_filter_type), 0, 0, 1, 1}, + {&__pyx_n_s_p_m, __pyx_k_p_m, sizeof(__pyx_k_p_m), 0, 0, 1, 1}, + {&__pyx_n_s_p_measurement_callables, __pyx_k_p_measurement_callables, sizeof(__pyx_k_p_measurement_callables), 0, 0, 1, 1}, + {&__pyx_n_s_p_unique_Q_number, __pyx_k_p_unique_Q_number, sizeof(__pyx_k_p_unique_Q_number), 0, 0, 1, 1}, + {&__pyx_n_s_p_unique_R_number, __pyx_k_p_unique_R_number, sizeof(__pyx_k_p_unique_R_number), 0, 0, 1, 1}, + {&__pyx_n_s_param, __pyx_k_param, sizeof(__pyx_k_param), 0, 0, 1, 1}, + {&__pyx_n_s_param_number, __pyx_k_param_number, sizeof(__pyx_k_param_number), 0, 0, 1, 1}, + {&__pyx_n_s_pi, __pyx_k_pi, sizeof(__pyx_k_pi), 0, 0, 1, 1}, + {&__pyx_n_s_prev_mean, __pyx_k_prev_mean, sizeof(__pyx_k_prev_mean), 0, 0, 1, 1}, + {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, + {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, + {&__pyx_n_s_reconstruct_indices, __pyx_k_reconstruct_indices, sizeof(__pyx_k_reconstruct_indices), 0, 0, 1, 1}, + {&__pyx_n_s_regular, __pyx_k_regular, sizeof(__pyx_k_regular), 0, 0, 1, 1}, + {&__pyx_n_s_res, __pyx_k_res, sizeof(__pyx_k_res), 0, 0, 1, 1}, + {&__pyx_n_s_reset, __pyx_k_reset, sizeof(__pyx_k_reset), 0, 0, 1, 1}, + {&__pyx_n_s_ret, __pyx_k_ret, sizeof(__pyx_k_ret), 0, 0, 1, 1}, + {&__pyx_n_s_scipy, __pyx_k_scipy, sizeof(__pyx_k_scipy), 0, 0, 1, 1}, + {&__pyx_n_s_shape, __pyx_k_shape, sizeof(__pyx_k_shape), 0, 0, 1, 1}, + {&__pyx_n_s_sp, __pyx_k_sp, sizeof(__pyx_k_sp), 0, 0, 1, 1}, + {&__pyx_n_s_sqrt, __pyx_k_sqrt, sizeof(__pyx_k_sqrt), 0, 0, 1, 1}, + {&__pyx_n_s_state_dim, __pyx_k_state_dim, sizeof(__pyx_k_state_dim), 0, 0, 1, 1}, + {&__pyx_n_s_steps_no, __pyx_k_steps_no, sizeof(__pyx_k_steps_no), 0, 0, 1, 1}, + {&__pyx_n_s_sum, __pyx_k_sum, sizeof(__pyx_k_sum), 0, 0, 1, 1}, + {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1}, + {&__pyx_n_s_svd, __pyx_k_svd, sizeof(__pyx_k_svd), 0, 0, 1, 1}, + {&__pyx_n_s_svd_1_matr, __pyx_k_svd_1_matr, sizeof(__pyx_k_svd_1_matr), 0, 0, 1, 1}, + {&__pyx_n_s_svd_2_matr, __pyx_k_svd_2_matr, sizeof(__pyx_k_svd_2_matr), 0, 0, 1, 1}, + {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, + {&__pyx_n_s_time_series_no, __pyx_k_time_series_no, sizeof(__pyx_k_time_series_no), 0, 0, 1, 1}, + {&__pyx_n_s_tmp1, __pyx_k_tmp1, sizeof(__pyx_k_tmp1), 0, 0, 1, 1}, + {&__pyx_n_s_tmp2, __pyx_k_tmp2, sizeof(__pyx_k_tmp2), 0, 0, 1, 1}, + {&__pyx_n_s_tmp3, __pyx_k_tmp3, sizeof(__pyx_k_tmp3), 0, 0, 1, 1}, + {&__pyx_n_s_tmp5, __pyx_k_tmp5, sizeof(__pyx_k_tmp5), 0, 0, 1, 1}, + {&__pyx_n_s_total_size_of_data, __pyx_k_total_size_of_data, sizeof(__pyx_k_total_size_of_data), 0, 0, 1, 1}, + {&__pyx_n_s_unique, __pyx_k_unique, sizeof(__pyx_k_unique), 0, 0, 1, 1}, + {&__pyx_n_s_unique_Q_number, __pyx_k_unique_Q_number, sizeof(__pyx_k_unique_Q_number), 0, 0, 1, 1}, + {&__pyx_n_s_unique_R_number, __pyx_k_unique_R_number, sizeof(__pyx_k_unique_R_number), 0, 0, 1, 1}, + {&__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_k_unknown_dtype_code_in_numpy_pxd, sizeof(__pyx_k_unknown_dtype_code_in_numpy_pxd), 0, 1, 0, 0}, + {&__pyx_kp_s_users_agrigori_SpiderOak_sp_hiv, __pyx_k_users_agrigori_SpiderOak_sp_hiv, sizeof(__pyx_k_users_agrigori_SpiderOak_sp_hiv), 0, 0, 1, 0}, + {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1}, + {&__pyx_n_s_vstack, __pyx_k_vstack, sizeof(__pyx_k_vstack), 0, 0, 1, 1}, + {&__pyx_n_s_zeros, __pyx_k_zeros, sizeof(__pyx_k_zeros), 0, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0} +}; +static int __Pyx_InitCachedBuiltins(void) { + __pyx_builtin_NotImplemented = __Pyx_GetBuiltinName(__pyx_n_s_NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __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 = 627; __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 = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +static int __Pyx_InitCachedConstants(void) { + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); + + /* "GPy/models/state_space_cython.pyx":23 + * cdef class Dynamic_Callables_Cython: + * cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + * raise NotImplemented("(cython) f_a is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix + */ + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_cython_f_a_is_not_implemented); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple_); + __Pyx_GIVEREF(__pyx_tuple_); + + /* "GPy/models/state_space_cython.pyx":26 + * + * cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix + * raise NotImplemented("(cython) Ak is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Qk(self, int k): + */ + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_cython_Ak_is_not_implemented); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__2); + __Pyx_GIVEREF(__pyx_tuple__2); + + /* "GPy/models/state_space_cython.pyx":29 + * + * cpdef Qk(self, int k): + * raise NotImplemented("(cython) Qk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Q_srk(self, int k): + */ + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_cython_Qk_is_not_implemented); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__3); + __Pyx_GIVEREF(__pyx_tuple__3); + + /* "GPy/models/state_space_cython.pyx":32 + * + * cpdef Q_srk(self, int k): + * raise NotImplemented("(cython) Q_srk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_cython_Q_srk_is_not_implemented); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__4); + __Pyx_GIVEREF(__pyx_tuple__4); + + /* "GPy/models/state_space_cython.pyx":35 + * + * cpdef dAk(self, int k): + * raise NotImplemented("(cython) dAk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_s_cython_dAk_is_not_implemented); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__5); + __Pyx_GIVEREF(__pyx_tuple__5); + + /* "GPy/models/state_space_cython.pyx":38 + * + * cpdef dQk(self, int k): + * raise NotImplemented("(cython) dQk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef reset(self, bint compute_derivatives = False): + */ + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_cython_dQk_is_not_implemented); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__6); + __Pyx_GIVEREF(__pyx_tuple__6); + + /* "GPy/models/state_space_cython.pyx":41 + * + * cpdef reset(self, bint compute_derivatives = False): + * raise NotImplemented("(cython) reset is not implemented!") # <<<<<<<<<<<<<< + * + * # Template class for measurement callables + */ + __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_cython_reset_is_not_implemented); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__7); + __Pyx_GIVEREF(__pyx_tuple__7); + + /* "GPy/models/state_space_cython.pyx":46 + * cdef class Measurement_Callables_Cython: + * cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): + * raise NotImplemented("(cython) f_a is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + */ + __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_s_cython_f_a_is_not_implemented); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__8); + __Pyx_GIVEREF(__pyx_tuple__8); + + /* "GPy/models/state_space_cython.pyx":49 + * + * cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + * raise NotImplemented("(cython) Hk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef Rk(self, int k): + */ + __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_s_cython_Hk_is_not_implemented); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__9); + __Pyx_GIVEREF(__pyx_tuple__9); + + /* "GPy/models/state_space_cython.pyx":52 + * + * cpdef Rk(self, int k): + * raise NotImplemented("(cython) Rk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef R_isrk(self, int k): + */ + __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s_cython_Rk_is_not_implemented); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__10); + __Pyx_GIVEREF(__pyx_tuple__10); + + /* "GPy/models/state_space_cython.pyx":55 + * + * cpdef R_isrk(self, int k): + * raise NotImplemented("(cython) Q_srk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dHk(self, int k): + */ + __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_cython_Q_srk_is_not_implemented); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__11); + __Pyx_GIVEREF(__pyx_tuple__11); + + /* "GPy/models/state_space_cython.pyx":58 + * + * cpdef dHk(self, int k): + * raise NotImplemented("(cython) dAk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef dRk(self, int k): + */ + __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_cython_dAk_is_not_implemented); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__12); + __Pyx_GIVEREF(__pyx_tuple__12); + + /* "GPy/models/state_space_cython.pyx":61 + * + * cpdef dRk(self, int k): + * raise NotImplemented("(cython) dQk is not implemented!") # <<<<<<<<<<<<<< + * + * cpdef reset(self,compute_derivatives = False): + */ + __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_cython_dQk_is_not_implemented); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__13); + __Pyx_GIVEREF(__pyx_tuple__13); + + /* "GPy/models/state_space_cython.pyx":64 + * + * cpdef reset(self,compute_derivatives = False): + * raise NotImplemented("(cython) reset is not implemented!") # <<<<<<<<<<<<<< + * + * cdef class R_handling_Cython(Measurement_Callables_Cython): + */ + __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_s_cython_reset_is_not_implemented); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__14); + __Pyx_GIVEREF(__pyx_tuple__14); + + /* "GPy/models/state_space_cython.pyx":119 + * + * cpdef Rk(self, int k): + * return self.R[:,:, self.index[self.R_time_var_index, k]] # <<<<<<<<<<<<<< + * + * + */ + __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); + __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); + + /* "GPy/models/state_space_cython.pyx":124 + * cpdef dRk(self,int k): + * if self.dR is None: + * raise ValueError("dR derivative is None") # <<<<<<<<<<<<<< + * + * return self.dR # the same dirivative on each iteration + */ + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_dR_derivative_is_None); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); + + /* "GPy/models/state_space_cython.pyx":133 + * """ + * cdef int ind = self.index[self.R_time_var_index, k] + * cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ] # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] inv_square_root + */ + __pyx_slice__18 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__18); + __Pyx_GIVEREF(__pyx_slice__18); + __pyx_slice__19 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__19); + __Pyx_GIVEREF(__pyx_slice__19); + + /* "GPy/models/state_space_cython.pyx":202 + * """ + * + * return self.H[:,:, self.index[self.H_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dHk(self,int k): + */ + __pyx_slice__20 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__20); + __Pyx_GIVEREF(__pyx_slice__20); + __pyx_slice__21 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__21); + __Pyx_GIVEREF(__pyx_slice__21); + + /* "GPy/models/state_space_cython.pyx":206 + * cpdef dHk(self,int k): + * if self.dH is None: + * raise ValueError("dH derivative is None") # <<<<<<<<<<<<<< + * + * return self.dH # the same dirivative on each iteration + */ + __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_s_dH_derivative_is_None); if (unlikely(!__pyx_tuple__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + + /* "GPy/models/state_space_cython.pyx":269 + * k (iteration number). starts at 0 + * """ + * return self.Q[:,:, self.index[self.Q_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __pyx_slice__23 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__23); + __Pyx_GIVEREF(__pyx_slice__23); + __pyx_slice__24 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__24); + __Pyx_GIVEREF(__pyx_slice__24); + + /* "GPy/models/state_space_cython.pyx":273 + * cpdef dQk(self, int k): + * if self.dQ is None: + * raise ValueError("dQ derivative is None") # <<<<<<<<<<<<<< + * + * return self.dQ # the same dirivative on each iteration + */ + __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_dQ_derivative_is_None); if (unlikely(!__pyx_tuple__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__25); + __Pyx_GIVEREF(__pyx_tuple__25); + + /* "GPy/models/state_space_cython.pyx":285 + * """ + * cdef int ind = self.index[self.Q_time_var_index, k] + * cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind] # <<<<<<<<<<<<<< + * + * + */ + __pyx_slice__26 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__26); + __Pyx_GIVEREF(__pyx_slice__26); + __pyx_slice__27 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__27); + __Pyx_GIVEREF(__pyx_slice__27); + + /* "GPy/models/state_space_cython.pyx":356 + * """ + * + * return self.A[:,:, self.index[self.A_time_var_index, k]] # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __pyx_slice__28 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__28); + __Pyx_GIVEREF(__pyx_slice__28); + __pyx_slice__29 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__29); + __Pyx_GIVEREF(__pyx_slice__29); + + /* "GPy/models/state_space_cython.pyx":360 + * cpdef dAk(self, int k): + * if self.dA is None: + * raise ValueError("dA derivative is None") # <<<<<<<<<<<<<< + * + * return self.dA # the same dirivative on each iteration + */ + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_dA_derivative_is_None); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); + + /* "GPy/models/state_space_cython.pyx":454 + * cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): + * self.last_k = k + * return self.As[:,:, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef Qk(self,int k): + */ + __pyx_slice__31 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__31)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__31); + __Pyx_GIVEREF(__pyx_slice__31); + __pyx_slice__32 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__32); + __Pyx_GIVEREF(__pyx_slice__32); + + /* "GPy/models/state_space_cython.pyx":458 + * cpdef Qk(self,int k): + * self.last_k = k + * return self.Qs[:,:, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef dAk(self, int k): + */ + __pyx_slice__33 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__33); + __Pyx_GIVEREF(__pyx_slice__33); + __pyx_slice__34 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__34); + __Pyx_GIVEREF(__pyx_slice__34); + + /* "GPy/models/state_space_cython.pyx":462 + * cpdef dAk(self, int k): + * self.last_k = k + * return self.dAs[:,:, :, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * cpdef dQk(self, int k): + */ + __pyx_slice__35 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__35)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__35); + __Pyx_GIVEREF(__pyx_slice__35); + __pyx_slice__36 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__36)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__36); + __Pyx_GIVEREF(__pyx_slice__36); + __pyx_slice__37 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__37); + __Pyx_GIVEREF(__pyx_slice__37); + + /* "GPy/models/state_space_cython.pyx":466 + * cpdef dQk(self, int k): + * self.last_k = k + * return self.dQs[:,:, :, self.reconstruct_indices[k]] # <<<<<<<<<<<<<< + * + * + */ + __pyx_slice__38 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__38)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__38); + __Pyx_GIVEREF(__pyx_slice__38); + __pyx_slice__39 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__39); + __Pyx_GIVEREF(__pyx_slice__39); + __pyx_slice__40 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__40); + __Pyx_GIVEREF(__pyx_slice__40); + + /* "GPy/models/state_space_cython.pyx":484 + * square_root = self.Q_svd_dict[matrix_index] + * else: + * U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], # <<<<<<<<<<<<<< + * full_matrices=False, compute_uv=True, + * overwrite_a=False, check_finite=False) + */ + __pyx_slice__41 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__41); + __Pyx_GIVEREF(__pyx_slice__41); + __pyx_slice__42 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 484; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__42); + __Pyx_GIVEREF(__pyx_slice__42); + + /* "GPy/models/state_space_cython.pyx":628 + * + * for j in range(param_number): + * dA = dA_all_params[:,:,j] # <<<<<<<<<<<<<< + * dQ = dQ_all_params[:,:,j] + * + */ + __pyx_slice__43 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__43); + __Pyx_GIVEREF(__pyx_slice__43); + __pyx_slice__44 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__44); + __Pyx_GIVEREF(__pyx_slice__44); + + /* "GPy/models/state_space_cython.pyx":629 + * for j in range(param_number): + * dA = dA_all_params[:,:,j] + * dQ = dQ_all_params[:,:,j] # <<<<<<<<<<<<<< + * + * dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) + */ + __pyx_slice__45 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__45); + __Pyx_GIVEREF(__pyx_slice__45); + __pyx_slice__46 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__46); + __Pyx_GIVEREF(__pyx_slice__46); + + /* "GPy/models/state_space_cython.pyx":631 + * dQ = dQ_all_params[:,:,j] + * + * dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) # <<<<<<<<<<<<<< + * # prediction step derivatives for current parameter: + * + */ + __pyx_slice__47 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__47); + __Pyx_GIVEREF(__pyx_slice__47); + __pyx_slice__48 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__48); + __Pyx_GIVEREF(__pyx_slice__48); + __pyx_slice__49 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__49); + __Pyx_GIVEREF(__pyx_slice__49); + __pyx_slice__50 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__50); + __Pyx_GIVEREF(__pyx_slice__50); + + /* "GPy/models/state_space_cython.pyx":634 + * # prediction step derivatives for current parameter: + * + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) # <<<<<<<<<<<<<< + * dP_pred[:,:,j] += dP_pred[:,:,j].T + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + */ + __pyx_slice__51 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__51); + __Pyx_GIVEREF(__pyx_slice__51); + __pyx_slice__52 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__52); + __Pyx_GIVEREF(__pyx_slice__52); + + /* "GPy/models/state_space_cython.pyx":635 + * + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + * dP_pred[:,:,j] += dP_pred[:,:,j].T # <<<<<<<<<<<<<< + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + * + */ + __pyx_slice__53 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__53); + __Pyx_GIVEREF(__pyx_slice__53); + __pyx_slice__54 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__54)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__54); + __Pyx_GIVEREF(__pyx_slice__54); + __pyx_slice__55 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__55); + __Pyx_GIVEREF(__pyx_slice__55); + __pyx_slice__56 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__56)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 635; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__56); + __Pyx_GIVEREF(__pyx_slice__56); + + /* "GPy/models/state_space_cython.pyx":636 + * dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + * dP_pred[:,:,j] += dP_pred[:,:,j].T + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ # <<<<<<<<<<<<<< + * + * dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + */ + __pyx_slice__57 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__57); + __Pyx_GIVEREF(__pyx_slice__57); + __pyx_slice__58 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__58)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__58); + __Pyx_GIVEREF(__pyx_slice__58); + __pyx_slice__59 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__59); + __Pyx_GIVEREF(__pyx_slice__59); + __pyx_slice__60 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__60); + __Pyx_GIVEREF(__pyx_slice__60); + + /* "GPy/models/state_space_cython.pyx":638 + * dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + * + * dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize # <<<<<<<<<<<<<< + * else: + * dm_pred = None + */ + __pyx_slice__61 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__61); + __Pyx_GIVEREF(__pyx_slice__61); + __pyx_slice__62 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__62); + __Pyx_GIVEREF(__pyx_slice__62); + __pyx_slice__63 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__63); + __Pyx_GIVEREF(__pyx_slice__63); + __pyx_slice__64 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__64); + __Pyx_GIVEREF(__pyx_slice__64); + __pyx_slice__65 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__65); + __Pyx_GIVEREF(__pyx_slice__65); + __pyx_slice__66 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__66); + __Pyx_GIVEREF(__pyx_slice__66); + + /* "GPy/models/state_space_cython.pyx":780 + * #log_likelihood_update = log_likelihood_update[0,0] # to make int + * if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + * raise ValueError("Nan values in likelihood update!") # <<<<<<<<<<<<<< + * else: + * log_likelihood_update = None + */ + __pyx_tuple__67 = PyTuple_Pack(1, __pyx_kp_s_Nan_values_in_likelihood_update); if (unlikely(!__pyx_tuple__67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__67); + __Pyx_GIVEREF(__pyx_tuple__67); + + /* "GPy/models/state_space_cython.pyx":786 + * else: + * measurement_dim_gt_one = True + * raise ValueError("""Measurement dimension larger then 1 is currently not supported""") # <<<<<<<<<<<<<< + * + * # Old method of computing updated covariance (for testing) -> + */ + __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_s_Measurement_dimension_larger_the); if (unlikely(!__pyx_tuple__68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__68); + __Pyx_GIVEREF(__pyx_tuple__68); + + /* "GPy/models/state_space_cython.pyx":825 + * for param in range(param_number): + * + * dH = dH_all_params[:,:,param] # <<<<<<<<<<<<<< + * dR = dR_all_params[:,:,param] + * + */ + __pyx_slice__69 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__69); + __Pyx_GIVEREF(__pyx_slice__69); + __pyx_slice__70 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__70); + __Pyx_GIVEREF(__pyx_slice__70); + + /* "GPy/models/state_space_cython.pyx":826 + * + * dH = dH_all_params[:,:,param] + * dR = dR_all_params[:,:,param] # <<<<<<<<<<<<<< + * + * dm_pred = dm_pred_all_params[:,:,param] + */ + __pyx_slice__71 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__71); + __Pyx_GIVEREF(__pyx_slice__71); + __pyx_slice__72 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__72); + __Pyx_GIVEREF(__pyx_slice__72); + + /* "GPy/models/state_space_cython.pyx":828 + * dR = dR_all_params[:,:,param] + * + * dm_pred = dm_pred_all_params[:,:,param] # <<<<<<<<<<<<<< + * dP_pred = dP_pred_all_params[:,:,param] + * + */ + __pyx_slice__73 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__73); + __Pyx_GIVEREF(__pyx_slice__73); + __pyx_slice__74 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__74); + __Pyx_GIVEREF(__pyx_slice__74); + + /* "GPy/models/state_space_cython.pyx":829 + * + * dm_pred = dm_pred_all_params[:,:,param] + * dP_pred = dP_pred_all_params[:,:,param] # <<<<<<<<<<<<<< + * + * # Terms in the likelihood derivatives + */ + __pyx_slice__75 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__75); + __Pyx_GIVEREF(__pyx_slice__75); + __pyx_slice__76 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__76); + __Pyx_GIVEREF(__pyx_slice__76); + + /* "GPy/models/state_space_cython.pyx":847 + * + * # terms required for the next step, save this for each parameter + * dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) # <<<<<<<<<<<<<< + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + */ + __pyx_slice__77 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__77); + __Pyx_GIVEREF(__pyx_slice__77); + __pyx_slice__78 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__78); + __Pyx_GIVEREF(__pyx_slice__78); + + /* "GPy/models/state_space_cython.pyx":849 + * dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) # <<<<<<<<<<<<<< + * dP_upd[:,:,param] += dP_upd[:,:,param].T + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + */ + __pyx_slice__79 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__79); + __Pyx_GIVEREF(__pyx_slice__79); + __pyx_slice__80 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__80); + __Pyx_GIVEREF(__pyx_slice__80); + + /* "GPy/models/state_space_cython.pyx":850 + * + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + * dP_upd[:,:,param] += dP_upd[:,:,param].T # <<<<<<<<<<<<<< + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + * + */ + __pyx_slice__81 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__81); + __Pyx_GIVEREF(__pyx_slice__81); + __pyx_slice__82 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__82); + __Pyx_GIVEREF(__pyx_slice__82); + __pyx_slice__83 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__83); + __Pyx_GIVEREF(__pyx_slice__83); + __pyx_slice__84 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__84); + __Pyx_GIVEREF(__pyx_slice__84); + + /* "GPy/models/state_space_cython.pyx":851 + * dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + * dP_upd[:,:,param] += dP_upd[:,:,param].T + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) # <<<<<<<<<<<<<< + * + * dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + */ + __pyx_slice__85 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__85); + __Pyx_GIVEREF(__pyx_slice__85); + __pyx_slice__86 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__86); + __Pyx_GIVEREF(__pyx_slice__86); + + /* "GPy/models/state_space_cython.pyx":853 + * dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + * + * dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize # <<<<<<<<<<<<<< + * # computing the likelihood change for each parameter: + * tmp5 = v / S + */ + __pyx_slice__87 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__87); + __Pyx_GIVEREF(__pyx_slice__87); + __pyx_slice__88 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__88); + __Pyx_GIVEREF(__pyx_slice__88); + __pyx_slice__89 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__89); + __Pyx_GIVEREF(__pyx_slice__89); + __pyx_slice__90 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__90); + __Pyx_GIVEREF(__pyx_slice__90); + __pyx_slice__91 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__91); + __Pyx_GIVEREF(__pyx_slice__91); + __pyx_slice__92 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__92); + __Pyx_GIVEREF(__pyx_slice__92); + + /* "GPy/models/state_space_cython.pyx":858 + * + * + * d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ # <<<<<<<<<<<<<< + * np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + * + */ + __pyx_slice__93 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__93); + __Pyx_GIVEREF(__pyx_slice__93); + + /* "GPy/models/state_space_cython.pyx":891 + * # Mean estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE) + * M[0,:,:] = m_init # Initialize mean values # <<<<<<<<<<<<<< + * # Variance estimations. Initial values will be included + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + */ + __pyx_slice__94 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__94); + __Pyx_GIVEREF(__pyx_slice__94); + __pyx_slice__95 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__95); + __Pyx_GIVEREF(__pyx_slice__95); + __pyx_tuple__96 = PyTuple_Pack(3, __pyx_int_0, __pyx_slice__94, __pyx_slice__95); if (unlikely(!__pyx_tuple__96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__96); + __Pyx_GIVEREF(__pyx_tuple__96); + + /* "GPy/models/state_space_cython.pyx":895 + * cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + * P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + * P[0,:,:] = P_init # Initialize initial covariance matrix # <<<<<<<<<<<<<< + * + * cdef np.ndarray[DTYPE_t, ndim=2] U + */ + __pyx_slice__97 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__97); + __Pyx_GIVEREF(__pyx_slice__97); + __pyx_slice__98 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__98); + __Pyx_GIVEREF(__pyx_slice__98); + __pyx_tuple__99 = PyTuple_Pack(3, __pyx_int_0, __pyx_slice__97, __pyx_slice__98); if (unlikely(!__pyx_tuple__99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__99); + __Pyx_GIVEREF(__pyx_tuple__99); + + /* "GPy/models/state_space_cython.pyx":927 + * #import pdb; pdb.set_trace() + * + * prev_mean = M[k,:,:] # mean from the previous step # <<<<<<<<<<<<<< + * + * m_pred, P_pred, dm_pred, dP_pred = \ + */ + __pyx_slice__100 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__100); + __Pyx_GIVEREF(__pyx_slice__100); + __pyx_slice__101 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__101); + __Pyx_GIVEREF(__pyx_slice__101); + + /* "GPy/models/state_space_cython.pyx":933 + * calc_grad_log_likelihood, dm_upd, dP_upd) + * + * k_measurment = Y[k,:,:] # <<<<<<<<<<<<<< + * if (np.any(np.isnan(k_measurment)) == False): + * # if np.any(np.isnan(k_measurment)): + */ + __pyx_slice__102 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__102); + __Pyx_GIVEREF(__pyx_slice__102); + __pyx_slice__103 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__103); + __Pyx_GIVEREF(__pyx_slice__103); + + /* "GPy/models/state_space_cython.pyx":945 + * else: + * if not np.all(np.isnan(k_measurment)): + * raise ValueError("""Nan measurements are currently not supported if # <<<<<<<<<<<<<< + * they are intermixed with not NaN measurements""") + * else: + */ + __pyx_tuple__104 = PyTuple_Pack(1, __pyx_kp_s_Nan_measurements_are_currently_n); if (unlikely(!__pyx_tuple__104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__104); + __Pyx_GIVEREF(__pyx_tuple__104); + + /* "GPy/models/state_space_cython.pyx":961 + * grad_log_likelihood += d_log_likelihood_update + * + * M[k+1,:,:] = m_upd # separate mean value for each time series # <<<<<<<<<<<<<< + * P[k+1,:,:] = P_upd[0] + * + */ + __pyx_slice__105 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__105); + __Pyx_GIVEREF(__pyx_slice__105); + __pyx_slice__106 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__106)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__106); + __Pyx_GIVEREF(__pyx_slice__106); + + /* "GPy/models/state_space_cython.pyx":962 + * + * M[k+1,:,:] = m_upd # separate mean value for each time series + * P[k+1,:,:] = P_upd[0] # <<<<<<<<<<<<<< + * + * return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) + */ + __pyx_slice__107 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__107); + __Pyx_GIVEREF(__pyx_slice__107); + __pyx_slice__108 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__108)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__108); + __Pyx_GIVEREF(__pyx_slice__108); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): + * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< + * + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + */ + __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple__109)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__109); + __Pyx_GIVEREF(__pyx_tuple__109); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) + * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): + * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< + * + * info.buf = PyArray_DATA(self) + */ + __pyx_tuple__110 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__110)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__110); + __Pyx_GIVEREF(__pyx_tuple__110); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 + * if ((descr.byteorder == c'>' and little_endian) or + * (descr.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * if t == NPY_BYTE: f = "b" + * elif t == NPY_UBYTE: f = "B" + */ + __pyx_tuple__111 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__111)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__111); + __Pyx_GIVEREF(__pyx_tuple__111); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + * + * if (end - f) - (new_offset - offset[0]) < 15: + * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< + * + * if ((child.byteorder == c'>' and little_endian) or + */ + __pyx_tuple__112 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__112)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__112); + __Pyx_GIVEREF(__pyx_tuple__112); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 + * if ((child.byteorder == c'>' and little_endian) or + * (child.byteorder == c'<' and not little_endian)): + * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< + * # One could encode it in the format string and have Cython + * # complain instead, BUT: < and > in format strings also imply + */ + __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__113)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__113); + __Pyx_GIVEREF(__pyx_tuple__113); + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 + * t = child.type_num + * if end - f < 5: + * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< + * + * # Until ticket #99 is fixed, use integers to avoid warnings + */ + __pyx_tuple__114 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__114)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__114); + __Pyx_GIVEREF(__pyx_tuple__114); + + /* "GPy/models/state_space_cython.pyx":510 + * + * @cython.boundscheck(False) + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, # <<<<<<<<<<<<<< + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + */ + __pyx_tuple__115 = PyTuple_Pack(31, __pyx_n_s_k, __pyx_n_s_p_m, __pyx_n_s_p_P, __pyx_n_s_p_dynamic_callables, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_p_dm, __pyx_n_s_p_dP, __pyx_n_s_Prev_cov, __pyx_n_s_S_old, __pyx_n_s_V_old, __pyx_n_s_A, __pyx_n_s_Q, __pyx_n_s_Q_sr, __pyx_n_s_m_pred, __pyx_n_s_svd_1_matr, __pyx_n_s_res, __pyx_n_s_U, __pyx_n_s_S, __pyx_n_s_Vh, __pyx_n_s_V_new, __pyx_n_s_S_new, __pyx_n_s_P_pred, __pyx_n_s_dA_all_params, __pyx_n_s_dQ_all_params, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_param_number, __pyx_n_s_j, __pyx_n_s_ret, __pyx_n_s_dA, __pyx_n_s_dQ); if (unlikely(!__pyx_tuple__115)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__115); + __Pyx_GIVEREF(__pyx_tuple__115); + __pyx_codeobj__116 = (PyObject*)__Pyx_PyCode_New(7, 0, 31, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__115, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_users_agrigori_SpiderOak_sp_hiv, __pyx_n_s_kalman_prediction_step_SVD_Cyth, 510, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__116)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":649 + * + * @cython.boundscheck(False) + * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + */ + __pyx_tuple__117 = PyTuple_Pack(52, __pyx_n_s_k, __pyx_n_s_p_m, __pyx_n_s_p_P, __pyx_n_s_p_measurement_callables, __pyx_n_s_measurement, __pyx_n_s_calc_log_likelihood, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_p_dm, __pyx_n_s_p_dP, __pyx_n_s_m_pred, __pyx_n_s_P_pred, __pyx_n_s_S_pred, __pyx_n_s_V_pred, __pyx_n_s_H, __pyx_n_s_R, __pyx_n_s_R_isr, __pyx_n_s_time_series_no, __pyx_n_s_log_likelihood_update, __pyx_n_s_v, __pyx_n_s_svd_2_matr, __pyx_n_s_res, __pyx_n_s_U, __pyx_n_s_S_svd, __pyx_n_s_Vh, __pyx_n_s_U_upd, __pyx_n_s_S_upd, __pyx_n_s_P_upd, __pyx_n_s_S, __pyx_n_s_K, __pyx_n_s_measurement_dim_gt_one, __pyx_n_s_dm_upd, __pyx_n_s_dP_upd, __pyx_n_s_d_log_likelihood_update, __pyx_n_s_dm_pred_all_params, __pyx_n_s_dP_pred_all_params, __pyx_n_s_param_number, __pyx_n_s_dH_all_params, __pyx_n_s_dR_all_params, __pyx_n_s_param, __pyx_n_s_dH, __pyx_n_s_dR, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_dv, __pyx_n_s_dS, __pyx_n_s_tmp1, __pyx_n_s_tmp2, __pyx_n_s_tmp3, __pyx_n_s_dK, __pyx_n_s_tmp5, __pyx_n_s_ret, __pyx_n_s_m_upd); if (unlikely(!__pyx_tuple__117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__117); + __Pyx_GIVEREF(__pyx_tuple__117); + __pyx_codeobj__118 = (PyObject*)__Pyx_PyCode_New(9, 0, 52, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__117, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_users_agrigori_SpiderOak_sp_hiv, __pyx_n_s_kalman_update_step_SVD_Cython, 649, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "GPy/models/state_space_cython.pyx":875 + * + * @cython.boundscheck(False) + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + */ + __pyx_tuple__119 = PyTuple_Pack(35, __pyx_n_s_state_dim, __pyx_n_s_p_dynamic_callables, __pyx_n_s_p_measurement_callables, __pyx_n_s_X, __pyx_n_s_Y, __pyx_n_s_m_init, __pyx_n_s_P_init, __pyx_n_s_p_kalman_filter_type, __pyx_n_s_calc_log_likelihood, __pyx_n_s_calc_grad_log_likelihood, __pyx_n_s_grad_params_no, __pyx_n_s_dm_init, __pyx_n_s_dP_init, __pyx_n_s_steps_no, __pyx_n_s_time_series_no, __pyx_n_s_M, __pyx_n_s_P, __pyx_n_s_U, __pyx_n_s_S, __pyx_n_s_Vh, __pyx_n_s_P_upd, __pyx_n_s_log_likelihood, __pyx_n_s_grad_log_likelihood, __pyx_n_s_dm_upd, __pyx_n_s_dP_upd, __pyx_n_s_prev_mean, __pyx_n_s_k_measurment, __pyx_n_s_m_pred, __pyx_n_s_m_upd, __pyx_n_s_P_pred, __pyx_n_s_dm_pred, __pyx_n_s_dP_pred, __pyx_n_s_log_likelihood_update, __pyx_n_s_d_log_likelihood_update, __pyx_n_s_k); if (unlikely(!__pyx_tuple__119)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__119); + __Pyx_GIVEREF(__pyx_tuple__119); + __pyx_codeobj__120 = (PyObject*)__Pyx_PyCode_New(13, 0, 35, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__119, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_users_agrigori_SpiderOak_sp_hiv, __pyx_n_s_cont_discr_kalman_filter_raw_Cy, 875, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__120)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_RefNannyFinishContext(); + return 0; + __pyx_L1_error:; + __Pyx_RefNannyFinishContext(); + return -1; +} + +static int __Pyx_InitGlobals(void) { + if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_float_0_5 = PyFloat_FromDouble(0.5); if (unlikely(!__pyx_float_0_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_float_1_0 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_float_1_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_float_1eneg_17 = PyFloat_FromDouble(1e-17); if (unlikely(!__pyx_float_1eneg_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_float_neg_0_5 = PyFloat_FromDouble(-0.5); if (unlikely(!__pyx_float_neg_0_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + return 0; + __pyx_L1_error:; + return -1; +} + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC initstate_space_cython(void); /*proto*/ +PyMODINIT_FUNC initstate_space_cython(void) +#else +PyMODINIT_FUNC PyInit_state_space_cython(void); /*proto*/ +PyMODINIT_FUNC PyInit_state_space_cython(void) +#endif +{ + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannyDeclarations + #if CYTHON_REFNANNY + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny"); + if (!__Pyx_RefNanny) { + PyErr_Clear(); + __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny"); + if (!__Pyx_RefNanny) + Py_FatalError("failed to import 'refnanny' module"); + } + #endif + __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_state_space_cython(void)", 0); + if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #ifdef __Pyx_CyFunction_USED + if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_FusedFunction_USED + if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + #ifdef __Pyx_Generator_USED + if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + /*--- Library function declarations ---*/ + /*--- Threads initialization code ---*/ + #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS + #ifdef WITH_THREAD /* Python build with threading support? */ + PyEval_InitThreads(); + #endif + #endif + /*--- Module creation code ---*/ + #if PY_MAJOR_VERSION < 3 + __pyx_m = Py_InitModule4("state_space_cython", __pyx_methods, __pyx_k_Contains_some_cython_code_for_s, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); + #else + __pyx_m = PyModule_Create(&__pyx_moduledef); + #endif + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + Py_INCREF(__pyx_d); + __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_PYPY + Py_INCREF(__pyx_b); + #endif + if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + /*--- Initialize various global constants etc. ---*/ + if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) + if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + if (__pyx_module_is_main_GPy__models__state_space_cython) { + if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + } + #if PY_MAJOR_VERSION >= 3 + { + PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!PyDict_GetItemString(modules, "GPy.models.state_space_cython")) { + if (unlikely(PyDict_SetItemString(modules, "GPy.models.state_space_cython", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + } + #endif + /*--- Builtin init code ---*/ + if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Constants init code ---*/ + if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Global init code ---*/ + /*--- Variable export code ---*/ + /*--- Function export code ---*/ + /*--- Type init code ---*/ + __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_f_a; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Ak; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Qk; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_Q_srk; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dAk; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_dQk; + __pyx_vtable_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Dynamic_Callables_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.f_h = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_f_h; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.Hk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Hk; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.Rk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_Rk; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.R_isrk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_R_isrk; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.dHk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dHk; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.dRk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_dRk; + __pyx_vtable_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_28Measurement_Callables_Cython_reset; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Measurement_Callables_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.Rk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_Rk; + __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.R_isrk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_R_isrk; + __pyx_vtable_3GPy_6models_18state_space_cython_R_handling_Cython.__pyx_base.dRk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17R_handling_Cython_dRk; + __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Measurement_Callables_Cython; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_print = 0; + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_17R_handling_Cython___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_17R_handling_Cython___init__; + } + } + #endif + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "R_handling_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython = &__pyx_type_3GPy_6models_18state_space_cython_R_handling_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_R_handling_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.f_h = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_f_h; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.Hk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_Hk; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.__pyx_base.__pyx_base.dHk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Measurement_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_32Std_Measurement_Callables_Cython_dHk; + __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_R_handling_Cython; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Std_Measurement_Callables_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Std_Measurement_Callables_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Qk; + __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_Q_srk; + __pyx_vtable_3GPy_6models_18state_space_cython_Q_handling_Cython.__pyx_base.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_17Q_handling_Cython_dQk; + __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_print = 0; + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_17Q_handling_Cython___init__; + } + } + #endif + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Q_handling_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Q_handling_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_f_a; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_Ak; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_dAk; + __pyx_vtable_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.__pyx_base.__pyx_base.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_28Std_Dynamic_Callables_Cython_reset; + __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_print = 0; + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "Std_Dynamic_Callables_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython = &__pyx_type_3GPy_6models_18state_space_cython_Std_Dynamic_Callables_Cython; + __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = &__pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base = *__pyx_vtabptr_3GPy_6models_18state_space_cython_Q_handling_Cython; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.f_a = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_f_a; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Ak = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, PyArrayObject *, PyArrayObject *, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Ak; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Qk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Qk; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.Q_srk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_Q_srk; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.dAk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dAk; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.dQk = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int, int __pyx_skip_dispatch))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_dQk; + __pyx_vtable_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.__pyx_base.__pyx_base.reset = (PyObject *(*)(struct __pyx_obj_3GPy_6models_18state_space_cython_Dynamic_Callables_Cython *, int __pyx_skip_dispatch, struct __pyx_opt_args_3GPy_6models_18state_space_cython_24Dynamic_Callables_Cython_reset *__pyx_optional_args))__pyx_f_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython_reset; + __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_base = __pyx_ptype_3GPy_6models_18state_space_cython_Q_handling_Cython; + if (PyType_Ready(&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_print = 0; + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__.doc = __pyx_doc_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_3GPy_6models_18state_space_cython_22AQcompute_batch_Cython___init__; + } + } + #endif + if (__Pyx_SetVtable(__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython.tp_dict, __pyx_vtabptr_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttrString(__pyx_m, "AQcompute_batch_Cython", (PyObject *)&__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3GPy_6models_18state_space_cython_AQcompute_batch_Cython = &__pyx_type_3GPy_6models_18state_space_cython_AQcompute_batch_Cython; + /*--- Type import code ---*/ + __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", + #if CYTHON_COMPILING_IN_PYPY + sizeof(PyTypeObject), + #else + sizeof(PyHeapTypeObject), + #endif + 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /*--- Variable import code ---*/ + /*--- Function import code ---*/ + /*--- Execution code ---*/ + + /* "GPy/models/state_space_cython.pyx":5 + * Contains some cython code for state space modelling. + * """ + * import numpy as np # <<<<<<<<<<<<<< + * cimport numpy as np + * import scipy as sp + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __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 = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":7 + * import numpy as np + * cimport numpy as np + * import scipy as sp # <<<<<<<<<<<<<< + * cimport cython + * + */ + __pyx_t_1 = __Pyx_Import(__pyx_n_s_scipy, 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_sp, __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/models/state_space_cython.pyx":14 + * bint npy_isnan(double x) + * + * DTYPE = np.float64 # <<<<<<<<<<<<<< + * DTYPE_int = np.int64 + * + */ + __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "GPy/models/state_space_cython.pyx":15 + * + * DTYPE = np.float64 + * DTYPE_int = np.int64 # <<<<<<<<<<<<<< + * + * ctypedef np.float64_t DTYPE_t + */ + __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_np); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_int64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyDict_SetItem(__pyx_d, __pyx_n_s_DTYPE_int, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":510 + * + * @cython.boundscheck(False) + * def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, # <<<<<<<<<<<<<< + * Dynamic_Callables_Cython p_dynamic_callables, + * bint calc_grad_log_likelihood=False, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_1_kalman_prediction_step_SVD_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_kalman_prediction_step_SVD_Cyth, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":649 + * + * @cython.boundscheck(False) + * def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, + * np.ndarray[DTYPE_t, ndim=2] measurement, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_3_kalman_update_step_SVD_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_kalman_update_step_SVD_Cython, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":875 + * + * @cython.boundscheck(False) + * def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, # <<<<<<<<<<<<<< + * Measurement_Callables_Cython p_measurement_callables, X, Y, + * np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + */ + __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3GPy_6models_18state_space_cython_5_cont_discr_kalman_filter_raw_Cython, NULL, __pyx_n_s_GPy_models_state_space_cython); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_cont_discr_kalman_filter_raw_Cy, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "GPy/models/state_space_cython.pyx":1 + * # -*- coding: utf-8 -*- # <<<<<<<<<<<<<< + * """ + * Contains some cython code for state space modelling. + */ + __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); + if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "../../../../../../../Work/anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 + * arr.base = baseptr + * + * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< + * if arr.base is NULL: + * return None + */ + + /*--- Wrapped vars code ---*/ + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + if (__pyx_m) { + if (__pyx_d) { + __Pyx_AddTraceback("init GPy.models.state_space_cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + } + Py_DECREF(__pyx_m); __pyx_m = 0; + } else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_ImportError, "init GPy.models.state_space_cython"); + } + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + #if PY_MAJOR_VERSION < 3 + return; + #else + return __pyx_m; + #endif +} + +/* --- Runtime support code --- */ +#if CYTHON_REFNANNY +static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { + PyObject *m = NULL, *p = NULL; + void *r = NULL; + m = PyImport_ImportModule((char *)modname); + if (!m) goto end; + p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); + if (!p) goto end; + r = PyLong_AsVoidPtr(p); +end: + Py_XDECREF(p); + Py_XDECREF(m); + return (__Pyx_RefNannyAPIStruct *)r; +} +#endif + +static PyObject *__Pyx_GetBuiltinName(PyObject *name) { + PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); + if (unlikely(!result)) { + PyErr_Format(PyExc_NameError, +#if PY_MAJOR_VERSION >= 3 + "name '%U' is not defined", name); +#else + "name '%.200s' is not defined", PyString_AS_STRING(name)); +#endif + } + return result; +} + +static CYTHON_INLINE int __Pyx_IsLittleEndian(void) { + unsigned int n = 1; + return *(unsigned char*)(&n) != 0; +} +static void __Pyx_BufFmt_Init(__Pyx_BufFmt_Context* ctx, + __Pyx_BufFmt_StackElem* stack, + __Pyx_TypeInfo* type) { + stack[0].field = &ctx->root; + stack[0].parent_offset = 0; + ctx->root.type = type; + ctx->root.name = "buffer dtype"; + ctx->root.offset = 0; + ctx->head = stack; + ctx->head->field = &ctx->root; + ctx->fmt_offset = 0; + ctx->head->parent_offset = 0; + ctx->new_packmode = '@'; + ctx->enc_packmode = '@'; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->is_complex = 0; + ctx->is_valid_array = 0; + ctx->struct_alignment = 0; + while (type->typegroup == 'S') { + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = 0; + type = type->fields->type; + } +} +static int __Pyx_BufFmt_ParseNumber(const char** ts) { + int count; + const char* t = *ts; + if (*t < '0' || *t > '9') { + return -1; + } else { + count = *t++ - '0'; + while (*t >= '0' && *t < '9') { + count *= 10; + count += *t++ - '0'; + } + } + *ts = t; + return count; +} +static int __Pyx_BufFmt_ExpectNumber(const char **ts) { + int number = __Pyx_BufFmt_ParseNumber(ts); + if (number == -1) + PyErr_Format(PyExc_ValueError,\ + "Does not understand character buffer dtype format string ('%c')", **ts); + return number; +} +static void __Pyx_BufFmt_RaiseUnexpectedChar(char ch) { + PyErr_Format(PyExc_ValueError, + "Unexpected format string character: '%c'", ch); +} +static const char* __Pyx_BufFmt_DescribeTypeChar(char ch, int is_complex) { + switch (ch) { + case 'c': return "'char'"; + case 'b': return "'signed char'"; + case 'B': return "'unsigned char'"; + case 'h': return "'short'"; + case 'H': return "'unsigned short'"; + case 'i': return "'int'"; + case 'I': return "'unsigned int'"; + case 'l': return "'long'"; + case 'L': return "'unsigned long'"; + case 'q': return "'long long'"; + case 'Q': return "'unsigned long long'"; + case 'f': return (is_complex ? "'complex float'" : "'float'"); + case 'd': return (is_complex ? "'complex double'" : "'double'"); + case 'g': return (is_complex ? "'complex long double'" : "'long double'"); + case 'T': return "a struct"; + case 'O': return "Python object"; + case 'P': return "a pointer"; + case 's': case 'p': return "a string"; + case 0: return "end"; + default: return "unparseable format string"; + } +} +static size_t __Pyx_BufFmt_TypeCharToStandardSize(char ch, int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return 2; + case 'i': case 'I': case 'l': case 'L': return 4; + case 'q': case 'Q': return 8; + case 'f': return (is_complex ? 8 : 4); + case 'd': return (is_complex ? 16 : 8); + case 'g': { + PyErr_SetString(PyExc_ValueError, "Python does not define a standard format string size for long double ('g').."); + return 0; + } + case 'O': case 'P': return sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static size_t __Pyx_BufFmt_TypeCharToNativeSize(char ch, int is_complex) { + switch (ch) { + case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(short); + case 'i': case 'I': return sizeof(int); + case 'l': case 'L': return sizeof(long); + #ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(PY_LONG_LONG); + #endif + case 'f': return sizeof(float) * (is_complex ? 2 : 1); + case 'd': return sizeof(double) * (is_complex ? 2 : 1); + case 'g': return sizeof(long double) * (is_complex ? 2 : 1); + case 'O': case 'P': return sizeof(void*); + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +typedef struct { char c; short x; } __Pyx_st_short; +typedef struct { char c; int x; } __Pyx_st_int; +typedef struct { char c; long x; } __Pyx_st_long; +typedef struct { char c; float x; } __Pyx_st_float; +typedef struct { char c; double x; } __Pyx_st_double; +typedef struct { char c; long double x; } __Pyx_st_longdouble; +typedef struct { char c; void *x; } __Pyx_st_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { char c; PY_LONG_LONG x; } __Pyx_st_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToAlignment(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_st_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_st_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_st_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_st_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_st_float) - sizeof(float); + case 'd': return sizeof(__Pyx_st_double) - sizeof(double); + case 'g': return sizeof(__Pyx_st_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_st_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +/* These are for computing the padding at the end of the struct to align + on the first member of the struct. This will probably the same as above, + but we don't have any guarantees. + */ +typedef struct { short x; char c; } __Pyx_pad_short; +typedef struct { int x; char c; } __Pyx_pad_int; +typedef struct { long x; char c; } __Pyx_pad_long; +typedef struct { float x; char c; } __Pyx_pad_float; +typedef struct { double x; char c; } __Pyx_pad_double; +typedef struct { long double x; char c; } __Pyx_pad_longdouble; +typedef struct { void *x; char c; } __Pyx_pad_void_p; +#ifdef HAVE_LONG_LONG +typedef struct { PY_LONG_LONG x; char c; } __Pyx_pad_longlong; +#endif +static size_t __Pyx_BufFmt_TypeCharToPadding(char ch, CYTHON_UNUSED int is_complex) { + switch (ch) { + case '?': case 'c': case 'b': case 'B': case 's': case 'p': return 1; + case 'h': case 'H': return sizeof(__Pyx_pad_short) - sizeof(short); + case 'i': case 'I': return sizeof(__Pyx_pad_int) - sizeof(int); + case 'l': case 'L': return sizeof(__Pyx_pad_long) - sizeof(long); +#ifdef HAVE_LONG_LONG + case 'q': case 'Q': return sizeof(__Pyx_pad_longlong) - sizeof(PY_LONG_LONG); +#endif + case 'f': return sizeof(__Pyx_pad_float) - sizeof(float); + case 'd': return sizeof(__Pyx_pad_double) - sizeof(double); + case 'g': return sizeof(__Pyx_pad_longdouble) - sizeof(long double); + case 'P': case 'O': return sizeof(__Pyx_pad_void_p) - sizeof(void*); + default: + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } +} +static char __Pyx_BufFmt_TypeCharToGroup(char ch, int is_complex) { + switch (ch) { + case 'c': + return 'H'; + case 'b': case 'h': case 'i': + case 'l': case 'q': case 's': case 'p': + return 'I'; + case 'B': case 'H': case 'I': case 'L': case 'Q': + return 'U'; + case 'f': case 'd': case 'g': + return (is_complex ? 'C' : 'R'); + case 'O': + return 'O'; + case 'P': + return 'P'; + default: { + __Pyx_BufFmt_RaiseUnexpectedChar(ch); + return 0; + } + } +} +static void __Pyx_BufFmt_RaiseExpected(__Pyx_BufFmt_Context* ctx) { + if (ctx->head == NULL || ctx->head->field == &ctx->root) { + const char* expected; + const char* quote; + if (ctx->head == NULL) { + expected = "end"; + quote = ""; + } else { + expected = ctx->head->field->type->name; + quote = "'"; + } + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected %s%s%s but got %s", + quote, expected, quote, + __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex)); + } else { + __Pyx_StructField* field = ctx->head->field; + __Pyx_StructField* parent = (ctx->head - 1)->field; + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch, expected '%s' but got %s in '%s.%s'", + field->type->name, __Pyx_BufFmt_DescribeTypeChar(ctx->enc_type, ctx->is_complex), + parent->type->name, field->name); + } +} +static int __Pyx_BufFmt_ProcessTypeChunk(__Pyx_BufFmt_Context* ctx) { + char group; + size_t size, offset, arraysize = 1; + if (ctx->enc_type == 0) return 0; + if (ctx->head->field->type->arraysize[0]) { + int i, ndim = 0; + if (ctx->enc_type == 's' || ctx->enc_type == 'p') { + ctx->is_valid_array = ctx->head->field->type->ndim == 1; + ndim = 1; + if (ctx->enc_count != ctx->head->field->type->arraysize[0]) { + PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %zu", + ctx->head->field->type->arraysize[0], ctx->enc_count); + return -1; + } + } + if (!ctx->is_valid_array) { + PyErr_Format(PyExc_ValueError, "Expected %d dimensions, got %d", + ctx->head->field->type->ndim, ndim); + return -1; + } + for (i = 0; i < ctx->head->field->type->ndim; i++) { + arraysize *= ctx->head->field->type->arraysize[i]; + } + ctx->is_valid_array = 0; + ctx->enc_count = 1; + } + group = __Pyx_BufFmt_TypeCharToGroup(ctx->enc_type, ctx->is_complex); + do { + __Pyx_StructField* field = ctx->head->field; + __Pyx_TypeInfo* type = field->type; + if (ctx->enc_packmode == '@' || ctx->enc_packmode == '^') { + size = __Pyx_BufFmt_TypeCharToNativeSize(ctx->enc_type, ctx->is_complex); + } else { + size = __Pyx_BufFmt_TypeCharToStandardSize(ctx->enc_type, ctx->is_complex); + } + if (ctx->enc_packmode == '@') { + size_t align_at = __Pyx_BufFmt_TypeCharToAlignment(ctx->enc_type, ctx->is_complex); + size_t align_mod_offset; + if (align_at == 0) return -1; + align_mod_offset = ctx->fmt_offset % align_at; + if (align_mod_offset > 0) ctx->fmt_offset += align_at - align_mod_offset; + if (ctx->struct_alignment == 0) + ctx->struct_alignment = __Pyx_BufFmt_TypeCharToPadding(ctx->enc_type, + ctx->is_complex); + } + if (type->size != size || type->typegroup != group) { + if (type->typegroup == 'C' && type->fields != NULL) { + size_t parent_offset = ctx->head->parent_offset + field->offset; + ++ctx->head; + ctx->head->field = type->fields; + ctx->head->parent_offset = parent_offset; + continue; + } + if ((type->typegroup == 'H' || group == 'H') && type->size == size) { + } else { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + } + offset = ctx->head->parent_offset + field->offset; + if (ctx->fmt_offset != offset) { + PyErr_Format(PyExc_ValueError, + "Buffer dtype mismatch; next field is at offset %" CYTHON_FORMAT_SSIZE_T "d but %" CYTHON_FORMAT_SSIZE_T "d expected", + (Py_ssize_t)ctx->fmt_offset, (Py_ssize_t)offset); + return -1; + } + ctx->fmt_offset += size; + if (arraysize) + ctx->fmt_offset += (arraysize - 1) * size; + --ctx->enc_count; + while (1) { + if (field == &ctx->root) { + ctx->head = NULL; + if (ctx->enc_count != 0) { + __Pyx_BufFmt_RaiseExpected(ctx); + return -1; + } + break; + } + ctx->head->field = ++field; + if (field->type == NULL) { + --ctx->head; + field = ctx->head->field; + continue; + } else if (field->type->typegroup == 'S') { + size_t parent_offset = ctx->head->parent_offset + field->offset; + if (field->type->fields->type == NULL) continue; + field = field->type->fields; + ++ctx->head; + ctx->head->field = field; + ctx->head->parent_offset = parent_offset; + break; + } else { + break; + } + } + } while (ctx->enc_count); + ctx->enc_type = 0; + ctx->is_complex = 0; + return 0; +} +static CYTHON_INLINE PyObject * +__pyx_buffmt_parse_array(__Pyx_BufFmt_Context* ctx, const char** tsp) +{ + const char *ts = *tsp; + int i = 0, number; + int ndim = ctx->head->field->type->ndim; +; + ++ts; + if (ctx->new_count != 1) { + PyErr_SetString(PyExc_ValueError, + "Cannot handle repeated arrays in format string"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + while (*ts && *ts != ')') { + switch (*ts) { + case ' ': case '\f': case '\r': case '\n': case '\t': case '\v': continue; + default: break; + } + number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + if (i < ndim && (size_t) number != ctx->head->field->type->arraysize[i]) + return PyErr_Format(PyExc_ValueError, + "Expected a dimension of size %zu, got %d", + ctx->head->field->type->arraysize[i], number); + if (*ts != ',' && *ts != ')') + return PyErr_Format(PyExc_ValueError, + "Expected a comma in format string, got '%c'", *ts); + if (*ts == ',') ts++; + i++; + } + if (i != ndim) + return PyErr_Format(PyExc_ValueError, "Expected %d dimension(s), got %d", + ctx->head->field->type->ndim, i); + if (!*ts) { + PyErr_SetString(PyExc_ValueError, + "Unexpected end of format string, expected ')'"); + return NULL; + } + ctx->is_valid_array = 1; + ctx->new_count = 1; + *tsp = ++ts; + return Py_None; +} +static const char* __Pyx_BufFmt_CheckString(__Pyx_BufFmt_Context* ctx, const char* ts) { + int got_Z = 0; + while (1) { + switch(*ts) { + case 0: + if (ctx->enc_type != 0 && ctx->head == NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + if (ctx->head != NULL) { + __Pyx_BufFmt_RaiseExpected(ctx); + return NULL; + } + return ts; + case ' ': + case '\r': + case '\n': + ++ts; + break; + case '<': + if (!__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Little-endian buffer not supported on big-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '>': + case '!': + if (__Pyx_IsLittleEndian()) { + PyErr_SetString(PyExc_ValueError, "Big-endian buffer not supported on little-endian compiler"); + return NULL; + } + ctx->new_packmode = '='; + ++ts; + break; + case '=': + case '@': + case '^': + ctx->new_packmode = *ts++; + break; + case 'T': + { + const char* ts_after_sub; + size_t i, struct_count = ctx->new_count; + size_t struct_alignment = ctx->struct_alignment; + ctx->new_count = 1; + ++ts; + if (*ts != '{') { + PyErr_SetString(PyExc_ValueError, "Buffer acquisition: Expected '{' after 'T'"); + return NULL; + } + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + ctx->enc_count = 0; + ctx->struct_alignment = 0; + ++ts; + ts_after_sub = ts; + for (i = 0; i != struct_count; ++i) { + ts_after_sub = __Pyx_BufFmt_CheckString(ctx, ts); + if (!ts_after_sub) return NULL; + } + ts = ts_after_sub; + if (struct_alignment) ctx->struct_alignment = struct_alignment; + } + break; + case '}': + { + size_t alignment = ctx->struct_alignment; + ++ts; + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_type = 0; + if (alignment && ctx->fmt_offset % alignment) { + ctx->fmt_offset += alignment - (ctx->fmt_offset % alignment); + } + } + return ts; + case 'x': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->fmt_offset += ctx->new_count; + ctx->new_count = 1; + ctx->enc_count = 0; + ctx->enc_type = 0; + ctx->enc_packmode = ctx->new_packmode; + ++ts; + break; + case 'Z': + got_Z = 1; + ++ts; + if (*ts != 'f' && *ts != 'd' && *ts != 'g') { + __Pyx_BufFmt_RaiseUnexpectedChar('Z'); + return NULL; + } + case 'c': case 'b': case 'B': case 'h': case 'H': case 'i': case 'I': + case 'l': case 'L': case 'q': case 'Q': + case 'f': case 'd': case 'g': + case 'O': case 'p': + if (ctx->enc_type == *ts && got_Z == ctx->is_complex && + ctx->enc_packmode == ctx->new_packmode) { + ctx->enc_count += ctx->new_count; + ctx->new_count = 1; + got_Z = 0; + ++ts; + break; + } + case 's': + if (__Pyx_BufFmt_ProcessTypeChunk(ctx) == -1) return NULL; + ctx->enc_count = ctx->new_count; + ctx->enc_packmode = ctx->new_packmode; + ctx->enc_type = *ts; + ctx->is_complex = got_Z; + ++ts; + ctx->new_count = 1; + got_Z = 0; + break; + case ':': + ++ts; + while(*ts != ':') ++ts; + ++ts; + break; + case '(': + if (!__pyx_buffmt_parse_array(ctx, &ts)) return NULL; + break; + default: + { + int number = __Pyx_BufFmt_ExpectNumber(&ts); + if (number == -1) return NULL; + ctx->new_count = (size_t)number; + } + } + } +} +static CYTHON_INLINE void __Pyx_ZeroBuffer(Py_buffer* buf) { + buf->buf = NULL; + buf->obj = NULL; + buf->strides = __Pyx_zeros; + buf->shape = __Pyx_zeros; + buf->suboffsets = __Pyx_minusones; +} +static CYTHON_INLINE int __Pyx_GetBufferAndValidate( + Py_buffer* buf, PyObject* obj, __Pyx_TypeInfo* dtype, int flags, + int nd, int cast, __Pyx_BufFmt_StackElem* stack) +{ + if (obj == Py_None || obj == NULL) { + __Pyx_ZeroBuffer(buf); + return 0; + } + buf->buf = NULL; + if (__Pyx_GetBuffer(obj, buf, flags) == -1) goto fail; + if (buf->ndim != nd) { + PyErr_Format(PyExc_ValueError, + "Buffer has wrong number of dimensions (expected %d, got %d)", + nd, buf->ndim); + goto fail; + } + if (!cast) { + __Pyx_BufFmt_Context ctx; + __Pyx_BufFmt_Init(&ctx, stack, dtype); + if (!__Pyx_BufFmt_CheckString(&ctx, buf->format)) goto fail; + } + if ((unsigned)buf->itemsize != dtype->size) { + PyErr_Format(PyExc_ValueError, + "Item size of buffer (%" CYTHON_FORMAT_SSIZE_T "d byte%s) does not match size of '%s' (%" CYTHON_FORMAT_SSIZE_T "d byte%s)", + buf->itemsize, (buf->itemsize > 1) ? "s" : "", + dtype->name, (Py_ssize_t)dtype->size, (dtype->size > 1) ? "s" : ""); + goto fail; + } + if (buf->suboffsets == NULL) buf->suboffsets = __Pyx_minusones; + return 0; +fail:; + __Pyx_ZeroBuffer(buf); + return -1; +} +static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info) { + if (info->buf == NULL) return; + if (info->suboffsets == __Pyx_minusones) info->suboffsets = NULL; + __Pyx_ReleaseBuffer(info); +} + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyObject *result; + ternaryfunc call = func->ob_type->tp_call; + if (unlikely(!call)) + return PyObject_Call(func, arg, kw); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = (*call)(func, arg, kw); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyThreadState *tstate = PyThreadState_GET(); + tmp_type = tstate->curexc_type; + tmp_value = tstate->curexc_value; + tmp_tb = tstate->curexc_traceback; + tstate->curexc_type = type; + tstate->curexc_value = value; + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_type); + Py_XDECREF(tmp_value); + Py_XDECREF(tmp_tb); +#else + PyErr_Restore(type, value, tb); +#endif +} +static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + *type = tstate->curexc_type; + *value = tstate->curexc_value; + *tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; +#else + PyErr_Fetch(type, value, tb); +#endif +} + +#if PY_MAJOR_VERSION < 3 +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, + CYTHON_UNUSED PyObject *cause) { + Py_XINCREF(type); + if (!value || value == Py_None) + value = NULL; + else + Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } + } + if (PyType_Check(type)) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto raise_error; + } + value = type; + type = (PyObject*) Py_TYPE(type); + Py_INCREF(type); + if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto raise_error; + } + } + __Pyx_ErrRestore(type, value, tb); + return; +raise_error: + Py_XDECREF(value); + Py_XDECREF(type); + Py_XDECREF(tb); + return; +} +#else +static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; + if (tb == Py_None) { + tb = 0; + } else if (tb && !PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto bad; + } + if (value == Py_None) + value = 0; + if (PyExceptionInstance_Check(type)) { + if (value) { + PyErr_SetString(PyExc_TypeError, + "instance exception may not have a separate value"); + goto bad; + } + value = type; + type = (PyObject*) Py_TYPE(value); + } else if (PyExceptionClass_Check(type)) { + PyObject *instance_class = NULL; + if (value && PyExceptionInstance_Check(value)) { + instance_class = (PyObject*) Py_TYPE(value); + if (instance_class != type) { + if (PyObject_IsSubclass(instance_class, type)) { + type = instance_class; + } else { + instance_class = NULL; + } + } + } + if (!instance_class) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyObject_Call(type, args, NULL); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } + } else { + PyErr_SetString(PyExc_TypeError, + "raise: exception class must be a subclass of BaseException"); + goto bad; + } +#if PY_VERSION_HEX >= 0x03030000 + if (cause) { +#else + if (cause && cause != Py_None) { +#endif + PyObject *fixed_cause; + if (cause == Py_None) { + fixed_cause = NULL; + } else if (PyExceptionClass_Check(cause)) { + fixed_cause = PyObject_CallObject(cause, NULL); + if (fixed_cause == NULL) + goto bad; + } else if (PyExceptionInstance_Check(cause)) { + fixed_cause = cause; + Py_INCREF(fixed_cause); + } else { + PyErr_SetString(PyExc_TypeError, + "exception causes must derive from " + "BaseException"); + goto bad; + } + PyException_SetCause(value, fixed_cause); + } + PyErr_SetObject(type, value); + if (tb) { +#if CYTHON_COMPILING_IN_PYPY + PyObject *tmp_type, *tmp_value, *tmp_tb; + PyErr_Fetch(tmp_type, tmp_value, tmp_tb); + Py_INCREF(tb); + PyErr_Restore(tmp_type, tmp_value, tb); + Py_XDECREF(tmp_tb); +#else + PyThreadState *tstate = PyThreadState_GET(); + PyObject* tmp_tb = tstate->curexc_traceback; + if (tb != tmp_tb) { + Py_INCREF(tb); + tstate->curexc_traceback = tb; + Py_XDECREF(tmp_tb); + } +#endif + } +bad: + Py_XDECREF(owned_instance); + return; +} +#endif + +static void __Pyx_RaiseArgtupleInvalid( + const char* func_name, + int exact, + Py_ssize_t num_min, + Py_ssize_t num_max, + Py_ssize_t num_found) +{ + Py_ssize_t num_expected; + const char *more_or_less; + if (num_found < num_min) { + num_expected = num_min; + more_or_less = "at least"; + } else { + num_expected = num_max; + more_or_less = "at most"; + } + if (exact) { + more_or_less = "exactly"; + } + PyErr_Format(PyExc_TypeError, + "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)", + func_name, more_or_less, num_expected, + (num_expected == 1) ? "" : "s", num_found); +} + +static void __Pyx_RaiseDoubleKeywordsError( + const char* func_name, + PyObject* kw_name) +{ + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION >= 3 + "%s() got multiple values for keyword argument '%U'", func_name, kw_name); + #else + "%s() got multiple values for keyword argument '%s'", func_name, + PyString_AsString(kw_name)); + #endif +} + +static int __Pyx_ParseOptionalKeywords( + PyObject *kwds, + PyObject **argnames[], + PyObject *kwds2, + PyObject *values[], + Py_ssize_t num_pos_args, + const char* function_name) +{ + PyObject *key = 0, *value = 0; + Py_ssize_t pos = 0; + PyObject*** name; + PyObject*** first_kw_arg = argnames + num_pos_args; + while (PyDict_Next(kwds, &pos, &key, &value)) { + name = first_kw_arg; + while (*name && (**name != key)) name++; + if (*name) { + values[name-argnames] = value; + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; + } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; + } + } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; + } + } + return 0; +arg_passed_twice: + __Pyx_RaiseDoubleKeywordsError(function_name, key); + goto bad; +invalid_keyword_type: + PyErr_Format(PyExc_TypeError, + "%.200s() keywords must be strings", function_name); + goto bad; +invalid_keyword: + PyErr_Format(PyExc_TypeError, + #if PY_MAJOR_VERSION < 3 + "%.200s() got an unexpected keyword argument '%.200s'", + function_name, PyString_AsString(key)); + #else + "%s() got an unexpected keyword argument '%U'", + function_name, key); + #endif +bad: + return -1; +} + +static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) { + PyErr_Format(PyExc_TypeError, + "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", + name, type->tp_name, Py_TYPE(obj)->tp_name); +} +static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, + const char *name, int exact) +{ + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (none_allowed && obj == Py_None) return 1; + else if (exact) { + if (likely(Py_TYPE(obj) == type)) return 1; + #if PY_MAJOR_VERSION == 2 + else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; + #endif + } + else { + if (likely(PyObject_TypeCheck(obj, type))) return 1; + } + __Pyx_RaiseArgumentTypeInvalid(name, obj, type); + return 0; +} + +#if CYTHON_COMPILING_IN_CPYTHON +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) { + PyObject *self, *result; + PyCFunction cfunc; + cfunc = PyCFunction_GET_FUNCTION(func); + self = PyCFunction_GET_SELF(func); + if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object"))) + return NULL; + result = cfunc(self, arg); + Py_LeaveRecursiveCall(); + if (unlikely(!result) && unlikely(!PyErr_Occurred())) { + PyErr_SetString( + PyExc_SystemError, + "NULL result without error in PyObject_Call"); + } + return result; +} +#endif + +#if CYTHON_COMPILING_IN_CPYTHON +static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject *result; + PyObject *args = PyTuple_New(1); + if (unlikely(!args)) return NULL; + Py_INCREF(arg); + PyTuple_SET_ITEM(args, 0, arg); + result = __Pyx_PyObject_Call(func, args, NULL); + Py_DECREF(args); + return result; +} +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { +#ifdef __Pyx_CyFunction_USED + if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) { +#else + if (likely(PyCFunction_Check(func))) { +#endif + if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { + return __Pyx_PyObject_CallMethO(func, arg); + } + } + return __Pyx__PyObject_CallOneArg(func, arg); +} +#else +static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { + PyObject* args = PyTuple_Pack(1, arg); + return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL; +} +#endif + +static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { + PyObject *result; +#if CYTHON_COMPILING_IN_CPYTHON + result = PyDict_GetItem(__pyx_d, name); + if (likely(result)) { + Py_INCREF(result); + } else { +#else + result = PyObject_GetItem(__pyx_d, name); + if (!result) { + PyErr_Clear(); +#endif + result = __Pyx_GetBuiltinName(name); + } + return result; +} + +static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { + if (unlikely(!type)) { + PyErr_SetString(PyExc_SystemError, "Missing type object"); + return 0; + } + if (likely(PyObject_TypeCheck(obj, type))) + return 1; + PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s", + Py_TYPE(obj)->tp_name, type->tp_name); + return 0; +} + +static void __Pyx_RaiseBufferFallbackError(void) { + PyErr_SetString(PyExc_ValueError, + "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!"); +} + +static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { + PyErr_Format(PyExc_ValueError, + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); +} + +static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { + PyErr_Format(PyExc_ValueError, + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", + index, (index == 1) ? "" : "s"); +} + +static CYTHON_INLINE int __Pyx_IterFinish(void) { +#if CYTHON_COMPILING_IN_CPYTHON + PyThreadState *tstate = PyThreadState_GET(); + PyObject* exc_type = tstate->curexc_type; + if (unlikely(exc_type)) { + if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) { + PyObject *exc_value, *exc_tb; + exc_value = tstate->curexc_value; + exc_tb = tstate->curexc_traceback; + tstate->curexc_type = 0; + tstate->curexc_value = 0; + tstate->curexc_traceback = 0; + Py_DECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } else { + return -1; + } + } + return 0; +#else + if (unlikely(PyErr_Occurred())) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { + PyErr_Clear(); + return 0; + } else { + return -1; + } + } + return 0; +#endif +} + +static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { + if (unlikely(retval)) { + Py_DECREF(retval); + __Pyx_RaiseTooManyValuesError(expected); + return -1; + } else { + return __Pyx_IterFinish(); + } + return 0; +} + +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { + PyObject *r; + if (!j) return NULL; + r = PyObject_GetItem(o, j); + Py_DECREF(j); + return r; +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) { + PyObject *r = PyList_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, + int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, i); + Py_INCREF(r); + return r; + } + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +#else + return PySequence_GetItem(o, i); +#endif +} +static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, + int is_list, int wraparound, int boundscheck) { +#if CYTHON_COMPILING_IN_CPYTHON + if (is_list || PyList_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); + if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { + PyObject *r = PyList_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } + else if (PyTuple_CheckExact(o)) { + Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); + if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { + PyObject *r = PyTuple_GET_ITEM(o, n); + Py_INCREF(r); + return r; + } + } else { + PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; + if (likely(m && m->sq_item)) { + if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { + Py_ssize_t l = m->sq_length(o); + if (likely(l >= 0)) { + i += l; + } else { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) + PyErr_Clear(); + else + return NULL; + } + } + return m->sq_item(o, i); + } + } +#else + if (is_list || PySequence_Check(o)) { + return PySequence_GetItem(o, i); + } +#endif + return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); +} + +static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) { + PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); +} + +static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) { + PyTypeObject* type = Py_TYPE(obj); + while (type && type->tp_traverse != current_tp_traverse) + type = type->tp_base; + while (type && type->tp_traverse == current_tp_traverse) + type = type->tp_base; + if (type && type->tp_traverse) + return type->tp_traverse(obj, v, a); + return 0; +} + +static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) { + PyTypeObject* type = Py_TYPE(obj); + while (type && type->tp_clear != current_tp_clear) + type = type->tp_base; + while (type && type->tp_clear == current_tp_clear) + type = type->tp_base; + if (type && type->tp_clear) + type->tp_clear(obj); +} + +static int __Pyx_SetVtable(PyObject *dict, void *vtable) { +#if PY_VERSION_HEX >= 0x02070000 + PyObject *ob = PyCapsule_New(vtable, 0, 0); +#else + PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); +#endif + if (!ob) + goto bad; + if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) + goto bad; + Py_DECREF(ob); + return 0; +bad: + Py_XDECREF(ob); + return -1; +} + +static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) { + int start = 0, mid = 0, end = count - 1; + if (end >= 0 && code_line > entries[end].code_line) { + return count; + } + while (start < end) { + mid = (start + end) / 2; + if (code_line < entries[mid].code_line) { + end = mid; + } else if (code_line > entries[mid].code_line) { + start = mid + 1; + } else { + return mid; + } + } + if (code_line <= entries[mid].code_line) { + return mid; + } else { + return mid + 1; + } +} +static PyCodeObject *__pyx_find_code_object(int code_line) { + PyCodeObject* code_object; + int pos; + if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { + return NULL; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { + return NULL; + } + code_object = __pyx_code_cache.entries[pos].code_object; + Py_INCREF(code_object); + return code_object; +} +static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { + int pos, i; + __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; + if (unlikely(!code_line)) { + return; + } + if (unlikely(!entries)) { + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); + if (likely(entries)) { + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = 64; + __pyx_code_cache.count = 1; + entries[0].code_line = code_line; + entries[0].code_object = code_object; + Py_INCREF(code_object); + } + return; + } + pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); + if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { + PyCodeObject* tmp = entries[pos].code_object; + entries[pos].code_object = code_object; + Py_DECREF(tmp); + return; + } + if (__pyx_code_cache.count == __pyx_code_cache.max_count) { + int new_max = __pyx_code_cache.max_count + 64; + entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( + __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); + if (unlikely(!entries)) { + return; + } + __pyx_code_cache.entries = entries; + __pyx_code_cache.max_count = new_max; + } + for (i=__pyx_code_cache.count; i>pos; i--) { + entries[i] = entries[i-1]; + } + entries[pos].code_line = code_line; + entries[pos].code_object = code_object; + __pyx_code_cache.count++; + Py_INCREF(code_object); +} + +#include "compile.h" +#include "frameobject.h" +#include "traceback.h" +static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( + const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyObject *py_srcfile = 0; + PyObject *py_funcname = 0; + #if PY_MAJOR_VERSION < 3 + py_srcfile = PyString_FromString(filename); + #else + py_srcfile = PyUnicode_FromString(filename); + #endif + if (!py_srcfile) goto bad; + if (c_line) { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #else + py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); + #endif + } + else { + #if PY_MAJOR_VERSION < 3 + py_funcname = PyString_FromString(funcname); + #else + py_funcname = PyUnicode_FromString(funcname); + #endif + } + if (!py_funcname) goto bad; + py_code = __Pyx_PyCode_New( + 0, + 0, + 0, + 0, + 0, + __pyx_empty_bytes, /*PyObject *code,*/ + __pyx_empty_tuple, /*PyObject *consts,*/ + __pyx_empty_tuple, /*PyObject *names,*/ + __pyx_empty_tuple, /*PyObject *varnames,*/ + __pyx_empty_tuple, /*PyObject *freevars,*/ + __pyx_empty_tuple, /*PyObject *cellvars,*/ + py_srcfile, /*PyObject *filename,*/ + py_funcname, /*PyObject *name,*/ + py_line, + __pyx_empty_bytes /*PyObject *lnotab*/ + ); + Py_DECREF(py_srcfile); + Py_DECREF(py_funcname); + return py_code; +bad: + Py_XDECREF(py_srcfile); + Py_XDECREF(py_funcname); + return NULL; +} +static void __Pyx_AddTraceback(const char *funcname, int c_line, + int py_line, const char *filename) { + PyCodeObject *py_code = 0; + PyFrameObject *py_frame = 0; + py_code = __pyx_find_code_object(c_line ? c_line : py_line); + if (!py_code) { + py_code = __Pyx_CreateCodeObjectForTraceback( + funcname, c_line, py_line, filename); + if (!py_code) goto bad; + __pyx_insert_code_object(c_line ? c_line : py_line, py_code); + } + py_frame = PyFrame_New( + PyThreadState_GET(), /*PyThreadState *tstate,*/ + py_code, /*PyCodeObject *code,*/ + __pyx_d, /*PyObject *globals,*/ + 0 /*PyObject *locals*/ + ); + if (!py_frame) goto bad; + py_frame->f_lineno = py_line; + PyTraceBack_Here(py_frame); +bad: + Py_XDECREF(py_code); + Py_XDECREF(py_frame); +} + +#if PY_MAJOR_VERSION < 3 +static int __Pyx_GetBuffer(PyObject *obj, Py_buffer *view, int flags) { + if (PyObject_CheckBuffer(obj)) return PyObject_GetBuffer(obj, view, flags); + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) return __pyx_pw_5numpy_7ndarray_1__getbuffer__(obj, view, flags); + PyErr_Format(PyExc_TypeError, "'%.200s' does not have the buffer interface", Py_TYPE(obj)->tp_name); + return -1; +} +static void __Pyx_ReleaseBuffer(Py_buffer *view) { + PyObject *obj = view->obj; + if (!obj) return; + if (PyObject_CheckBuffer(obj)) { + PyBuffer_Release(view); + return; + } + if (PyObject_TypeCheck(obj, __pyx_ptype_5numpy_ndarray)) { __pyx_pw_5numpy_7ndarray_3__releasebuffer__(obj, view); return; } + Py_DECREF(obj); + view->obj = NULL; +} +#endif + + + static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { + PyObject *empty_list = 0; + PyObject *module = 0; + PyObject *global_dict = 0; + PyObject *empty_dict = 0; + PyObject *list; + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_import; + py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); + if (!py_import) + goto bad; + #endif + if (from_list) + list = from_list; + else { + empty_list = PyList_New(0); + if (!empty_list) + goto bad; + list = empty_list; + } + global_dict = PyModule_GetDict(__pyx_m); + if (!global_dict) + goto bad; + empty_dict = PyDict_New(); + if (!empty_dict) + goto bad; + { + #if PY_MAJOR_VERSION >= 3 + if (level == -1) { + if (strchr(__Pyx_MODULE_NAME, '.')) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(1); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, 1); + #endif + if (!module) { + if (!PyErr_ExceptionMatches(PyExc_ImportError)) + goto bad; + PyErr_Clear(); + } + } + level = 0; + } + #endif + if (!module) { + #if PY_VERSION_HEX < 0x03030000 + PyObject *py_level = PyInt_FromLong(level); + if (!py_level) + goto bad; + module = PyObject_CallFunctionObjArgs(py_import, + name, global_dict, empty_dict, list, py_level, NULL); + Py_DECREF(py_level); + #else + module = PyImport_ImportModuleLevelObject( + name, global_dict, empty_dict, list, level); + #endif + } + } +bad: + #if PY_VERSION_HEX < 0x03030000 + Py_XDECREF(py_import); + #endif + Py_XDECREF(empty_list); + Py_XDECREF(empty_dict); + return module; +} + +#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value) \ + { \ + func_type value = func_value; \ + if (sizeof(target_type) < sizeof(func_type)) { \ + if (unlikely(value != (func_type) (target_type) value)) { \ + func_type zero = 0; \ + if (is_unsigned && unlikely(value < zero)) \ + goto raise_neg_overflow; \ + else \ + goto raise_overflow; \ + } \ + } \ + return (target_type) value; \ + } + +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + #include "longintrepr.h" + #endif +#endif + +static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { + const int neg_one = (int) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(int) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (int) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]); + } + #endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } + if (sizeof(int) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(int) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: __PYX_VERIFY_RETURN_INT(int, digit, +(((PyLongObject*)x)->ob_digit[0])); + case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]); + } + #endif +#endif + if (sizeof(int) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x)) + } else if (sizeof(int) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x)) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + int val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (int) -1; + } + } else { + int val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (int) -1; + val = __Pyx_PyInt_As_int(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to int"); + return (int) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to int"); + return (int) -1; +} + +static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { + const long neg_one = (long) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_Check(x))) { + if (sizeof(long) < sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) + } else { + long val = PyInt_AS_LONG(x); + if (is_unsigned && unlikely(val < 0)) { + goto raise_neg_overflow; + } + return (long) val; + } + } else +#endif + if (likely(PyLong_Check(x))) { + if (is_unsigned) { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]); + } + #endif +#endif + if (unlikely(Py_SIZE(x) < 0)) { + goto raise_neg_overflow; + } + if (sizeof(long) <= sizeof(unsigned long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x)) + } else if (sizeof(long) <= sizeof(unsigned long long)) { + __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x)) + } + } else { +#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(x)) { + case 0: return 0; + case 1: __PYX_VERIFY_RETURN_INT(long, digit, +(((PyLongObject*)x)->ob_digit[0])); + case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]); + } + #endif +#endif + if (sizeof(long) <= sizeof(long)) { + __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x)) + } else if (sizeof(long) <= sizeof(long long)) { + __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x)) + } + } + { +#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) + PyErr_SetString(PyExc_RuntimeError, + "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); +#else + long val; + PyObject *v = __Pyx_PyNumber_Int(x); + #if PY_MAJOR_VERSION < 3 + if (likely(v) && !PyLong_Check(v)) { + PyObject *tmp = v; + v = PyNumber_Long(tmp); + Py_DECREF(tmp); + } + #endif + if (likely(v)) { + int one = 1; int is_little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&val; + int ret = _PyLong_AsByteArray((PyLongObject *)v, + bytes, sizeof(val), + is_little, !is_unsigned); + Py_DECREF(v); + if (likely(!ret)) + return val; + } +#endif + return (long) -1; + } + } else { + long val; + PyObject *tmp = __Pyx_PyNumber_Int(x); + if (!tmp) return (long) -1; + val = __Pyx_PyInt_As_long(tmp); + Py_DECREF(tmp); + return val; + } +raise_overflow: + PyErr_SetString(PyExc_OverflowError, + "value too large to convert to long"); + return (long) -1; +raise_neg_overflow: + PyErr_SetString(PyExc_OverflowError, + "can't convert negative value to long"); + return (long) -1; +} + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { + const int neg_one = (int) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(int) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(int) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); + } + } else { + if (sizeof(int) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(int) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(int), + little, !is_unsigned); + } +} + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { + const long neg_one = (long) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(long) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(long) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); + } + } else { + if (sizeof(long) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(long) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(long), + little, !is_unsigned); + } +} + +static CYTHON_INLINE PyObject* __Pyx_PyInt_From_Py_intptr_t(Py_intptr_t value) { + const Py_intptr_t neg_one = (Py_intptr_t) -1, const_zero = 0; + const int is_unsigned = neg_one > const_zero; + if (is_unsigned) { + if (sizeof(Py_intptr_t) < sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long)) { + return PyLong_FromUnsignedLong((unsigned long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(unsigned long long)) { + return PyLong_FromUnsignedLongLong((unsigned long long) value); + } + } else { + if (sizeof(Py_intptr_t) <= sizeof(long)) { + return PyInt_FromLong((long) value); + } else if (sizeof(Py_intptr_t) <= sizeof(long long)) { + return PyLong_FromLongLong((long long) value); + } + } + { + int one = 1; int little = (int)*(unsigned char *)&one; + unsigned char *bytes = (unsigned char *)&value; + return _PyLong_FromByteArray(bytes, sizeof(Py_intptr_t), + little, !is_unsigned); + } +} + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return ::std::complex< float >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + return x + y*(__pyx_t_float_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) { + __pyx_t_float_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) { + __pyx_t_float_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrtf(z.real*z.real + z.imag*z.imag); + #else + return hypotf(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_powf(__pyx_t_float_complex a, __pyx_t_float_complex b) { + __pyx_t_float_complex z; + float r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + float denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(a, a); + case 3: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, a); + case 4: + z = __Pyx_c_prodf(a, a); + return __Pyx_c_prodf(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_absf(a); + theta = atan2f(a.imag, a.real); + } + lnr = logf(r); + z_r = expf(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cosf(z_theta); + z.imag = z_r * sinf(z_theta); + return z; + } + #endif +#endif + +#if CYTHON_CCOMPLEX + #ifdef __cplusplus + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return ::std::complex< double >(x, y); + } + #else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + return x + y*(__pyx_t_double_complex)_Complex_I; + } + #endif +#else + static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) { + __pyx_t_double_complex z; + z.real = x; + z.imag = y; + return z; + } +#endif + +#if CYTHON_CCOMPLEX +#else + static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) { + return (a.real == b.real) && (a.imag == b.imag); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real + b.real; + z.imag = a.imag + b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real - b.real; + z.imag = a.imag - b.imag; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + z.real = a.real * b.real - a.imag * b.imag; + z.imag = a.real * b.imag + a.imag * b.real; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double denom = b.real * b.real + b.imag * b.imag; + z.real = (a.real * b.real + a.imag * b.imag) / denom; + z.imag = (a.imag * b.real - a.real * b.imag) / denom; + return z; + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = -a.real; + z.imag = -a.imag; + return z; + } + static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) { + return (a.real == 0) && (a.imag == 0); + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) { + __pyx_t_double_complex z; + z.real = a.real; + z.imag = -a.imag; + return z; + } + #if 1 + static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) { + #if !defined(HAVE_HYPOT) || defined(_MSC_VER) + return sqrt(z.real*z.real + z.imag*z.imag); + #else + return hypot(z.real, z.imag); + #endif + } + static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_pow(__pyx_t_double_complex a, __pyx_t_double_complex b) { + __pyx_t_double_complex z; + double r, lnr, theta, z_r, z_theta; + if (b.imag == 0 && b.real == (int)b.real) { + if (b.real < 0) { + double denom = a.real * a.real + a.imag * a.imag; + a.real = a.real / denom; + a.imag = -a.imag / denom; + b.real = -b.real; + } + switch ((int)b.real) { + case 0: + z.real = 1; + z.imag = 0; + return z; + case 1: + return a; + case 2: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(a, a); + case 3: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, a); + case 4: + z = __Pyx_c_prod(a, a); + return __Pyx_c_prod(z, z); + } + } + if (a.imag == 0) { + if (a.real == 0) { + return a; + } + r = a.real; + theta = 0; + } else { + r = __Pyx_c_abs(a); + theta = atan2(a.imag, a.real); + } + lnr = log(r); + z_r = exp(lnr * b.real - theta * b.imag); + z_theta = theta * b.real + lnr * b.imag; + z.real = z_r * cos(z_theta); + z.imag = z_r * sin(z_theta); + return z; + } + #endif +#endif + +static int __Pyx_check_binary_version(void) { + char ctversion[4], rtversion[4]; + PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); + PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); + if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { + char message[200]; + PyOS_snprintf(message, sizeof(message), + "compiletime version %s of module '%.100s' " + "does not match runtime version %s", + ctversion, __Pyx_MODULE_NAME, rtversion); + return PyErr_WarnEx(NULL, message, 1); + } + return 0; +} + +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + +#ifndef __PYX_HAVE_RT_ImportType +#define __PYX_HAVE_RT_ImportType +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, + size_t size, int strict) +{ + PyObject *py_module = 0; + PyObject *result = 0; + PyObject *py_name = 0; + char warning[200]; + Py_ssize_t basicsize; +#ifdef Py_LIMITED_API + PyObject *py_basicsize; +#endif + py_module = __Pyx_ImportModule(module_name); + if (!py_module) + goto bad; + py_name = __Pyx_PyIdentifier_FromString(class_name); + if (!py_name) + goto bad; + result = PyObject_GetAttr(py_module, py_name); + Py_DECREF(py_name); + py_name = 0; + Py_DECREF(py_module); + py_module = 0; + if (!result) + goto bad; + if (!PyType_Check(result)) { + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s is not a type object", + module_name, class_name); + goto bad; + } +#ifndef Py_LIMITED_API + basicsize = ((PyTypeObject *)result)->tp_basicsize; +#else + py_basicsize = PyObject_GetAttrString(result, "__basicsize__"); + if (!py_basicsize) + goto bad; + basicsize = PyLong_AsSsize_t(py_basicsize); + Py_DECREF(py_basicsize); + py_basicsize = 0; + if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred()) + goto bad; +#endif + if (!strict && (size_t)basicsize > size) { + PyOS_snprintf(warning, sizeof(warning), + "%s.%s size changed, may indicate binary incompatibility", + module_name, class_name); + if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad; + } + else if ((size_t)basicsize != size) { + PyErr_Format(PyExc_ValueError, + "%.200s.%.200s has the wrong size, try recompiling", + module_name, class_name); + goto bad; + } + return (PyTypeObject *)result; +bad: + Py_XDECREF(py_module); + Py_XDECREF(result); + return NULL; +} +#endif + +static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { + while (t->p) { + #if PY_MAJOR_VERSION < 3 + if (t->is_unicode) { + *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); + } else if (t->intern) { + *t->p = PyString_InternFromString(t->s); + } else { + *t->p = PyString_FromStringAndSize(t->s, t->n - 1); + } + #else + if (t->is_unicode | t->is_str) { + if (t->intern) { + *t->p = PyUnicode_InternFromString(t->s); + } else if (t->encoding) { + *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); + } else { + *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); + } + } else { + *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); + } + #endif + if (!*t->p) + return -1; + ++t; + } + return 0; +} + +static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { + return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) { + Py_ssize_t ignore; + return __Pyx_PyObject_AsStringAndSize(o, &ignore); +} +static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) { +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT + if ( +#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + __Pyx_sys_getdefaultencoding_not_ascii && +#endif + PyUnicode_Check(o)) { +#if PY_VERSION_HEX < 0x03030000 + char* defenc_c; + PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); + if (!defenc) return NULL; + defenc_c = PyBytes_AS_STRING(defenc); +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + { + char* end = defenc_c + PyBytes_GET_SIZE(defenc); + char* c; + for (c = defenc_c; c < end; c++) { + if ((unsigned char) (*c) >= 128) { + PyUnicode_AsASCIIString(o); + return NULL; + } + } + } +#endif + *length = PyBytes_GET_SIZE(defenc); + return defenc_c; +#else + if (__Pyx_PyUnicode_READY(o) == -1) return NULL; +#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII + if (PyUnicode_IS_ASCII(o)) { + *length = PyUnicode_GET_LENGTH(o); + return PyUnicode_AsUTF8(o); + } else { + PyUnicode_AsASCIIString(o); + return NULL; + } +#else + return PyUnicode_AsUTF8AndSize(o, length); +#endif +#endif + } else +#endif +#if !CYTHON_COMPILING_IN_PYPY + if (PyByteArray_Check(o)) { + *length = PyByteArray_GET_SIZE(o); + return PyByteArray_AS_STRING(o); + } else +#endif + { + char* result; + int r = PyBytes_AsStringAndSize(o, &result, length); + if (unlikely(r < 0)) { + return NULL; + } else { + return result; + } + } +} +static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) { + int is_true = x == Py_True; + if (is_true | (x == Py_False) | (x == Py_None)) return is_true; + else return PyObject_IsTrue(x); +} +static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) { + PyNumberMethods *m; + const char *name = NULL; + PyObject *res = NULL; +#if PY_MAJOR_VERSION < 3 + if (PyInt_Check(x) || PyLong_Check(x)) +#else + if (PyLong_Check(x)) +#endif + return Py_INCREF(x), x; + m = Py_TYPE(x)->tp_as_number; +#if PY_MAJOR_VERSION < 3 + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Int(x); + } + else if (m && m->nb_long) { + name = "long"; + res = PyNumber_Long(x); + } +#else + if (m && m->nb_int) { + name = "int"; + res = PyNumber_Long(x); + } +#endif + if (res) { +#if PY_MAJOR_VERSION < 3 + if (!PyInt_Check(res) && !PyLong_Check(res)) { +#else + if (!PyLong_Check(res)) { +#endif + PyErr_Format(PyExc_TypeError, + "__%.4s__ returned non-%.4s (type %.200s)", + name, name, Py_TYPE(res)->tp_name); + Py_DECREF(res); + return NULL; + } + } + else if (!PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, + "an integer is required"); + } + return res; +} +static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) { + Py_ssize_t ival; + PyObject *x; +#if PY_MAJOR_VERSION < 3 + if (likely(PyInt_CheckExact(b))) + return PyInt_AS_LONG(b); +#endif + if (likely(PyLong_CheckExact(b))) { + #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 + #if CYTHON_USE_PYLONG_INTERNALS + switch (Py_SIZE(b)) { + case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0]; + case 0: return 0; + case 1: return ((PyLongObject*)b)->ob_digit[0]; + } + #endif + #endif + return PyLong_AsSsize_t(b); + } + x = PyNumber_Index(b); + if (!x) return -1; + ival = PyInt_AsSsize_t(x); + Py_DECREF(x); + return ival; +} +static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { + return PyInt_FromSize_t(ival); +} + + +#endif /* Py_PYTHON_H */ diff --git a/GPy/models/state_space_cython.pyx b/GPy/models/state_space_cython.pyx new file mode 100644 index 00000000..ae09d1cd --- /dev/null +++ b/GPy/models/state_space_cython.pyx @@ -0,0 +1,964 @@ +# -*- coding: utf-8 -*- +""" +Contains some cython code for state space modelling. +""" +import numpy as np +cimport numpy as np +import scipy as sp +cimport cython + +#from libc.math cimport isnan # for nan checking in kalman filter cycle +cdef extern from "numpy/npy_math.h": + bint npy_isnan(double x) + +DTYPE = np.float64 +DTYPE_int = np.int64 + +ctypedef np.float64_t DTYPE_t +ctypedef np.int64_t DTYPE_int_t + +# Template class for dynamic callables +cdef class Dynamic_Callables_Cython: + cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + raise NotImplemented("(cython) f_a is not implemented!") + + cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): # returns state iteration matrix + raise NotImplemented("(cython) Ak is not implemented!") + + cpdef Qk(self, int k): + raise NotImplemented("(cython) Qk is not implemented!") + + cpdef Q_srk(self, int k): + raise NotImplemented("(cython) Q_srk is not implemented!") + + cpdef dAk(self, int k): + raise NotImplemented("(cython) dAk is not implemented!") + + cpdef dQk(self, int k): + raise NotImplemented("(cython) dQk is not implemented!") + + cpdef reset(self, bint compute_derivatives = False): + raise NotImplemented("(cython) reset is not implemented!") + +# Template class for measurement callables +cdef class Measurement_Callables_Cython: + cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] Hk): + raise NotImplemented("(cython) f_a is not implemented!") + + cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + raise NotImplemented("(cython) Hk is not implemented!") + + cpdef Rk(self, int k): + raise NotImplemented("(cython) Rk is not implemented!") + + cpdef R_isrk(self, int k): + raise NotImplemented("(cython) Q_srk is not implemented!") + + cpdef dHk(self, int k): + raise NotImplemented("(cython) dAk is not implemented!") + + cpdef dRk(self, int k): + raise NotImplemented("(cython) dQk is not implemented!") + + cpdef reset(self,compute_derivatives = False): + raise NotImplemented("(cython) reset is not implemented!") + +cdef class R_handling_Cython(Measurement_Callables_Cython): + """ + The calss handles noise matrix R. + """ + cdef: + np.ndarray R + np.ndarray index + int R_time_var_index + np.ndarray dR + bint svd_each_time + dict R_square_root + + def __init__(self, np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, + int R_time_var_index, int p_unique_R_number, np.ndarray[DTYPE_t, ndim=3] dR = None): + """ + Input: + --------------- + R - array with noise on various steps. The result of preprocessing + the noise input. + + index - for each step of Kalman filter contains the corresponding index + in the array. + + R_time_var_index - another index in the array R. Computed earlier and passed here. + + unique_R_number - number of unique noise matrices below which square roots + are cached and above which they are computed each time. + + dR: 3D array[:, :, param_num] + derivative of R. Derivative is supported only when R do not change over time + + Output: + -------------- + Object which has two necessary functions: + f_R(k) + inv_R_square_root(k) + """ + + self.R = R + self.index = index + self.R_time_var_index = R_time_var_index + self.dR = dR + + cdef int unique_len = len(np.unique(index)) + + if (unique_len > p_unique_R_number): + self.svd_each_time = True + else: + self.svd_each_time = False + + self.R_square_root = {} + + cpdef Rk(self, int k): + return self.R[:,:, self.index[self.R_time_var_index, k]] + + + cpdef dRk(self,int k): + if self.dR is None: + raise ValueError("dR derivative is None") + + return self.dR # the same dirivative on each iteration + + cpdef R_isrk(self, int k): + """ + Function returns the inverse square root of R matrix on step k. + """ + cdef int ind = self.index[self.R_time_var_index, k] + cdef np.ndarray[DTYPE_t, ndim=2] R = self.R[:,:, ind ] + + cdef np.ndarray[DTYPE_t, ndim=2] inv_square_root + + cdef np.ndarray[DTYPE_t, ndim=2] U + cdef np.ndarray[DTYPE_t, ndim=1] S + cdef np.ndarray[DTYPE_t, ndim=2] Vh + + if (R.shape[0] == 1): # 1-D case handle simplier. No storage + # of the result, just compute it each time. + inv_square_root = np.sqrt( 1.0/R ) + else: + if self.svd_each_time: + + U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + inv_square_root = U * 1.0/np.sqrt(S) + else: + if ind in self.R_square_root: + inv_square_root = self.R_square_root[ind] + else: + U,S,Vh = sp.linalg.svd( R,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + inv_square_root = U * 1.0/np.sqrt(S) + + self.R_square_root[ind] = inv_square_root + + return inv_square_root + + +cdef class Std_Measurement_Callables_Cython(R_handling_Cython): + + cdef: + np.ndarray H + int H_time_var_index + np.ndarray dH + + def __init__(self, np.ndarray[DTYPE_t, ndim=3] H, int H_time_var_index, + np.ndarray[DTYPE_t, ndim=3] R, np.ndarray[DTYPE_t, ndim=2] index, int R_time_var_index, + int unique_R_number, np.ndarray[DTYPE_t, ndim=3] dH = None, + np.ndarray[DTYPE_t, ndim=3] dR=None): + + super(Std_Measurement_Callables_Cython,self).__init__(R, index, R_time_var_index, unique_R_number,dR) + + self.H = H + self.H_time_var_index = H_time_var_index + self.dH = dH + + cpdef f_h(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] H): + """ + function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), starts at 0 + x_{k} state + H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + """ + + return np.dot(H, m) + + cpdef Hk(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + return self.H[:,:, self.index[self.H_time_var_index, k]] + + cpdef dHk(self,int k): + if self.dH is None: + raise ValueError("dH derivative is None") + + return self.dH # the same dirivative on each iteration + + + +cdef class Q_handling_Cython(Dynamic_Callables_Cython): + + cdef: + np.ndarray Q + np.ndarray index + int Q_time_var_index + np.ndarray dQ + dict Q_square_root + bint svd_each_time + + def __init__(self, np.ndarray[DTYPE_t, ndim=3] Q, np.ndarray[DTYPE_t, ndim=2] index, + int Q_time_var_index, int p_unique_Q_number, np.ndarray[DTYPE_t, ndim=3] dQ = None): + """ + Input: + --------------- + Q - array with noise on various steps. The result of preprocessing + the noise input. + + index - for each step of Kalman filter contains the corresponding index + in the array. + + Q_time_var_index - another index in the array R. Computed earlier and passed here. + + unique_Q_number - number of unique noise matrices below which square roots + are cached and above which they are computed each time. + + dQ: 3D array[:, :, param_num] + derivative of Q. Derivative is supported only when Q do not change over time + + Output: + -------------- + Object which has three necessary functions: + Qk(k) + dQk(k) + Q_srkt(k) + """ + + self.Q = Q + self.index = index + self.Q_time_var_index = Q_time_var_index + self.dQ = dQ + + cdef int unique_len = len(np.unique(index)) + + if (unique_len > p_unique_Q_number): + self.svd_each_time = True + else: + self.svd_each_time = False + + self.Q_square_root = {} + + + cpdef Qk(self, int k): + """ + function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + """ + return self.Q[:,:, self.index[self.Q_time_var_index, k]] + + cpdef dQk(self, int k): + if self.dQ is None: + raise ValueError("dQ derivative is None") + + return self.dQ # the same dirivative on each iteration + + cpdef Q_srk(self, int k): + """ + function (k). Returns the square root of noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + + This function is implemented to use SVD prediction step. + """ + cdef int ind = self.index[self.Q_time_var_index, k] + cdef np.ndarray[DTYPE_t, ndim=2] Q = self.Q[:,:, ind] + + + cdef np.ndarray[DTYPE_t, ndim=2] square_root + + cdef np.ndarray[DTYPE_t, ndim=2] U + cdef np.ndarray[DTYPE_t, ndim=1] S + cdef np.ndarray[DTYPE_t, ndim=2] Vh + + if (Q.shape[0] == 1): # 1-D case handle simplier. No storage + # of the result, just compute it each time. + square_root = np.sqrt( Q ) + else: + if self.svd_each_time: + + U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + square_root = U * np.sqrt(S) + else: + + if ind in self.Q_square_root: + square_root = self.Q_square_root[ind] + else: + U,S,Vh = sp.linalg.svd( Q,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + square_root = U * np.sqrt(S) + + self.Q_square_root[ind] = square_root + + return square_root + +cdef class Std_Dynamic_Callables_Cython(Q_handling_Cython): + cdef: + np.ndarray A + int A_time_var_index + np.ndarray dA + + def __init__(self, np.ndarray[DTYPE_t, ndim=3] A, int A_time_var_index, + np.ndarray[DTYPE_t, ndim=3] Q, + np.ndarray[DTYPE_t, ndim=2] index, + int Q_time_var_index, int unique_Q_number, + np.ndarray[DTYPE_t, ndim=3] dA = None, + np.ndarray[DTYPE_t, ndim=3] dQ=None): + + super(Std_Dynamic_Callables_Cython,self).__init__(Q, index, Q_time_var_index, unique_Q_number,dQ) + + self.A = A + self.A_time_var_index = A_time_var_index + self.dA = dA + + cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + """ + f_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), starts at 0 + x_{k-1} State from the previous step + A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}. + """ + + return np.dot(A,m) + + cpdef Ak(self, int k, np.ndarray[DTYPE_t, ndim=2] m_pred, np.ndarray[DTYPE_t, ndim=2] P_pred): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + return self.A[:,:, self.index[self.A_time_var_index, k]] + + cpdef dAk(self, int k): + if self.dA is None: + raise ValueError("dA derivative is None") + + return self.dA # the same dirivative on each iteration + + + cpdef reset(self, bint compute_derivatives=False): + """ + For reusing this object e.g. in smoother computation. It makes sence + because necessary matrices have been already computed for all + time steps. + """ + return self + +cdef class AQcompute_batch_Cython(Q_handling_Cython): + """ + Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter + from the matrices F, L, Qc, P_ing, dF, dQc, dP_inf of the continuos state + equation. dt - time steps. + + It has the same interface as AQcompute_once. + + It computes matrices for all time steps. This object is used when + there are not so many (controlled by internal variable) + different time steps and storing all the matrices do not take too much memory. + + Since all the matrices are computed all together, this object can be used + in smoother without repeating the computations. + """ + #def __init__(self, F,L,Qc,dt,compute_derivatives=False, grad_params_no=None, P_inf=None, dP_inf=None, dF = None, dQc=None): + cdef: + np.ndarray As + np.ndarray Qs + np.ndarray dAs + np.ndarray dQs + np.ndarray reconstruct_indices + #long total_size_of_data + dict Q_svd_dict + int last_k + + def __init__(self, np.ndarray[DTYPE_t, ndim=3] As, np.ndarray[DTYPE_t, ndim=3] Qs, + np.ndarray[DTYPE_int_t, ndim=1] reconstruct_indices, + np.ndarray[DTYPE_t, ndim=4] dAs=None, + np.ndarray[DTYPE_t, ndim=4] dQs=None): + """ + Constructor. All necessary parameters are passed here and stored + in the opject. + + Input: + ------------------- + F, L, Qc, P_inf : matrices + Parameters of corresponding continuous state model + dt: array + All time steps + compute_derivatives: bool + Whether to calculate derivatives + + dP_inf, dF, dQc: 3D array + Derivatives if they are required + + Output: + ------------------- + + """ + + self.As = As + self.Qs = Qs + self.dAs = dAs + self.dQs = dQs + self.reconstruct_indices = reconstruct_indices + self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + + self.Q_svd_dict = {} + self.last_k = 0 + # !!!Print statistics! Which object is created + # !!!Print statistics! Print sizes of matrices + cpdef f_a(self, int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] A): + """ + Dynamic model + """ + return np.dot(A, m) # default dynamic model + + cpdef reset(self, bint compute_derivatives=False): + """ + For reusing this object e.g. in smoother computation. It makes sence + because necessary matrices have been already computed for all + time steps. + """ + return self + + cpdef Ak(self,int k, np.ndarray[DTYPE_t, ndim=2] m, np.ndarray[DTYPE_t, ndim=2] P): + self.last_k = k + return self.As[:,:, self.reconstruct_indices[k]] + + cpdef Qk(self,int k): + self.last_k = k + return self.Qs[:,:, self.reconstruct_indices[k]] + + cpdef dAk(self, int k): + self.last_k = k + return self.dAs[:,:, :, self.reconstruct_indices[k]] + + cpdef dQk(self, int k): + self.last_k = k + return self.dQs[:,:, :, self.reconstruct_indices[k]] + + + cpdef Q_srk(self, int k): + """ + Square root of the noise matrix Q + """ + + cdef int matrix_index = self.reconstruct_indices[k] + cdef np.ndarray[DTYPE_t, ndim=2] square_root + + cdef np.ndarray[DTYPE_t, ndim=2] U + cdef np.ndarray[DTYPE_t, ndim=1] S + cdef np.ndarray[DTYPE_t, ndim=2] Vh + + if matrix_index in self.Q_svd_dict: + square_root = self.Q_svd_dict[matrix_index] + else: + U,S,Vh = sp.linalg.svd( self.Qs[:,:, matrix_index], + full_matrices=False, compute_uv=True, + overwrite_a=False, check_finite=False) + + square_root = U * np.sqrt(S) + self.Q_svd_dict[matrix_index] = square_root + + return square_root + +# def return_last(self): +# """ +# Function returns last available matrices. +# """ +# +# if (self.last_k is None): +# raise ValueError("Matrices are not computed.") +# else: +# ind = self.reconstruct_indices[self.last_k] +# A = self.As[:,:, ind] +# Q = self.Qs[:,:, ind] +# dA = self.dAs[:,:, :, ind] +# dQ = self.dQs[:,:, :, ind] +# +# return self.last_k, A, Q, dA, dQ + +@cython.boundscheck(False) +def _kalman_prediction_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m , tuple p_P, + Dynamic_Callables_Cython p_dynamic_callables, + bint calc_grad_log_likelihood=False, + np.ndarray[DTYPE_t, ndim=3] p_dm = None, + np.ndarray[DTYPE_t, ndim=3] p_dP = None): + """ + Desctrete prediction function + + Input: + k:int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + p_m: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: tuple (Prev_cov, S, V) + Covariance matrix from the previous step and its SVD decomposition. + Prev_cov = V * S * V.T The tuple is (Prev_cov, S, V) + + p_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), starts at 0 + x_{k-1} State from the previous step + A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}. + + p_f_A: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_a. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_Q: function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + + p_f_Qsr: function (k). Returns square root of noise matrix of the + dynamic model on iteration k. k (iteration number). starts at 0 + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the previous step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: 3D array (state_dim, state_dim, parameters_no) + Mean derivatives from the previous step + + grad_calc_params_1: List or None + List with derivatives. The first component is 'f_dA' - function(k) + which returns the derivative of A. The second element is 'f_dQ' + - function(k). Function which returns the derivative of Q. + + Output: + ---------------------------- + m_pred, P_pred, dm_pred, dP_pred: metrices, 3D objects + Results of the prediction steps. + + """ + + # covariance from the previous step# p_prev_cov = v * S * V.T + cdef np.ndarray[DTYPE_t, ndim=2] Prev_cov = p_P[0] + cdef np.ndarray[DTYPE_t, ndim=1] S_old = p_P[1] + cdef np.ndarray[DTYPE_t, ndim=2] V_old = p_P[2] + #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step + + # index correspond to values from previous iteration. + cdef np.ndarray[DTYPE_t, ndim=2] A = p_dynamic_callables.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian) + cdef np.ndarray[DTYPE_t, ndim=2] Q = p_dynamic_callables.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step) + cdef np.ndarray[DTYPE_t, ndim=2] Q_sr = p_dynamic_callables.Q_srk(k) + # Prediction step -> + cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_dynamic_callables.f_a(k, p_m, A) # predicted mean + + # coavariance prediction have changed: + cdef np.ndarray[DTYPE_t, ndim=2] svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) + res = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + # (U,S,Vh) + cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + cdef np.ndarray[DTYPE_t, ndim=1] S = res[1] + cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + # predicted variance computed by the regular method. For testing + #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q + cdef np.ndarray[DTYPE_t, ndim=2] V_new = Vh.T + cdef np.ndarray[DTYPE_t, ndim=1] S_new = S**2 + + cdef np.ndarray[DTYPE_t, ndim=2] P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance + #tuple P_pred = (P_pred, S_new, Vh.T) + # Prediction step <- + + # derivatives + cdef np.ndarray[DTYPE_t, ndim=3] dA_all_params + cdef np.ndarray[DTYPE_t, ndim=3] dQ_all_params + + cdef np.ndarray[DTYPE_t, ndim=3] dm_pred + cdef np.ndarray[DTYPE_t, ndim=3] dP_pred + + cdef int param_number + cdef int j + cdef tuple ret + + cdef np.ndarray[DTYPE_t, ndim=2] dA + cdef np.ndarray[DTYPE_t, ndim=2] dQ + if calc_grad_log_likelihood: + dA_all_params = p_dynamic_callables.dAk(k) # derivatives of A wrt parameters + dQ_all_params = p_dynamic_callables.dQk(k) # derivatives of Q wrt parameters + + param_number = p_dP.shape[2] + + # p_dm, p_dP - derivatives form the previoius step + dm_pred = np.empty((p_dm.shape[0], p_dm.shape[1], p_dm.shape[2]), dtype = DTYPE) + dP_pred = np.empty((p_dP.shape[0], p_dP.shape[1], p_dP.shape[2]), dtype = DTYPE) + + for j in range(param_number): + dA = dA_all_params[:,:,j] + dQ = dQ_all_params[:,:,j] + + dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) + # prediction step derivatives for current parameter: + + dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + dP_pred[:,:,j] += dP_pred[:,:,j].T + dP_pred[:,:,j] += np.dot( A ,np.dot( p_dP[:,:,j] , A.T)) + dQ + + dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + else: + dm_pred = None + dP_pred = None + + ret = (P_pred, S_new, Vh.T) + return m_pred, ret, dm_pred, dP_pred + + + +@cython.boundscheck(False) +def _kalman_update_step_SVD_Cython(long k, np.ndarray[DTYPE_t, ndim=2] p_m, tuple p_P, + Measurement_Callables_Cython p_measurement_callables, + np.ndarray[DTYPE_t, ndim=2] measurement, + bint calc_log_likelihood= False, + bint calc_grad_log_likelihood=False, + np.ndarray[DTYPE_t, ndim=3] p_dm = None, + np.ndarray[DTYPE_t, ndim=3] p_dP = None): + """ + Input: + + k: int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + m_P: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: tuple (P_pred, S, V) + Covariance matrix from the prediction step and its SVD decomposition. + P_pred = V * S * V.T The tuple is (P_pred, S, V) + + p_h: function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), starts at 0 + x_{k} state + H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + + p_f_H: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_R: function (k). Returns noise matrix of measurement equation + on iteration k. + k (iteration number). starts at 0 + + p_f_iRsr: function (k). Returns the square root of the noise matrix of + measurement equation on iteration k. + k (iteration number). starts at 0 + + measurement: (measurement_dim, time_series_no) matrix + One measurement used on the current update step. For + "multiple time series mode" it is matrix, second dimension of + which correspond to different time series. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the prediction step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: array + Covariance derivatives from the prediction step. + + grad_calc_params_2: List or None + List with derivatives. The first component is 'f_dH' - function(k) + which returns the derivative of H. The second element is 'f_dR' + - function(k). Function which returns the derivative of R. + + Output: + ---------------------------- + m_upd, P_upd, dm_upd, dP_upd: metrices, 3D objects + Results of the prediction steps. + + log_likelihood_update: double or 1D array + Update to the log_likelihood from this step + + d_log_likelihood_update: (grad_params_no, time_series_no) matrix + Update to the gradient of log_likelihood, "multiple time series mode" + adds extra columns to the gradient. + + """ + + cdef np.ndarray[DTYPE_t, ndim=2] m_pred = p_m # from prediction step + #P_pred,S_pred,V_pred = p_P # from prediction step + cdef np.ndarray[DTYPE_t, ndim=2] P_pred = p_P[0] + cdef np.ndarray[DTYPE_t, ndim=1] S_pred = p_P[1] + cdef np.ndarray[DTYPE_t, ndim=2] V_pred = p_P[2] + + cdef np.ndarray[DTYPE_t, ndim=2] H = p_measurement_callables.Hk(k, m_pred, P_pred) + cdef np.ndarray[DTYPE_t, ndim=2] R = p_measurement_callables.Rk(k) + cdef np.ndarray[DTYPE_t, ndim=2] R_isr =p_measurement_callables.R_isrk(k) # square root of the inverse of R matrix + + cdef int time_series_no = p_m.shape[1] # number of time serieses + + cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood_update # log_likelihood_update=None; + # Update step (only if there is data) + #if not np.any(np.isnan(measurement)): # TODO: if some dimensions are missing, do properly computations for other. + cdef np.ndarray[DTYPE_t, ndim=2] v = measurement-p_measurement_callables.f_h(k, m_pred, H) + + cdef np.ndarray[DTYPE_t, ndim=2] svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) + + res = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + #(U,S,Vh) + cdef np.ndarray[DTYPE_t, ndim=2] U = res[0] + cdef np.ndarray[DTYPE_t, ndim=1] S_svd = res[1] + cdef np.ndarray[DTYPE_t, ndim=2] Vh = res[2] + + # P_upd = U_upd S_upd**2 U_upd.T + cdef np.ndarray[DTYPE_t, ndim=2] U_upd = np.dot(V_pred, Vh.T) + cdef np.ndarray[DTYPE_t, ndim=1] S_upd = (1.0/S_svd)**2 + + cdef np.ndarray[DTYPE_t, ndim=2] P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance + #P_upd = (P_upd,S_upd,U_upd) # tuple to pass to the next step + + # stil need to compute S and K for derivative computation + cdef np.ndarray[DTYPE_t, ndim=2] S = H.dot(P_pred).dot(H.T) + R + cdef np.ndarray[DTYPE_t, ndim=2] K + cdef bint measurement_dim_gt_one = False + if measurement.shape[0]==1: # measurements are one dimensional + if (S < 0): + raise ValueError("Kalman Filter Update SVD: S is negative step %i" % k ) + #import pdb; pdb.set_trace() + + K = P_pred.dot(H.T) / S + if calc_log_likelihood: + log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + v*v / S) + #log_likelihood_update = log_likelihood_update[0,0] # to make int + if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + raise ValueError("Nan values in likelihood update!") + else: + log_likelihood_update = None + #LL = None; islower = None + else: + measurement_dim_gt_one = True + raise ValueError("""Measurement dimension larger then 1 is currently not supported""") + + # Old method of computing updated covariance (for testing) -> + #P_upd_tst = K.dot(S).dot(K.T) + #P_upd_tst = 0.5*(P_upd_tst + P_upd_tst.T) + #P_upd_tst = P_pred - P_upd_tst# this update matrix is symmetric + # Old method of computing updated covariance (for testing) <- + cdef np.ndarray[DTYPE_t, ndim=3] dm_upd # dm_upd=None; + cdef np.ndarray[DTYPE_t, ndim=3] dP_upd # dP_upd=None; + cdef np.ndarray[DTYPE_t, ndim=2] d_log_likelihood_update # d_log_likelihood_update=None + + cdef np.ndarray[DTYPE_t, ndim=3] dm_pred_all_params + cdef np.ndarray[DTYPE_t, ndim=3] dP_pred_all_params + cdef int param_number + + cdef np.ndarray[DTYPE_t, ndim=3] dH_all_params + cdef np.ndarray[DTYPE_t, ndim=3] dR_all_params + + cdef int param + + cdef np.ndarray[DTYPE_t, ndim=2] dH, dR, dm_pred, dP_pred, dv, dS, tmp1, tmp2, tmp3, dK, tmp5 + cdef tuple ret + + if calc_grad_log_likelihood: + dm_pred_all_params = p_dm # derivativas of the prediction phase + dP_pred_all_params = p_dP + + param_number = p_dP.shape[2] + + dH_all_params = p_measurement_callables.dHk(k) + dR_all_params = p_measurement_callables.dRk(k) + + dm_upd = np.empty((dm_pred_all_params.shape[0], dm_pred_all_params.shape[1], dm_pred_all_params.shape[2]), dtype = DTYPE) + dP_upd = np.empty((dP_pred_all_params.shape[0], dP_pred_all_params.shape[1], dP_pred_all_params.shape[2]), dtype = DTYPE) + + # firts dimension parameter_no, second - time series number + d_log_likelihood_update = np.empty((param_number,time_series_no), dtype = DTYPE) + for param in range(param_number): + + dH = dH_all_params[:,:,param] + dR = dR_all_params[:,:,param] + + dm_pred = dm_pred_all_params[:,:,param] + dP_pred = dP_pred_all_params[:,:,param] + + # Terms in the likelihood derivatives + dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) + dS = np.dot(dH, np.dot( P_pred, H.T)) + dS += dS.T + dS += np.dot(H, np.dot( dP_pred, H.T)) + dR + + # TODO: maybe symmetrize dS + + tmp1 = H.T / S + tmp2 = dH.T / S + tmp3 = dS.T / S + + dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ + np.dot( P_pred, np.dot( tmp1, tmp3 ) ) + + # terms required for the next step, save this for each parameter + dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) + + dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + dP_upd[:,:,param] += dP_upd[:,:,param].T + dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + + dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + # computing the likelihood change for each parameter: + tmp5 = v / S + + + d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ + np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + + # Compute the actual updates for mean of the states. Variance update + # is computed earlier. + else: + dm_upd = None + dP_upd = None + d_log_likelihood_update = None + + m_upd = m_pred + K.dot( v ) + + ret = (P_upd,S_upd,U_upd) + return m_upd, ret, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update + + +@cython.boundscheck(False) +def _cont_discr_kalman_filter_raw_Cython(int state_dim, Dynamic_Callables_Cython p_dynamic_callables, + Measurement_Callables_Cython p_measurement_callables, X, Y, + np.ndarray[DTYPE_t, ndim=2] m_init=None, np.ndarray[DTYPE_t, ndim=2] P_init=None, + p_kalman_filter_type='regular', + bint calc_log_likelihood=False, + bint calc_grad_log_likelihood=False, + int grad_params_no=0, + np.ndarray[DTYPE_t, ndim=3] dm_init=None, + np.ndarray[DTYPE_t, ndim=3] dP_init=None): + + cdef int steps_no = Y.shape[0] # number of steps in the Kalman Filter + cdef int time_series_no = Y.shape[2] # multiple time series mode + + # Allocate space for results + # Mean estimations. Initial values will be included + cdef np.ndarray[DTYPE_t, ndim=3] M = np.empty(((steps_no+1),state_dim,time_series_no), dtype=DTYPE) + M[0,:,:] = m_init # Initialize mean values + # Variance estimations. Initial values will be included + cdef np.ndarray[DTYPE_t, ndim=3] P = np.empty(((steps_no+1),state_dim,state_dim)) + P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + P[0,:,:] = P_init # Initialize initial covariance matrix + + cdef np.ndarray[DTYPE_t, ndim=2] U + cdef np.ndarray[DTYPE_t, ndim=1] S + cdef np.ndarray[DTYPE_t, ndim=2] Vh + + U,S,Vh = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + cdef tuple P_upd = (P_init, S,U) + #log_likelihood = 0 + #grad_log_likelihood = np.zeros((grad_params_no,1)) + cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood = np.zeros((1, time_series_no), dtype = DTYPE) #if calc_log_likelihood else None + cdef np.ndarray[DTYPE_t, ndim=2] grad_log_likelihood = np.zeros((grad_params_no, time_series_no), dtype = DTYPE) #if calc_grad_log_likelihood else None + + #setting initial values for derivatives update + cdef np.ndarray[DTYPE_t, ndim=3] dm_upd = dm_init + cdef np.ndarray[DTYPE_t, ndim=3] dP_upd = dP_init + # Main loop of the Kalman filter + cdef np.ndarray[DTYPE_t, ndim=2] prev_mean, k_measurment + cdef np.ndarray[DTYPE_t, ndim=2] m_pred, m_upd + cdef tuple P_pred + cdef np.ndarray[DTYPE_t, ndim=3] dm_pred, dP_pred + cdef np.ndarray[DTYPE_t, ndim=2] log_likelihood_update, d_log_likelihood_update + cdef int k + + #print "Hi I am cython" + for k in range(0,steps_no): + # In this loop index for new estimations is (k+1), old - (k) + # This happened because initial values are stored at 0-th index. + #import pdb; pdb.set_trace() + + prev_mean = M[k,:,:] # mean from the previous step + + m_pred, P_pred, dm_pred, dP_pred = \ + _kalman_prediction_step_SVD_Cython(k, prev_mean ,P_upd, p_dynamic_callables, + calc_grad_log_likelihood, dm_upd, dP_upd) + + k_measurment = Y[k,:,:] + if (np.any(np.isnan(k_measurment)) == False): +# if np.any(np.isnan(k_measurment)): +# raise ValueError("Nan measurements are currently not supported") + + m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + _kalman_update_step_SVD_Cython(k, m_pred , P_pred, p_measurement_callables, + k_measurment, calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_pred, p_dP = dP_pred) + else: + if not np.all(np.isnan(k_measurment)): + raise ValueError("""Nan measurements are currently not supported if + they are intermixed with not NaN measurements""") + else: + m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred + if calc_log_likelihood: + log_likelihood_update = np.zeros((1,time_series_no)) + if calc_grad_log_likelihood: + d_log_likelihood_update = np.zeros((grad_params_no,time_series_no)) + + + if calc_log_likelihood: + log_likelihood += log_likelihood_update + + if calc_grad_log_likelihood: + grad_log_likelihood += d_log_likelihood_update + + M[k+1,:,:] = m_upd # separate mean value for each time series + P[k+1,:,:] = P_upd[0] + + return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) \ No newline at end of file diff --git a/GPy/models/state_space_main.py b/GPy/models/state_space_main.py new file mode 100644 index 00000000..d0406e96 --- /dev/null +++ b/GPy/models/state_space_main.py @@ -0,0 +1,3489 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Main functionality for state-space inference. +""" + +import collections # for cheking whether a variable is iterable +import types # for cheking whether a variable is a function + +import numpy as np +import scipy as sp +import scipy.linalg as linalg + +try: + from . import state_space_setup + setup_available = True +except ImportError as e: + setup_available = False + + +print_verbose = False + +try: + import state_space_cython + cython_code_available = True + if print_verbose: + print("state_space: cython is available") +except ImportError as e: + cython_code_available = False + +#cython_code_available = False +# Use cython by default +use_cython = False +if setup_available: + use_cython = state_space_setup.use_cython + +if print_verbose: + if use_cython: + print("state_space: cython is used") + else: + print("state_space: cython is NOT used") + + +class Dynamic_Callables_Python(object): + + def f_a(self, k, m, A): + """ + p_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), starts at 0 + x_{k-1} State from the previous step + A_{k} Jacobian matrices of f_a. In the linear case it is exactly + A_{k}. + """ + + raise NotImplemented("f_a is not implemented!") + + def Ak(self, k, m, P): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of dynamic function, it is passed + into p_a. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + raise NotImplemented("Ak is not implemented!") + + def Qk(self, k): + """ + function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("Qk is not implemented!") + + def Q_srk(self, k): + """ + function (k). Returns the square root of noise matrix of dynamic model + on iteration k. + + k (iteration number). starts at 0 + + This function is implemented to use SVD prediction step. + """ + + raise NotImplemented("Q_srk is not implemented!") + + def dAk(self, k): + """ + function (k). Returns the derivative of A on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("dAk is not implemented!") + + def dQk(self, k): + """ + function (k). Returns the derivative of Q on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("dQk is not implemented!") + + def reset(self, compute_derivatives=False): + """ + Return the state of this object to the beginning of iteration + (to k eq. 0). + """ + + raise NotImplemented("reset is not implemented!") + +if use_cython: + Dynamic_Callables_Class = state_space_cython.Dynamic_Callables_Cython +else: + Dynamic_Callables_Class = Dynamic_Callables_Python + + +class Measurement_Callables_Python(object): + def f_h(self, k, m_pred, Hk): + """ + function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), starts at 0 + x_{k} state + H_{k} Jacobian matrices of f_h. In the linear case it is exactly + H_{k}. + """ + + raise NotImplemented("f_a is not implemented!") + + def Hk(self, k, m_pred, P_pred): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + raise NotImplemented("Hk is not implemented!") + + def Rk(self, k): + """ + function (k). Returns noise matrix of measurement equation + on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("Rk is not implemented!") + + def R_isrk(self, k): + """ + function (k). Returns the square root of the noise matrix of + measurement equation on iteration k. + k (iteration number). starts at 0 + + This function is implemented to use SVD prediction step. + """ + + raise NotImplemented("Q_srk is not implemented!") + + def dHk(self, k): + """ + function (k). Returns the derivative of H on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("dAk is not implemented!") + + def dRk(self, k): + """ + function (k). Returns the derivative of R on iteration k. + k (iteration number). starts at 0 + """ + raise NotImplemented("dQk is not implemented!") + + def reset(self, compute_derivatives=False): + """ + Return the state of this object to the beginning of iteration + (to k eq. 0) + """ + + raise NotImplemented("reset is not implemented!") + +if use_cython: + Measurement_Callables_Class = state_space_cython.\ + Measurement_Callables_Cython +else: + Measurement_Callables_Class = Measurement_Callables_Python + + +class R_handling_Python(Measurement_Callables_Class): + """ + The calss handles noise matrix R. + """ + def __init__(self, R, index, R_time_var_index, unique_R_number, dR=None): + """ + Input: + --------------- + R - array with noise on various steps. The result of preprocessing + the noise input. + + index - for each step of Kalman filter contains the corresponding index + in the array. + + R_time_var_index - another index in the array R. Computed earlier and + is passed here. + + unique_R_number - number of unique noise matrices below which square + roots are cached and above which they are computed each time. + + dR: 3D array[:, :, param_num] + derivative of R. Derivative is supported only when R do not change + over time + + Output: + -------------- + Object which has two necessary functions: + f_R(k) + inv_R_square_root(k) + """ + self.R = R + self.index = index + self.R_time_var_index = int(R_time_var_index) + self.dR = dR + + if (len(np.unique(index)) > unique_R_number): + self.svd_each_time = True + else: + self.svd_each_time = False + + self.R_square_root = {} + + def Rk(self, k): + return self.R[:, :, self.index[self.R_time_var_index, k]] + + def dRk(self, k): + if self.dR is None: + raise ValueError("dR derivative is None") + + return self.dR # the same dirivative on each iteration + + def R_isrk(self, k): + """ + Function returns the inverse square root of R matrix on step k. + """ + ind = int(self.index[self.R_time_var_index, k]) + R = self.R[:, :, ind] + + if (R.shape[0] == 1): # 1-D case handle simplier. No storage + # of the result, just compute it each time. + inv_square_root = np.sqrt(1.0/R) + else: + if self.svd_each_time: + + (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, + compute_uv=True, overwrite_a=False, + check_finite=True) + + inv_square_root = U * 1.0/np.sqrt(S) + else: + if ind in self.R_square_root: + inv_square_root = self.R_square_root[ind] + else: + (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, + compute_uv=True, + overwrite_a=False, + check_finite=True) + + inv_square_root = U * 1.0/np.sqrt(S) + + self.R_square_root[ind] = inv_square_root + + return inv_square_root + +if use_cython: + R_handling_Class = state_space_cython.R_handling_Cython +else: + R_handling_Class = R_handling_Python + + +class Std_Measurement_Callables_Python(R_handling_Class): + + def __init__(self, H, H_time_var_index, R, index, R_time_var_index, + unique_R_number, dH=None, dR=None): + super(Std_Measurement_Callables_Python, + self).__init__(R, index, R_time_var_index, unique_R_number, dR) + + self.H = H + self.H_time_var_index = int(H_time_var_index) + self.dH = dH + + def f_h(self, k, m, H): + """ + function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), starts at 0 + x_{k} state + H_{k} Jacobian matrices of f_h. In the linear case it is exactly + H_{k}. + """ + + return np.dot(H, m) + + def Hk(self, k, m_pred, P_pred): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + return self.H[:, :, self.index[self.H_time_var_index, k]] + + def dHk(self, k): + if self.dH is None: + raise ValueError("dH derivative is None") + + return self.dH # the same dirivative on each iteration + +if use_cython: + Std_Measurement_Callables_Class = state_space_cython.\ + Std_Measurement_Callables_Cython +else: + Std_Measurement_Callables_Class = Std_Measurement_Callables_Python + + +class Q_handling_Python(Dynamic_Callables_Class): + + def __init__(self, Q, index, Q_time_var_index, unique_Q_number, dQ=None): + """ + Input: + --------------- + R - array with noise on various steps. The result of preprocessing + the noise input. + + index - for each step of Kalman filter contains the corresponding index + in the array. + + R_time_var_index - another index in the array R. Computed earlier and + passed here. + + unique_R_number - number of unique noise matrices below which square + roots are cached and above which they are computed each time. + + dQ: 3D array[:, :, param_num] + derivative of Q. Derivative is supported only when Q do not + change over time + + Output: + -------------- + Object which has two necessary functions: + f_R(k) + inv_R_square_root(k) + """ + + self.Q = Q + self.index = index + self.Q_time_var_index = Q_time_var_index + self.dQ = dQ + + if (len(np.unique(index)) > unique_Q_number): + self.svd_each_time = True + else: + self.svd_each_time = False + + self.Q_square_root = {} + + def Qk(self, k): + """ + function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + """ + return self.Q[:, :, self.index[self.Q_time_var_index, k]] + + def dQk(self, k): + if self.dQ is None: + raise ValueError("dQ derivative is None") + + return self.dQ # the same dirivative on each iteration + + def Q_srk(self, k): + """ + function (k). Returns the square root of noise matrix of dynamic model + on iteration k. + k (iteration number). starts at 0 + + This function is implemented to use SVD prediction step. + """ + ind = self.index[self.Q_time_var_index, k] + Q = self.Q[:, :, ind] + + if (Q.shape[0] == 1): # 1-D case handle simplier. No storage + # of the result, just compute it each time. + square_root = np.sqrt(Q) + else: + if self.svd_each_time: + + (U, S, Vh) = sp.linalg.svd(Q, full_matrices=False, + compute_uv=True, + overwrite_a=False, + check_finite=True) + + square_root = U * np.sqrt(S) + else: + + if ind in self.Q_square_root: + square_root = self.Q_square_root[ind] + else: + (U, S, Vh) = sp.linalg.svd(Q, full_matrices=False, + compute_uv=True, + overwrite_a=False, + check_finite=True) + + square_root = U * np.sqrt(S) + + self.Q_square_root[ind] = square_root + + return square_root + +if use_cython: + Q_handling_Class = state_space_cython.Q_handling_Cython +else: + Q_handling_Class = Q_handling_Python + + +class Std_Dynamic_Callables_Python(Q_handling_Class): + + def __init__(self, A, A_time_var_index, Q, index, Q_time_var_index, + unique_Q_number, dA=None, dQ=None): + super(Std_Dynamic_Callables_Python, + self).__init__(Q, index, Q_time_var_index, unique_Q_number, dQ) + + self.A = A + self.A_time_var_index = A_time_var_index + self.dA = dA + + def f_a(self, k, m, A): + """ + f_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), starts at 0 + x_{k-1} State from the previous step + A_{k} Jacobian matrices of f_a. In the linear case it is exactly + A_{k}. + """ + return np.dot(A, m) + + def Ak(self, k, m_pred, P_pred): # returns state iteration matrix + """ + function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + """ + + return self.A[:, :, self.index[self.A_time_var_index, k]] + + def dAk(self, k): + if self.dA is None: + raise ValueError("dA derivative is None") + + return self.dA # the same dirivative on each iteration + + def reset(self, compute_derivatives=False): + """ + Return the state of this object to the beginning of iteration + (to k eq. 0) + """ + + return self + +if use_cython: + Std_Dynamic_Callables_Class = state_space_cython.\ + Std_Dynamic_Callables_Cython +else: + Std_Dynamic_Callables_Class = Std_Dynamic_Callables_Python + + +class AddMethodToClass(object): + + def __init__(self, func=None, tp='staticmethod'): + """ + Input: + -------------- + func: function to add + tp: string + Type of the method: normal, staticmethod, classmethod + """ + if func is None: + raise ValueError("Function can not be None") + + self.func = func + self.tp = tp + + def __get__(self, obj, klass=None, *args, **kwargs): + + if self.tp == 'staticmethod': + return self.func + elif self.tp == 'normal': + def newfunc(obj, *args, **kwargs): + return self.func + + elif self.tp == 'classmethod': + def newfunc(klass, *args, **kwargs): + return self.func + return newfunc + + +class DescreteStateSpaceMeta(type): + """ + Substitute necessary methods from cython. + """ + + def __new__(typeclass, name, bases, attributes): + """ + After thos method the class object is created + """ + + if use_cython: + if '_kalman_prediction_step_SVD' in attributes: + attributes['_kalman_prediction_step_SVD'] =\ + AddMethodToClass(state_space_cython. + _kalman_prediction_step_SVD_Cython) + + if '_kalman_update_step_SVD' in attributes: + attributes['_kalman_update_step_SVD'] =\ + AddMethodToClass(state_space_cython. + _kalman_update_step_SVD_Cython) + + if '_cont_discr_kalman_filter_raw' in attributes: + attributes['_cont_discr_kalman_filter_raw'] =\ + AddMethodToClass(state_space_cython. + _cont_discr_kalman_filter_raw_Cython) + + return super(DescreteStateSpaceMeta, + typeclass).__new__(typeclass, name, bases, attributes) + + +class DescreteStateSpace(object): + """ + This class implents state-space inference for linear and non-linear + state-space models. + Linear models are: + x_{k} = A_{k} * x_{k-1} + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Nonlinear: + x_{k} = f_a(k, x_{k-1}, A_{k}) + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + y_{k} = f_h(k, x_{k}, H_{k}) + r_{k}; r_{k-1} ~ N(0, R_{k}) + Here f_a and f_h are some functions of k (iteration number), x_{k-1} or + x_{k} (state value on certain iteration), A_{k} and H_{k} - Jacobian + matrices of f_a and f_h respectively. In the linear case they are exactly + A_{k} and H_{k}. + + + Currently two nonlinear Gaussian filter algorithms are implemented: + Extended Kalman Filter (EKF), Statistically linearized Filter (SLF), which + implementations are very similar. + + """ + __metaclass__ = DescreteStateSpaceMeta + + @staticmethod + def _reshape_input_data(shape, desired_dim=3): + """ + Static function returns the column-wise shape for for an input shape. + + Input: + -------------- + shape: tuple + Shape of an input array, so that it is always a column. + + desired_dim: int + desired shape of output. For Y data it should be 3 + (sample_no, dimension, ts_no). For X data - 2 (sample_no, 1) + Output: + -------------- + new_shape: tuple + New shape of the measurements array. Idea is that samples are + along dimension 0, sample dimension - dimension 1, different + time series - dimension 2. + old_shape: tuple or None + If the shape has been modified, return old shape, otherwise + None. + """ + + if (len(shape) > 3): + raise ValueError("""Input array is not supposed to be more + than 3 dimensional.""") + + if (len(shape) > desired_dim): + raise ValueError("Input array shape is more than desired shape.") + elif len(shape) == 1: + if (desired_dim == 3): + return ((shape[0], 1, 1), shape) # last dimension is the + # time serime_series_no + elif (desired_dim == 2): + return ((shape[0], 1), shape) + + elif len(shape) == 2: + if (desired_dim == 3): + return ((shape[1], 1, 1), shape) if (shape[0] == 1) else\ + ((shape[0], shape[1], 1), shape) # convert to column + # vector + elif (desired_dim == 2): + return ((shape[1], 1), shape) if (shape[0] == 1) else\ + ((shape[0], shape[1]), None) # convert to column vector + + else: # len(shape) == 3 + return (shape, None) # do nothing + + @classmethod + def kalman_filter(cls, p_A, p_Q, p_H, p_R, Y, index=None, m_init=None, + P_init=None, p_kalman_filter_type='regular', + calc_log_likelihood=False, + calc_grad_log_likelihood=False, grad_params_no=None, + grad_calc_params=None): + """ + This function implements the basic Kalman Filter algorithm + These notations for the State-Space model are assumed: + x_{k} = A_{k} * x_{k-1} + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated filter distributions x_{k} ~ N(m_{k}, P(k)) + + Current Features: + ---------------------------------------- + 1) The function generaly do not modify the passed parameters. If + it happens then it is an error. There are several exeprions: scalars + can be modified into a matrix, in some rare cases shapes of + the derivatives matrices may be changed, it is ignored for now. + + 2) Copies of p_A, p_Q, index are created in memory to be used later + in smoother. References to copies are kept in "matrs_for_smoother" + return parameter. + + 3) Function support "multiple time series mode" which means that exactly + the same State-Space model is used to filter several sets of measurements. + In this case third dimension of Y should include these state-space measurements + Log_likelihood and Grad_log_likelihood have the corresponding dimensions then. + + 4) Calculation of Grad_log_likelihood is not supported if matrices A,Q, + H, or R changes over time. (later may be changed) + + 5) Measurement may include missing values. In this case update step is + not done for this measurement. (later may be changed) + + Input: + ----------------- + + p_A: scalar, square matrix, 3D array + A_{k} in the model. If matrix then A_{k} = A - constant. + If it is 3D array then A_{k} = p_A[:,:, index[0,k]] + + p_Q: scalar, square symmetric matrix, 3D array + Q_{k-1} in the model. If matrix then Q_{k-1} = Q - constant. + If it is 3D array then Q_{k-1} = p_Q[:,:, index[1,k]] + + p_H: scalar, matrix (measurement_dim, state_dim) , 3D array + H_{k} in the model. If matrix then H_{k} = H - constant. + If it is 3D array then H_{k} = p_Q[:,:, index[2,k]] + + p_R: scalar, square symmetric matrix, 3D array + R_{k} in the model. If matrix then R_{k} = R - constant. + If it is 3D array then R_{k} = p_R[:,:, index[3,k]] + + Y: matrix or vector or 3D array + Data. If Y is matrix then samples are along 0-th dimension and + features along the 1-st. If 3D array then third dimension + correspond to "multiple time series mode". + + index: vector + Which indices (on 3-rd dimension) from arrays p_A, p_Q,p_H, p_R to use + on every time step. If this parameter is None then it is assumed + that p_A, p_Q, p_H, p_R do not change over time and indices are not needed. + index[0,:] - correspond to A, index[1,:] - correspond to Q + index[2,:] - correspond to H, index[3,:] - correspond to R. + If index.shape[0] == 1, it is assumed that indides for all matrices + are the same. + + m_init: vector or matrix + Initial distribution mean. If None it is assumed to be zero. + For "multiple time series mode" it is matrix, second dimension of + which correspond to different time series. In regular case ("one + time series mode") it is a vector. + + P_init: square symmetric matrix or scalar + Initial covariance of the states. If the parameter is scalar + then it is assumed that initial covariance matrix is unit matrix + multiplied by this scalar. If None the unit matrix is used instead. + "multiple time series mode" does not affect it, since it does not + affect anything related to state variaces. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then "grad_calc_params" parameter must + provide the extra parameters for gradient calculation. + + grad_params_no: int + If previous parameter is true, then this parameters gives the + total number of parameters in the gradient. + + grad_calc_params: dictionary + Dictionary with derivatives of model matrices with respect + to parameters "dA", "dQ", "dH", "dR", "dm_init", "dP_init". + They can be None, in this case zero matrices (no dependence on parameters) + is assumed. If there is only one parameter then third dimension is + automatically added. + + Output: + -------------- + + M: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array + Filter estimates of the state means. In the extra step the initial + value is included. In the "multiple time series mode" third dimension + correspond to different timeseries. + + P: (no_steps+1, state_dim, state_dim) 3D array + Filter estimates of the state covariances. In the extra step the initial + value is included. + + log_likelihood: double or (1, time_series_no) 3D array. + If the parameter calc_log_likelihood was set to true, return + logarithm of marginal likelihood of the state-space model. If + the parameter was false, return None. In the "multiple time series mode" it is a vector + providing log_likelihood for each time series. + + grad_log_likelihood: column vector or (grad_params_no, time_series_no) matrix + If calc_grad_log_likelihood is true, return gradient of log likelihood + with respect to parameters. It returns it column wise, so in + "multiple time series mode" gradients for each time series is in the + corresponding column. + + matrs_for_smoother: dict + Dictionary with model functions for smoother. The intrinsic model + functions are computed in this functions and they are returned to + use in smoother for convenience. They are: 'p_a', 'p_f_A', 'p_f_Q' + The dictionary contains the same fields. + """ + + #import pdb; pdb.set_trace() + + # Parameters checking -> + # index + p_A = np.atleast_1d(p_A) + p_Q = np.atleast_1d(p_Q) + p_H = np.atleast_1d(p_H) + p_R = np.atleast_1d(p_R) + + # Reshape and check measurements: + Y.shape, old_Y_shape = cls._reshape_input_data(Y.shape) + measurement_dim = Y.shape[1] + time_series_no = Y.shape[2] # multiple time series mode + + if ((len(p_A.shape) == 3) and (len(p_A.shape[2]) != 1)) or\ + ((len(p_Q.shape) == 3) and (len(p_Q.shape[2]) != 1)) or\ + ((len(p_H.shape) == 3) and (len(p_H.shape[2]) != 1)) or\ + ((len(p_R.shape) == 3) and (len(p_R.shape[2]) != 1)): + model_matrices_chage_with_time = True + else: + model_matrices_chage_with_time = False + + # Check index + old_index_shape = None + if index is None: + if (len(p_A.shape) == 3) or (len(p_Q.shape) == 3) or\ + (len(p_H.shape) == 3) or (len(p_R.shape) == 3): + raise ValueError("Parameter index can not be None for time varying matrices (third dimension is present)") + else: # matrices do not change in time, so form dummy zero indices. + index = np.zeros((1,Y.shape[0])) + else: + if len(index.shape) == 1: + index.shape = (1,index.shape[0]) + old_index_shape = (index.shape[0],) + + if (index.shape[1] != Y.shape[0]): + raise ValueError("Number of measurements must be equal the number of A_{k}, Q_{k}, H_{k}, R_{k}") + + if (index.shape[0] == 1): + A_time_var_index = 0; Q_time_var_index = 0 + H_time_var_index = 0; R_time_var_index = 0 + elif (index.shape[0] == 4): + A_time_var_index = 0; Q_time_var_index = 1 + H_time_var_index = 2; R_time_var_index = 3 + else: + raise ValueError("First Dimension of index must be either 1 or 4.") + + state_dim = p_A.shape[0] + # Check and make right shape for model matrices. On exit they all are 3 dimensional. Last dimension + # correspond to change in time. + (p_A, old_A_shape) = cls._check_SS_matrix(p_A, state_dim, measurement_dim, which='A') + (p_Q, old_Q_shape) = cls._check_SS_matrix(p_Q, state_dim, measurement_dim, which='Q') + (p_H, old_H_shape) = cls._check_SS_matrix(p_H, state_dim, measurement_dim, which='H') + (p_R, old_R_shape) = cls._check_SS_matrix(p_R, state_dim, measurement_dim, which='R') + + # m_init + if m_init is None: + m_init = np.zeros((state_dim, time_series_no)) + else: + m_init = np.atleast_2d(m_init).T + + # P_init + if P_init is None: + P_init = np.eye(state_dim) + elif not isinstance(P_init, collections.Iterable): #scalar + P_init = P_init*np.eye(state_dim) + + if p_kalman_filter_type not in ('regular', 'svd'): + raise ValueError("Kalman filer type neither 'regular nor 'svd'.") + + # Functions to pass to the kalman_filter algorithm: + # Parameters: + # k - number of Kalman filter iteration + # m - vector for calculating matrices. Required for EKF. Not used here. + + c_p_A = p_A.copy() # create a copy because this object is passed to the smoother + c_p_Q = p_Q.copy() # create a copy because this object is passed to the smoother + c_index = index.copy() # create a copy because this object is passed to the smoother + + if calc_grad_log_likelihood: + if model_matrices_chage_with_time: + raise ValueError("When computing likelihood gradient A and Q can not change over time.") + + dA = cls._check_grad_state_matrices(grad_calc_params.get('dA'), state_dim, grad_params_no, which = 'dA') + dQ = cls._check_grad_state_matrices(grad_calc_params.get('dQ'), state_dim, grad_params_no, which = 'dQ') + dH = cls._check_grad_measurement_matrices(grad_calc_params.get('dH'), state_dim, grad_params_no, measurement_dim, which = 'dH') + dR = cls._check_grad_measurement_matrices(grad_calc_params.get('dR'), state_dim, grad_params_no, measurement_dim, which = 'dR') + + dm_init = grad_calc_params.get('dm_init') + if dm_init is None: + # multiple time series mode. Keep grad_params always as a last dimension + dm_init = np.zeros((state_dim, time_series_no, grad_params_no)) + + dP_init = grad_calc_params.get('dP_init') + if dP_init is None: + dP_init = np.zeros((state_dim,state_dim,grad_params_no)) + else: + dA = None + dQ = None + dH = None + dR = None + dm_init = None + dP_init = None + + dynamic_callables = Std_Dynamic_Callables_Class(c_p_A, A_time_var_index, c_p_Q, c_index, Q_time_var_index, 20, dA, dQ) + measurement_callables = Std_Measurement_Callables_Class(p_H, H_time_var_index, p_R, index, R_time_var_index, 20, dH, dR) + + (M, P,log_likelihood, grad_log_likelihood, dynamic_callables) = \ + cls._kalman_algorithm_raw(state_dim, dynamic_callables, + measurement_callables, Y, m_init, + P_init, p_kalman_filter_type = p_kalman_filter_type, + calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + grad_params_no=grad_params_no, + dm_init=dm_init, dP_init=dP_init) + + # restore shapes so that input parameters are unchenged + if old_index_shape is not None: + index.shape = old_index_shape + + if old_Y_shape is not None: + Y.shape = old_Y_shape + + if old_A_shape is not None: + p_A.shape = old_A_shape + + if old_Q_shape is not None: + p_Q.shape = old_Q_shape + + if old_H_shape is not None: + p_H.shape = old_H_shape + + if old_R_shape is not None: + p_R.shape = old_R_shape + # Return values + + return (M, P,log_likelihood, grad_log_likelihood, dynamic_callables) + + @classmethod + def extended_kalman_filter(cls,p_state_dim, p_a, p_f_A, p_f_Q, p_h, p_f_H, p_f_R, Y, m_init=None, + P_init=None,calc_log_likelihood=False): + + """ + Extended Kalman Filter + + Input: + ----------------- + + p_state_dim: integer + + p_a: if None - the function from the linear model is assumed. No non- + linearity in the dynamic is assumed. + + function (k, x_{k-1}, A_{k}). Dynamic function. + k: (iteration number), + x_{k-1}: (previous state) + x_{k}: Jacobian matrices of f_a. In the linear case it is exactly A_{k}. + + p_f_A: matrix - in this case function which returns this matrix is assumed. + Look at this parameter description in kalman_filter function. + + function (k, m, P) return Jacobian of dynamic function, it is + passed into p_a. + + k: (iteration number), + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_Q: matrix. In this case function which returns this matrix is asumed. + Look at this parameter description in kalman_filter function. + + function (k). Returns noise matrix of dynamic model on iteration k. + k: (iteration number). + + p_h: if None - the function from the linear measurement model is assumed. + No nonlinearity in the measurement is assumed. + + function (k, x_{k}, H_{k}). Measurement function. + k: (iteration number), + x_{k}: (current state) + H_{k}: Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + + p_f_H: matrix - in this case function which returns this matrix is assumed. + function (k, m, P) return Jacobian of dynamic function, it is + passed into p_h. + k: (iteration number), + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_R: matrix. In this case function which returns this matrix is asumed. + function (k). Returns noise matrix of measurement equation + on iteration k. + k: (iteration number). + + Y: matrix or vector + Data. If Y is matrix then samples are along 0-th dimension and + features along the 1-st. May have missing values. + + p_mean: vector + Initial distribution mean. If None it is assumed to be zero + + P_init: square symmetric matrix or scalar + Initial covariance of the states. If the parameter is scalar + then it is assumed that initial covariance matrix is unit matrix + multiplied by this scalar. If None the unit matrix is used instead. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + """ + + # Y + Y.shape, old_Y_shape = cls._reshape_input_data(Y.shape) + + # m_init + if m_init is None: + m_init = np.zeros((p_state_dim,1)) + else: + m_init = np.atleast_2d(m_init).T + + # P_init + if P_init is None: + P_init = np.eye(p_state_dim) + elif not isinstance(P_init, collections.Iterable): #scalar + P_init = P_init*np.eye(p_state_dim) + + if p_a is None: + p_a = lambda k,m,A: np.dot(A, m) + + old_A_shape = None + if not isinstance(p_f_A, types.FunctionType): # not a function but array + p_f_A = np.atleast_1d(p_f_A) + (p_A, old_A_shape) = cls._check_A_matrix(p_f_A) + + p_f_A = lambda k, m, P: p_A[:,:, 0] # make function + else: + if p_f_A(1, m_init, P_init).shape[0] != m_init.shape[0]: + raise ValueError("p_f_A function returns matrix of wrong size") + + old_Q_shape = None + if not isinstance(p_f_Q, types.FunctionType): # not a function but array + p_f_Q = np.atleast_1d(p_f_Q) + (p_Q, old_Q_shape) = cls._check_Q_matrix(p_f_Q) + + p_f_Q = lambda k: p_Q[:,:, 0] # make function + else: + if p_f_Q(1).shape[0] != m_init.shape[0]: + raise ValueError("p_f_Q function returns matrix of wrong size") + + if p_h is None: + lambda k,m,H: np.dot(H, m) + + old_H_shape = None + if not isinstance(p_f_H, types.FunctionType): # not a function but array + p_f_H = np.atleast_1d(p_f_H) + (p_H, old_H_shape) = cls._check_H_matrix(p_f_H) + + p_f_H = lambda k, m, P: p_H # make function + else: + if p_f_H(1, m_init, P_init).shape[0] != Y.shape[1]: + raise ValueError("p_f_H function returns matrix of wrong size") + + old_R_shape = None + if not isinstance(p_f_R, types.FunctionType): # not a function but array + p_f_R = np.atleast_1d(p_f_R) + (p_R, old_R_shape) = cls._check_H_matrix(p_f_R) + + p_f_R = lambda k: p_R # make function + else: + if p_f_R(1).shape[0] != m_init.shape[0]: + raise ValueError("p_f_R function returns matrix of wrong size") + +# class dynamic_callables_class(Dynamic_Model_Callables): +# +# Ak = +# Qk = + + + class measurement_callables_class(R_handling_Class): + def __init__(self,R, index, R_time_var_index, unique_R_number): + super(measurement_callables_class,self).__init__(R, index, R_time_var_index, unique_R_number) + + Hk = AddMethodToClass(f_H) + f_h = AddMethodToClass(f_hl) + + + (M, P,log_likelihood, grad_log_likelihood) = cls._kalman_algorithm_raw(p_state_dim, p_a, p_f_A, p_f_Q, p_h, p_f_H, p_f_R, Y, m_init, + P_init, calc_log_likelihood, + calc_grad_log_likelihood=False, grad_calc_params=None) + + if old_Y_shape is not None: + Y.shape = old_Y_shape + + if old_A_shape is not None: + p_A.shape = old_A_shape + + if old_Q_shape is not None: + p_Q.shape = old_Q_shape + + if old_H_shape is not None: + p_H.shape = old_H_shape + + if old_R_shape is not None: + p_R.shape = old_R_shape + + return (M, P) + + @classmethod + def _kalman_algorithm_raw(cls,state_dim, p_dynamic_callables, p_measurement_callables, Y, m_init, + P_init, p_kalman_filter_type='regular', + calc_log_likelihood=False, + calc_grad_log_likelihood=False, grad_params_no=None, + dm_init=None, dP_init=None): + """ + General nonlinear filtering algorithm for inference in the state-space + model: + + x_{k} = f_a(k, x_{k-1}, A_{k}) + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + y_{k} = f_h(k, x_{k}, H_{k}) + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated filter distributions x_{k} ~ N(m_{k}, P(k)) + + Current Features: + ---------------------------------------- + + 1) Function support "multiple time series mode" which means that exactly + the same State-Space model is used to filter several sets of measurements. + In this case third dimension of Y should include these state-space measurements + Log_likelihood and Grad_log_likelihood have the corresponding dimensions then. + + 2) Measurement may include missing values. In this case update step is + not done for this measurement. (later may be changed) + + Input: + ----------------- + state_dim: int + Demensionality of the states + + p_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), + x_{k-1} + A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}. + + p_f_A: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_a. + k (iteration number), + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_Q: function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). + + p_h: function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), + x_{k} + H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + + p_f_H: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_h. + k (iteration number), + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_R: function (k). Returns noise matrix of measurement equation + on iteration k. + k (iteration number). + + Y: matrix or vector or 3D array + Data. If Y is matrix then samples are along 0-th dimension and + features along the 1-st. If 3D array then third dimension + correspond to "multiple time series mode". + + m_init: vector or matrix + Initial distribution mean. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. In regular case ("one time series mode") it is a + vector. + + P_init: matrix or scalar + Initial covariance of the states. Must be not None + "multiple time series mode" does not affect it, since it does not + affect anything related to state variaces. + + p_kalman_filter_type: string + + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + grad_calc_params: dictionary + Dictionary with derivatives of model matrices with respect + to parameters "dA", "dQ", "dH", "dR", "dm_init", "dP_init". + + Output: + -------------- + + M: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array + Filter estimates of the state means. In the extra step the initial + value is included. In the "multiple time series mode" third dimension + correspond to different timeseries. + + P: (no_steps+1, state_dim, state_dim) 3D array + Filter estimates of the state covariances. In the extra step the initial + value is included. + + log_likelihood: double or (1, time_series_no) 3D array. + If the parameter calc_log_likelihood was set to true, return + logarithm of marginal likelihood of the state-space model. If + the parameter was false, return None. In the "multiple time series mode" it is a vector + providing log_likelihood for each time series. + + grad_log_likelihood: column vector or (grad_params_no, time_series_no) matrix + If calc_grad_log_likelihood is true, return gradient of log likelihood + with respect to parameters. It returns it column wise, so in + "multiple time series mode" gradients for each time series is in the + corresponding column. + + """ + + steps_no = Y.shape[0] # number of steps in the Kalman Filter + time_series_no = Y.shape[2] # multiple time series mode + + # Allocate space for results + # Mean estimations. Initial values will be included + M = np.empty(((steps_no+1),state_dim,time_series_no)) + M[0,:,:] = m_init # Initialize mean values + # Variance estimations. Initial values will be included + P = np.empty(((steps_no+1),state_dim,state_dim)) + P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + P[0,:,:] = P_init # Initialize initial covariance matrix + + if p_kalman_filter_type == 'svd': + (U,S,Vh) = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + P_upd = (P_init, S,U) + + log_likelihood = 0 if calc_log_likelihood else None + grad_log_likelihood = 0 if calc_grad_log_likelihood else None + + #setting initial values for derivatives update + dm_upd = dm_init + dP_upd = dP_init + # Main loop of the Kalman filter + for k in range(0,steps_no): + # In this loop index for new estimations is (k+1), old - (k) + # This happened because initial values are stored at 0-th index. + + prev_mean = M[k,:,:] # mean from the previous step + + if p_kalman_filter_type == 'svd': + m_pred, P_pred, dm_pred, dP_pred = \ + cls._kalman_prediction_step_SVD(k, prev_mean ,P_upd, p_dynamic_callables, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_upd, p_dP = dP_upd) + else: + m_pred, P_pred, dm_pred, dP_pred = \ + cls._kalman_prediction_step(k, prev_mean ,P[k,:,:], p_dynamic_callables, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_upd, p_dP = dP_upd ) + + k_measurment = Y[k,:,:] + + if (np.any(np.isnan(k_measurment)) == False): + if p_kalman_filter_type == 'svd': + m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + cls._kalman_update_step_SVD(k, m_pred , P_pred, p_measurement_callables, + k_measurment, calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_pred, p_dP = dP_pred ) + + + # m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + # cls._kalman_update_step(k, m_pred , P_pred[0], f_h, f_H, p_R.f_R, k_measurment, + # calc_log_likelihood=calc_log_likelihood, + # calc_grad_log_likelihood=calc_grad_log_likelihood, + # p_dm = dm_pred, p_dP = dP_pred, grad_calc_params_2 = (dH, dR)) + # + # (U,S,Vh) = sp.linalg.svd( P_upd,full_matrices=False, compute_uv=True, + # overwrite_a=False,check_finite=True) + # P_upd = (P_upd, S,U) + else: + m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + cls._kalman_update_step(k, m_pred , P_pred, p_measurement_callables, k_measurment, + calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_pred, p_dP = dP_pred ) + + else: +# if k_measurment.shape != (1,1): +# raise ValueError("Nan measurements are currently not supported for \ +# multidimensional output and multiple time series.") +# else: +# m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred +# log_likelihood_update = 0.0; +# d_log_likelihood_update = 0.0; + + if not np.all(np.isnan(k_measurment)): + raise ValueError("""Nan measurements are currently not supported if + they are intermixed with not NaN measurements""") + else: + m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred + if calc_log_likelihood: + log_likelihood_update = np.zeros((time_series_no,)) + if calc_grad_log_likelihood: + d_log_likelihood_update = np.zeros((grad_params_no,time_series_no)) + + + if calc_log_likelihood: + log_likelihood += log_likelihood_update + + if calc_grad_log_likelihood: + grad_log_likelihood += d_log_likelihood_update + + M[k+1,:,:] = m_upd # separate mean value for each time series + + if p_kalman_filter_type == 'svd': + P[k+1,:,:] = P_upd[0] + else: + P[k+1,:,:] = P_upd + + # !!!Print statistics! Print sizes of matrices + # !!!Print statistics! Print iteration time base on another boolean variable + return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) + + @staticmethod + def _kalman_prediction_step(k, p_m , p_P, p_dyn_model_callable, calc_grad_log_likelihood=False, + p_dm = None, p_dP = None): + """ + Desctrete prediction function + + Input: + k:int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + p_m: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: + Covariance matrix from the previous step. + + p_dyn_model_callable: class + + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the previous step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: 3D array (state_dim, state_dim, parameters_no) + Mean derivatives from the previous step + + Output: + ---------------------------- + m_pred, P_pred, dm_pred, dP_pred: metrices, 3D objects + Results of the prediction steps. + + """ + + # index correspond to values from previous iteration. + A = p_dyn_model_callable.Ak(k,p_m,p_P) # state transition matrix (or Jacobian) + Q = p_dyn_model_callable.Qk(k) # state noise matrix + + # Prediction step -> + m_pred = p_dyn_model_callable.f_a(k, p_m, A) # predicted mean + P_pred = A.dot(p_P).dot(A.T) + Q # predicted variance + # Prediction step <- + + if calc_grad_log_likelihood: + dA_all_params = p_dyn_model_callable.dAk(k) # derivatives of A wrt parameters + dQ_all_params = p_dyn_model_callable.dQk(k) # derivatives of Q wrt parameters + + param_number = p_dP.shape[2] + + # p_dm, p_dP - derivatives form the previoius step + dm_pred = np.empty(p_dm.shape) + dP_pred = np.empty(p_dP.shape) + + for j in range(param_number): + dA = dA_all_params[:,:,j] + dQ = dQ_all_params[:,:,j] + + dP = p_dP[:,:,j] + dm = p_dm[:,:,j] + dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, dm) + # prediction step derivatives for current parameter: + + dP_pred[:,:,j] = np.dot( dA ,np.dot(p_P, A.T)) + dP_pred[:,:,j] += dP_pred[:,:,j].T + dP_pred[:,:,j] += np.dot( A ,np.dot(dP, A.T)) + dQ + + dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + else: + dm_pred = None + dP_pred = None + + return m_pred, P_pred, dm_pred, dP_pred + + @staticmethod + def _kalman_prediction_step_SVD(k, p_m , p_P, p_dyn_model_callable, calc_grad_log_likelihood=False, + p_dm = None, p_dP = None): + """ + Desctrete prediction function + + Input: + k:int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + p_m: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: tuple (Prev_cov, S, V) + Covariance matrix from the previous step and its SVD decomposition. + Prev_cov = V * S * V.T The tuple is (Prev_cov, S, V) + + p_dyn_model_callable: object + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the previous step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: 3D array (state_dim, state_dim, parameters_no) + Mean derivatives from the previous step + + Output: + ---------------------------- + m_pred, P_pred, dm_pred, dP_pred: metrices, 3D objects + Results of the prediction steps. + + """ + + # covariance from the previous step and its SVD decomposition + # p_prev_cov = v * S * V.T + Prev_cov, S_old, V_old = p_P + #p_prev_cov_tst = np.dot(p_V, (p_S * p_V).T) # reconstructed covariance from the previous step + + # index correspond to values from previous iteration. + A = p_dyn_model_callable.Ak(k,p_m,Prev_cov) # state transition matrix (or Jacobian) + Q = p_dyn_model_callable.Qk(k) # state noise matrx. This is necessary for the square root calculation (next step) + Q_sr = p_dyn_model_callable.Q_srk(k) + # Prediction step -> + m_pred = p_dyn_model_callable.f_a(k, p_m, A) # predicted mean + + # coavariance prediction have changed: + svd_1_matr = np.vstack( ( (np.sqrt(S_old)* np.dot(A,V_old)).T , Q_sr.T) ) + (U,S,Vh) = sp.linalg.svd( svd_1_matr,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + # predicted variance computed by the regular method. For testing + #P_pred_tst = A.dot(Prev_cov).dot(A.T) + Q + V_new = Vh.T + S_new = S**2 + + P_pred = np.dot(V_new * S_new, V_new.T) # prediction covariance + P_pred = (P_pred, S_new, Vh.T) + # Prediction step <- + + # derivatives + if calc_grad_log_likelihood: + dA_all_params = p_dyn_model_callable.dAk(k) # derivatives of A wrt parameters + dQ_all_params = p_dyn_model_callable.dQk(k) # derivatives of Q wrt parameters + + param_number = p_dP.shape[2] + + # p_dm, p_dP - derivatives form the previoius step + dm_pred = np.empty(p_dm.shape) + dP_pred = np.empty(p_dP.shape) + + for j in range(param_number): + dA = dA_all_params[:,:,j] + dQ = dQ_all_params[:,:,j] + + #dP = p_dP[:,:,j] + #dm = p_dm[:,:,j] + dm_pred[:,:,j] = np.dot(dA, p_m) + np.dot(A, p_dm[:,:,j]) + # prediction step derivatives for current parameter: + + + dP_pred[:,:,j] = np.dot( dA ,np.dot(Prev_cov, A.T)) + dP_pred[:,:,j] += dP_pred[:,:,j].T + dP_pred[:,:,j] += np.dot( A ,np.dot(p_dP[:,:,j], A.T)) + dQ + + dP_pred[:,:,j] = 0.5*(dP_pred[:,:,j] + dP_pred[:,:,j].T) #symmetrize + else: + dm_pred = None + dP_pred = None + + return m_pred, P_pred, dm_pred, dP_pred + + @staticmethod + def _kalman_update_step(k, p_m , p_P, p_meas_model_callable, measurement, calc_log_likelihood= False, + calc_grad_log_likelihood=False, p_dm = None, p_dP = None): + """ + Input: + + k: int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + m_P: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: + Covariance matrix from the prediction step. + + p_meas_model_callable: object + + measurement: (measurement_dim, time_series_no) matrix + One measurement used on the current update step. For + "multiple time series mode" it is matrix, second dimension of + which correspond to different time series. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the prediction step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: array + Covariance derivatives from the prediction step. + + Output: + ---------------------------- + m_upd, P_upd, dm_upd, dP_upd: metrices, 3D objects + Results of the prediction steps. + + log_likelihood_update: double or 1D array + Update to the log_likelihood from this step + + d_log_likelihood_update: (grad_params_no, time_series_no) matrix + Update to the gradient of log_likelihood, "multiple time series mode" + adds extra columns to the gradient. + + """ + #import pdb; pdb.set_trace() + + m_pred = p_m # from prediction step + P_pred = p_P # from prediction step + + H = p_meas_model_callable.Hk(k, m_pred, P_pred) + R = p_meas_model_callable.Rk(k) + + time_series_no = p_m.shape[1] # number of time serieses + + log_likelihood_update=None; dm_upd=None; dP_upd=None; d_log_likelihood_update=None + # Update step (only if there is data) + #if not np.any(np.isnan(measurement)): # TODO: if some dimensions are missing, do properly computations for other. + v = measurement-p_meas_model_callable.f_h(k, m_pred, H) + S = H.dot(P_pred).dot(H.T) + R + if measurement.shape[0]==1: # measurements are one dimensional + if (S < 0): + raise ValueError("Kalman Filter Update: S is negative step %i" % k ) + #import pdb; pdb.set_trace() + + K = P_pred.dot(H.T) / S + if calc_log_likelihood: + log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + v*v / S) + #log_likelihood_update = log_likelihood_update[0,0] # to make int + if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + raise ValueError("Nan values in likelihood update!") + LL = None; islower = None + else: + LL,islower = linalg.cho_factor(S) + K = linalg.cho_solve((LL,islower), H.dot(P_pred.T)).T + + if calc_log_likelihood: + log_likelihood_update = -0.5 * ( v.shape[0]*np.log(2*np.pi) + + 2*np.sum( np.log(np.diag(LL)) ) +\ + np.sum((linalg.cho_solve((LL,islower),v)) * v, axis = 0) ) # diagonal of v.T*S^{-1}*v + + if calc_grad_log_likelihood: + dm_pred_all_params = p_dm # derivativas of the prediction phase + dP_pred_all_params = p_dP + + param_number = p_dP.shape[2] + + dH_all_params = p_meas_model_callable.dHk(k) + dR_all_params = p_meas_model_callable.dRk(k) + + dm_upd = np.empty(dm_pred_all_params.shape) + dP_upd = np.empty(dP_pred_all_params.shape) + + # firts dimension parameter_no, second - time series number + d_log_likelihood_update = np.empty((param_number,time_series_no)) + for param in range(param_number): + + dH = dH_all_params[:,:,param] + dR = dR_all_params[:,:,param] + + dm_pred = dm_pred_all_params[:,:,param] + dP_pred = dP_pred_all_params[:,:,param] + + # Terms in the likelihood derivatives + dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) + dS = np.dot(dH, np.dot( P_pred, H.T)) + dS += dS.T + dS += np.dot(H, np.dot( dP_pred, H.T)) + dR + + # TODO: maybe symmetrize dS + + #dm and dP for the next stem + if LL is not None: # the state vector is not a scalar + tmp1 = linalg.cho_solve((LL,islower), H).T + tmp2 = linalg.cho_solve((LL,islower), dH).T + tmp3 = linalg.cho_solve((LL,islower), dS).T + else: # the state vector is a scalar + tmp1 = H.T / S + tmp2 = dH.T / S + tmp3 = dS.T / S + + dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ + np.dot( P_pred, np.dot( tmp1, tmp3 ) ) + + # terms required for the next step, save this for each parameter + dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) + + dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + dP_upd[:,:,param] += dP_upd[:,:,param].T + dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + + dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + # computing the likelihood change for each parameter: + if LL is not None: # the state vector is not 1D + #tmp4 = linalg.cho_solve((LL,islower), dv) + tmp5 = linalg.cho_solve((LL,islower), v) + else: # the state vector is a scalar + #tmp4 = dv / S + tmp5 = v / S + + + d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ + np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + # Before + #d_log_likelihood_update[param,0] = -(0.5*np.sum(np.diag(tmp3)) + \ + #np.dot(tmp5.T, dv) - 0.5 * np.dot(tmp5.T ,np.dot(dS, tmp5)) ) + + + + # Compute the actual updates for mean and variance of the states. + m_upd = m_pred + K.dot( v ) + + # Covariance update and ensure it is symmetric + P_upd = K.dot(S).dot(K.T) + P_upd = 0.5*(P_upd + P_upd.T) + P_upd = P_pred - P_upd# this update matrix is symmetric + + return m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update + + @staticmethod + def _kalman_update_step_SVD(k, p_m , p_P, p_meas_model_callable, measurement, calc_log_likelihood= False, + calc_grad_log_likelihood=False, p_dm = None, p_dP = None): + """ + Input: + + k: int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + m_P: matrix of size (state_dim, time_series_no) + Mean value from the previous step. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. + + p_P: tuple (P_pred, S, V) + Covariance matrix from the prediction step and its SVD decomposition. + P_pred = V * S * V.T The tuple is (P_pred, S, V) + + p_h: function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), starts at 0 + x_{k} state + H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + + p_f_H: function (k, m, P) return Jacobian of measurement function, it is + passed into p_h. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_R: function (k). Returns noise matrix of measurement equation + on iteration k. + k (iteration number). starts at 0 + + p_f_iRsr: function (k). Returns the square root of the noise matrix of + measurement equation on iteration k. + k (iteration number). starts at 0 + + measurement: (measurement_dim, time_series_no) matrix + One measurement used on the current update step. For + "multiple time series mode" it is matrix, second dimension of + which correspond to different time series. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + p_dm: 3D array (state_dim, time_series_no, parameters_no) + Mean derivatives from the prediction step. For "multiple time series mode" + it is 3D array, second dimension of which correspond to different + time series. + + p_dP: array + Covariance derivatives from the prediction step. + + grad_calc_params_2: List or None + List with derivatives. The first component is 'f_dH' - function(k) + which returns the derivative of H. The second element is 'f_dR' + - function(k). Function which returns the derivative of R. + + Output: + ---------------------------- + m_upd, P_upd, dm_upd, dP_upd: metrices, 3D objects + Results of the prediction steps. + + log_likelihood_update: double or 1D array + Update to the log_likelihood from this step + + d_log_likelihood_update: (grad_params_no, time_series_no) matrix + Update to the gradient of log_likelihood, "multiple time series mode" + adds extra columns to the gradient. + + """ + + #import pdb; pdb.set_trace() + + m_pred = p_m # from prediction step + P_pred,S_pred,V_pred = p_P # from prediction step + + H = p_meas_model_callable.Hk(k, m_pred, P_pred) + R = p_meas_model_callable.Rk(k) + R_isr = p_meas_model_callable.R_isrk(k) # square root of the inverse of R matrix + + time_series_no = p_m.shape[1] # number of time serieses + + log_likelihood_update=None; dm_upd=None; dP_upd=None; d_log_likelihood_update=None + # Update step (only if there is data) + #if not np.any(np.isnan(measurement)): # TODO: if some dimensions are missing, do properly computations for other. + v = measurement-p_meas_model_callable.f_h(k, m_pred, H) + + svd_2_matr = np.vstack( ( np.dot( R_isr.T, np.dot(H, V_pred)) , np.diag( 1.0/np.sqrt(S_pred) ) ) ) + + (U,S,Vh) = sp.linalg.svd( svd_2_matr,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + + # P_upd = U_upd S_upd**2 U_upd.T + U_upd = np.dot(V_pred, Vh.T) + S_upd = (1.0/S)**2 + + P_upd = np.dot(U_upd * S_upd, U_upd.T) # update covariance + P_upd = (P_upd,S_upd,U_upd) # tuple to pass to the next step + + # stil need to compute S and K for derivative computation + S = H.dot(P_pred).dot(H.T) + R + if measurement.shape[0]==1: # measurements are one dimensional + if (S < 0): + raise ValueError("Kalman Filter Update: S is negative step %i" % k ) + #import pdb; pdb.set_trace() + + K = P_pred.dot(H.T) / S + if calc_log_likelihood: + log_likelihood_update = -0.5 * ( np.log(2*np.pi) + np.log(S) + + v*v / S) + #log_likelihood_update = log_likelihood_update[0,0] # to make int + if np.any(np.isnan(log_likelihood_update)): # some member in P_pred is None. + raise ValueError("Nan values in likelihood update!") + LL = None; islower = None + else: + LL,islower = linalg.cho_factor(S) + K = linalg.cho_solve((LL,islower), H.dot(P_pred.T)).T + + if calc_log_likelihood: + log_likelihood_update = -0.5 * ( v.shape[0]*np.log(2*np.pi) + + 2*np.sum( np.log(np.diag(LL)) ) +\ + np.sum((linalg.cho_solve((LL,islower),v)) * v, axis = 0) ) # diagonal of v.T*S^{-1}*v + + + # Old method of computing updated covariance (for testing) -> + #P_upd_tst = K.dot(S).dot(K.T) + #P_upd_tst = 0.5*(P_upd_tst + P_upd_tst.T) + #P_upd_tst = P_pred - P_upd_tst# this update matrix is symmetric + # Old method of computing updated covariance (for testing) <- + + if calc_grad_log_likelihood: + dm_pred_all_params = p_dm # derivativas of the prediction phase + dP_pred_all_params = p_dP + + param_number = p_dP.shape[2] + + dH_all_params = p_meas_model_callable.dHk(k) + dR_all_params = p_meas_model_callable.dRk(k) + + dm_upd = np.empty(dm_pred_all_params.shape) + dP_upd = np.empty(dP_pred_all_params.shape) + + # firts dimension parameter_no, second - time series number + d_log_likelihood_update = np.empty((param_number,time_series_no)) + for param in range(param_number): + + dH = dH_all_params[:,:,param] + dR = dR_all_params[:,:,param] + + dm_pred = dm_pred_all_params[:,:,param] + dP_pred = dP_pred_all_params[:,:,param] + + # Terms in the likelihood derivatives + dv = - np.dot( dH, m_pred) - np.dot( H, dm_pred) + dS = np.dot(dH, np.dot( P_pred, H.T)) + dS += dS.T + dS += np.dot(H, np.dot( dP_pred, H.T)) + dR + + # TODO: maybe symmetrize dS + + #dm and dP for the next stem + if LL is not None: # the state vector is not a scalar + tmp1 = linalg.cho_solve((LL,islower), H).T + tmp2 = linalg.cho_solve((LL,islower), dH).T + tmp3 = linalg.cho_solve((LL,islower), dS).T + else: # the state vector is a scalar + tmp1 = H.T / S + tmp2 = dH.T / S + tmp3 = dS.T / S + + dK = np.dot( dP_pred, tmp1) + np.dot( P_pred, tmp2) - \ + np.dot( P_pred, np.dot( tmp1, tmp3 ) ) + + # terms required for the next step, save this for each parameter + dm_upd[:,:,param] = dm_pred + np.dot(dK, v) + np.dot(K, dv) + + dP_upd[:,:,param] = -np.dot(dK, np.dot(S, K.T)) + dP_upd[:,:,param] += dP_upd[:,:,param].T + dP_upd[:,:,param] += dP_pred - np.dot(K , np.dot( dS, K.T)) + + dP_upd[:,:,param] = 0.5*(dP_upd[:,:,param] + dP_upd[:,:,param].T) #symmetrize + # computing the likelihood change for each parameter: + if LL is not None: # the state vector is not 1D + tmp5 = linalg.cho_solve((LL,islower), v) + else: # the state vector is a scalar + tmp5 = v / S + + + d_log_likelihood_update[param,:] = -(0.5*np.sum(np.diag(tmp3)) + \ + np.sum(tmp5*dv, axis=0) - 0.5 * np.sum(tmp5 * np.dot(dS, tmp5), axis=0) ) + # Before + #d_log_likelihood_update[param,0] = -(0.5*np.sum(np.diag(tmp3)) + \ + #np.dot(tmp5.T, dv) - 0.5 * np.dot(tmp5.T ,np.dot(dS, tmp5)) ) + + # Compute the actual updates for mean of the states. Variance update + # is computed earlier. + m_upd = m_pred + K.dot( v ) + + return m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update + + @staticmethod + def _rts_smoother_update_step(k, p_m , p_P, p_m_pred, p_P_pred, p_m_prev_step, + p_P_prev_step, p_dynamic_callables): + """ + Rauch–Tung–Striebel(RTS) update step + + Input: + ----------------------------- + k: int + Iteration No. Starts at 0. Total number of iterations equal to the + number of measurements. + + p_m: matrix of size (state_dim, time_series_no) + Filter mean on step k + + p_P: matrix of size (state_dim,state_dim) + Filter Covariance on step k + + p_m_pred: matrix of size (state_dim, time_series_no) + Means from the smoother prediction step. + + p_P_pred: + Covariance from the smoother prediction step. + + p_m_prev_step + Smoother mean from the previous step. + + p_P_prev_step: + Smoother covariance from the previous step. + + p_f_A: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_a. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + """ + + A = p_dynamic_callables.Ak(k,p_m,p_P) # state transition matrix (or Jacobian) + + tmp = np.dot( A, p_P.T) + if A.shape[0] == 1: # 1D states + G = tmp.T / p_P_pred # P[:,:,k] is symmetric + else: + try: + LL,islower = linalg.cho_factor(p_P_pred) + G = linalg.cho_solve((LL,islower),tmp).T + except: + # It happende that p_P_pred has several near zero eigenvalues + # hence the Cholesky method does not work. + res = sp.linalg.lstsq(p_P_pred, tmp) + G = res[0].T + + m_upd = p_m + G.dot( p_m_prev_step-p_m_pred ) + P_upd = p_P + G.dot( p_P_prev_step-p_P_pred).dot(G.T) + + P_upd = 0.5*(P_upd + P_upd.T) + + return m_upd, P_upd, G + + @classmethod + def rts_smoother(cls,state_dim, p_dynamic_callables, filter_means, + filter_covars): + """ + This function implements Rauch–Tung–Striebel(RTS) smoother algorithm + based on the results of kalman_filter_raw. + These notations are the same: + x_{k} = A_{k} * x_{k-1} + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated smoother distributions x_{k} ~ N(m_{k}, P(k)) + + Input: + -------------- + + p_a: function (k, x_{k-1}, A_{k}). Dynamic function. + k (iteration number), starts at 0 + x_{k-1} State from the previous step + A_{k} Jacobian matrices of f_a. In the linear case it is exactly A_{k}. + + p_f_A: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_a. + k (iteration number), starts at 0 + m: point where Jacobian is evaluated + P: parameter for Jacobian, usually covariance matrix. + + p_f_Q: function (k). Returns noise matrix of dynamic model on iteration k. + k (iteration number). starts at 0 + + filter_means: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array + Results of the Kalman Filter means estimation. + + filter_covars: (no_steps+1, state_dim, state_dim) 3D array + Results of the Kalman Filter covariance estimation. + + Output: + ------------- + + M: (no_steps+1, state_dim) matrix + Smoothed estimates of the state means + + P: (no_steps+1, state_dim, state_dim) 3D array + Smoothed estimates of the state covariances + """ + + no_steps = filter_covars.shape[0]-1# number of steps (minus initial covariance) + + M = np.empty(filter_means.shape) # smoothed means + P = np.empty(filter_covars.shape) # smoothed covars + #G = np.empty( (no_steps,state_dim,state_dim) ) # G from the update step of the smoother + + M[-1,:] = filter_means[-1,:] + P[-1,:,:] = filter_covars[-1,:,:] + for k in range(no_steps-1,-1,-1): + + m_pred, P_pred, tmp1, tmp2 = \ + cls._kalman_prediction_step(k, filter_means[k,:], + filter_covars[k,:,:], p_dynamic_callables, + calc_grad_log_likelihood=False) + p_m = filter_means[k,:] + if len(p_m.shape)<2: + p_m.shape = (p_m.shape[0],1) + + p_m_prev_step = M[k+1,:] + if len(p_m_prev_step.shape)<2: + p_m_prev_step.shape = (p_m_prev_step.shape[0],1) + + m_upd, P_upd, G_tmp = cls._rts_smoother_update_step(k, + p_m ,filter_covars[k,:,:], + m_pred, P_pred, p_m_prev_step ,P[k+1,:,:], p_dynamic_callables) + + M[k,:] = m_upd#np.squeeze(m_upd) + P[k,:,:] = P_upd + #G[k,:,:] = G_upd.T # store transposed G. + # Return values + + return (M, P) #, G) + + @staticmethod + def _EM_gradient(A,Q,H,R,m_init,P_init,measurements, M, P, G, dA, dQ, dH, dR, dm_init, dP_init): + """ + Gradient computation with the EM algorithm. + + Input: + ----------------- + + M: Means from the smoother + P: Variances from the smoother + G: Gains? from the smoother + """ + import pdb; pdb.set_trace(); + + param_number = dA.shape[-1] + d_log_likelihood_update = np.empty((param_number,1)) + + sample_no = measurements.shape[0] + P_1 = P[1:,:,:] # remove 0-th step + P_2 = P[0:-1,:,:] # remove 0-th step + + M_1 = M[1:,:] # remove 0-th step + M_2 = M[0:-1,:] # remove the last step + + Sigma = np.mean(P_1,axis=0) + np.dot(M_1.T, M_1) / sample_no # + Phi = np.mean(P_2,axis=0) + np.dot(M_2.T, M_2) / sample_no # + + B = np.dot( measurements.T, M_1 )/ sample_no + C = (sp.einsum( 'ijk,ikl', P_1, G) + np.dot(M_1.T, M_2)) / sample_no # + +# C1 = np.zeros( (P_1.shape[1],P_1.shape[1]) ) +# for k in range(P_1.shape[0]): +# C1 += np.dot(P_1[k,:,:],G[k,:,:]) + sp.outer( M_1[k,:], M_2[k,:] ) +# C1 = C1 / sample_no + + D = np.dot( measurements.T, measurements ) / sample_no + + try: + P_init_inv = sp.linalg.inv(P_init) + + if np.max( np.abs(P_init_inv)) > 10e13: + compute_P_init_terms = False + else: + compute_P_init_terms = True + except np.linalg.LinAlgError: + compute_P_init_terms = False + + try: + Q_inv = sp.linalg.inv(Q) + + if np.max( np.abs(Q_inv)) > 10e13: + compute_Q_terms = False + else: + compute_Q_terms = True + except np.linalg.LinAlgError: + compute_Q_terms = False + + try: + R_inv = sp.linalg.inv(R) + + if np.max( np.abs(R_inv)) > 10e13: + compute_R_terms = False + else: + compute_R_terms = True + except np.linalg.LinAlgError: + compute_R_terms = False + + + d_log_likelihood_update = np.zeros((param_number,1)) + for j in range(param_number): + if compute_P_init_terms: + d_log_likelihood_update[j,:] -= 0.5 * np.sum(P_init_inv* dP_init[:,:,j].T ) #p #m + + M0_smoothed = M[0]; M0_smoothed.shape = (M0_smoothed.shape[0],1) + tmp1 = np.dot( dP_init[:,:,j], np.dot( P_init_inv, (P[0,:,:] + sp.outer( (M0_smoothed - m_init), (M0_smoothed - m_init) )) ) ) #p #m + d_log_likelihood_update[j,:] += 0.5 * np.sum(P_init_inv* tmp1.T ) + + tmp2 = sp.outer( dm_init[:,j], M0_smoothed ) + tmp2 += tmp2.T + d_log_likelihood_update[j,:] += 0.5 * np.sum(P_init_inv* tmp2.T ) + + if compute_Q_terms: + + d_log_likelihood_update[j,:] -= sample_no/2.0 * np.sum(Q_inv* dQ[:,:,j].T ) #m + + tmp1 = np.dot(C,A.T); tmp1 += tmp1.T; tmp1 = Sigma - tmp1 + np.dot(A, np.dot(Phi,A.T)) #m + tmp1 = np.dot( dQ[:,:,j], np.dot( Q_inv, tmp1) ) + d_log_likelihood_update[j,:] += sample_no/2.0 * np.sum(Q_inv * tmp1.T) + + tmp2 = np.dot( dA[:,:,j], C.T); tmp2 += tmp2.T; + tmp3 = np.dot(dA[:,:,j], np.dot(Phi,A.T)); tmp3 += tmp3.T + d_log_likelihood_update[j,:] -= sample_no/2.0 * np.sum(Q_inv.T * (tmp3 - tmp2) ) + + if compute_R_terms: + d_log_likelihood_update[j,:] -= sample_no/2.0 * np.sum(R_inv* dR[:,:,j].T ) + + tmp1 = np.dot(B,H.T); tmp1 += tmp1.T; tmp1 = D - tmp1 + np.dot(H, np.dot(Sigma,H.T)) + tmp1 = np.dot( dR[:,:,j], np.dot( R_inv, tmp1) ) + d_log_likelihood_update[j,:] += sample_no/2.0 * np.sum(R_inv * tmp1.T) + + tmp2 = np.dot( dH[:,:,j], B.T); tmp2 += tmp2.T; + tmp3 = np.dot(dH[:,:,j], np.dot(Sigma,H.T)); tmp3 += tmp3.T + d_log_likelihood_update[j,:] -= sample_no/2.0 * np.sum(R_inv.T * (tmp3 - tmp2) ) + + return d_log_likelihood_update + + @staticmethod + def _check_SS_matrix(p_M, state_dim, measurement_dim, which='A'): + """ + Veryfy that on exit the matrix has appropriate shape for the KF algorithm. + + Input: + p_M: matrix + As it is given for the user + state_dim: int + State dimensioanlity + measurement_dim: int + Measurement dimensionality + which: string + One of: 'A', 'Q', 'H', 'R' + Output: + --------------- + p_M: matrix of the right shape + + old_M_shape: tuple + Old Shape + """ + + old_M_shape = None + if len(p_M.shape) < 3: # new shape is 3 dimensional + old_M_shape = p_M.shape # save shape to restore it on exit + if len(p_M.shape) == 2: # matrix + p_M.shape = (p_M.shape[0],p_M.shape[1],1) + elif len(p_M.shape) == 1: # scalar but in array already + if (p_M.shape[0] != 1): + raise ValueError("Matrix %s is an 1D array, while it must be a matrix or scalar", which) + else: + p_M.shape = (1,1,1) + + if (which == 'A') or (which == 'Q'): + if (p_M.shape[0] != state_dim) or (p_M.shape[1] != state_dim): + raise ValueError("%s must be a square matrix of size (%i,%i)" % (which, state_dim, state_dim)) + if (which == 'H'): + if (p_M.shape[0] != measurement_dim) or (p_M.shape[1] != state_dim): + raise ValueError("H must be of shape (measurement_dim, state_dim) (%i,%i)" % (measurement_dim, state_dim)) + if (which == 'R'): + if (p_M.shape[0] != measurement_dim) or (p_M.shape[1] != measurement_dim): + raise ValueError("R must be of shape (measurement_dim, measurement_dim) (%i,%i)" % (measurement_dim, measurement_dim)) + + return (p_M,old_M_shape) + + @staticmethod + def _check_grad_state_matrices(dM, state_dim, grad_params_no, which = 'dA'): + """ + Function checks (mostly check dimensions) matrices for marginal likelihood + gradient parameters calculation. It check dA, dQ matrices. + + Input: + ------------- + dM: None, scaler or 3D matrix + It is supposed to be (state_dim,state_dim,grad_params_no) matrix. + If None then zero matrix is assumed. If scalar then the function + checks consistency with "state_dim" and "grad_params_no". + + state_dim: int + State dimensionality + + grad_params_no: int + How many parrameters of likelihood gradient in total. + + which: string + 'dA' or 'dQ' + + + Output: + -------------- + function of (k) which returns the parameters matrix. + + """ + + + if dM is None: + dM=np.zeros((state_dim,state_dim,grad_params_no)) + elif isinstance(dM, np.ndarray): + if state_dim == 1: + if len(dM.shape) < 3: + dM.shape = (1,1,1) + else: + if len(dM.shape) < 3: + dM.shape = (state_dim,state_dim,1) + elif isinstance(dM, np.int): + if state_dim > 1: + raise ValueError("When computing likelihood gradient wrong %s dimension." % which) + else: + dM = np.ones((1,1,1)) * dM + +# if not isinstance(dM, types.FunctionType): +# f_dM = lambda k: dM +# else: +# f_dM = dM + + return dM + + + @staticmethod + def _check_grad_measurement_matrices(dM, state_dim, grad_params_no, measurement_dim, which = 'dH'): + """ + Function checks (mostly check dimensions) matrices for marginal likelihood + gradient parameters calculation. It check dH, dR matrices. + + Input: + ------------- + dM: None, scaler or 3D matrix + It is supposed to be + (measurement_dim ,state_dim,grad_params_no) for "dH" matrix. + (measurement_dim,measurement_dim,grad_params_no) for "dR" + + If None then zero matrix is assumed. If scalar then the function + checks consistency with "state_dim" and "grad_params_no". + + state_dim: int + State dimensionality + + grad_params_no: int + How many parrameters of likelihood gradient in total. + + measurement_dim: int + Dimensionality of measurements. + + which: string + 'dH' or 'dR' + + + Output: + -------------- + function of (k) which returns the parameters matrix. + """ + + if dM is None: + if which == 'dH': + dM=np.zeros((measurement_dim ,state_dim,grad_params_no)) + elif which == 'dR': + dM=np.zeros((measurement_dim,measurement_dim,grad_params_no)) + elif isinstance(dM, np.ndarray): + if state_dim == 1: + if len(dM.shape) < 3: + dM.shape = (1,1,1) + else: + if len(dM.shape) < 3: + if which == 'dH': + dM.shape = (measurement_dim,state_dim,1) + elif which == 'dR': + dM.shape = (measurement_dim,measurement_dim,1) + elif isinstance(dM, np.int): + if state_dim > 1: + raise ValueError("When computing likelihood gradient wrong dH dimension.") + else: + dM = np.ones((1,1,1)) * dM + +# if not isinstance(dM, types.FunctionType): +# f_dM = lambda k: dM +# else: +# f_dM = dM + + return dM + + + +class Struct(object): + pass + +class ContDescrStateSpace(DescreteStateSpace): + """ + Class for continuous-discrete Kalman filter. State equation is + continuous while measurement equation is discrete. + + d x(t)/ dt = F x(t) + L q; where q~ N(0, Qc) + y_{t_k} = H_{k} x_{t_k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + """ + + class AQcompute_once(Q_handling_Class): + """ + Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter + from the matrices F, L, Qc, P_ing, dF, dQc, dP_inf of the continuos state + equation. dt - time steps. + + It has the same interface as AQcompute_batch. + + It computes matrices for only one time step. This object is used when + there are many different time steps and storing matrices for each of them + would take too much memory. + """ + + def __init__(self, F,L,Qc,dt,compute_derivatives=False, grad_params_no=None, P_inf=None, dP_inf=None, dF = None, dQc=None): + """ + Constructor. All necessary parameters are passed here and stored + in the opject. + + Input: + ------------------- + F, L, Qc, P_inf : matrices + Parameters of corresponding continuous state model + dt: array + All time steps + compute_derivatives: bool + Whether to calculate derivatives + + dP_inf, dF, dQc: 3D array + Derivatives if they are required + + Output: + ------------------- + Nothing + """ + # Copies are done because this object is used later in smoother + # and these parameters must not change. + self.F = F.copy() + self.L = L.copy() + self.Qc = Qc.copy() + + self.dt = dt # copy is not taken because dt is internal parameter + + # Parameters are used to calculate derivatives but derivatives + # are not used in the smoother. Therefore copies are not taken. + self.P_inf = P_inf + self.dP_inf = dP_inf + self.dF = dF + self.dQc = dQc + + self.compute_derivatives = compute_derivatives + self.grad_params_no = grad_params_no + + + self.last_k = 0 + self.last_k_computed = False + self.v_Ak = None + self.v_Qk = None + self.v_dAk = None + self.v_dQk = None + + self.square_root_computed = False + # !!!Print statistics! Which object is created + + def f_a(self, k,m,A): + """ + Dynamic model + """ + + return np.dot(A, m) # default dynamic model + + def _recompute_for_new_k(self,k): + """ + Computes the necessary matrices for an index k and store the results. + + Input: + ---------------------- + k: int + Index in the time differences array dt where to compute matrices + + Output: + ---------------------- + Ak,Qk, dAk, dQk: matrices and/or 3D arrays + A, Q, dA dQ on step k + """ + if (self.last_k != k) or (self.last_k_computed == False): + v_Ak,v_Qk, tmp, v_dAk, v_dQk = ContDescrStateSpace.lti_sde_to_descrete(self.F, + self.L,self.Qc,self.dt[k],self.compute_derivatives, + grad_params_no=self.grad_params_no, P_inf=self.P_inf, dP_inf=self.dP_inf, dF=self.dF, dQc=self.dQc) + + self.last_k = k + self.last_k_computed = True + self.v_Ak = v_Ak + self.v_Qk = v_Qk + self.v_dAk = v_dAk + self.v_dQk = v_dQk + self.Q_square_root_computed = False + else: + v_Ak = self.v_Ak + v_Qk = self.v_Qk + v_dAk = self.v_dAk + v_dQk = self.v_dQk + + # !!!Print statistics! Print sizes of matrices + + return v_Ak,v_Qk, v_dAk, v_dQk + + def reset(self, compute_derivatives): + """ + For reusing this object e.g. in smoother computation. Actually, + this object can not be reused because it computes the matrices on + every iteration. But this method is written for keeping the same + interface with the class AQcompute_batch. + """ + + self.last_k = 0 + self.last_k_computed = False + self.compute_derivatives = compute_derivatives + self.Q_square_root_computed = False + + return self + + def Ak(self,k,m,P): + v_Ak,v_Qk, v_dAk, v_dQk = self._recompute_for_new_k(k) + return v_Ak + + def Qk(self,k): + v_Ak,v_Qk, v_dAk, v_dQk = self._recompute_for_new_k(k) + return v_Qk + + def dAk(self, k): + v_Ak,v_Qk, v_dAk, v_dQk = self._recompute_for_new_k(k) + return v_dAk + + def dQk(self, k): + v_Ak,v_Qk, v_dAk, v_dQk = self._recompute_for_new_k(k) + return v_dQk + + def Q_srk(self,k): + """ + Square root of the noise matrix Q + """ + + if ((self.last_k == k) and (self.last_k_computed == True)): + if not self.Q_square_root_computed: + (U, S, Vh) = sp.linalg.svd( self.v_Qk, full_matrices=False, compute_uv=True, overwrite_a=False, check_finite=False) + square_root = U * np.sqrt(S) + self.square_root_computed = True + self.Q_square_root = square_root + else: + square_root = self.Q_square_root + else: + raise ValueError("Square root of Q can not be computed") + + return square_root + + def return_last(self): + """ + Function returns last computed matrices. + """ + if not self.last_k_computed: + raise ValueError("Matrices are not computed.") + else: + k = self.last_k + A = self.v_Ak + Q = self.v_Qk + dA = self.v_dAk + dQ = self.v_dQk + + return k, A, Q, dA, dQ + + class AQcompute_batch_Python(Q_handling_Class): + """ + Class for calculating matrices A, Q, dA, dQ of the discrete Kalman Filter + from the matrices F, L, Qc, P_ing, dF, dQc, dP_inf of the continuos state + equation. dt - time steps. + + It has the same interface as AQcompute_once. + + It computes matrices for all time steps. This object is used when + there are not so many (controlled by internal variable) + different time steps and storing all the matrices do not take too much memory. + + Since all the matrices are computed all together, this object can be used + in smoother without repeating the computations. + """ + def __init__(self, F,L,Qc,dt,compute_derivatives=False, grad_params_no=None, P_inf=None, dP_inf=None, dF = None, dQc=None): + """ + Constructor. All necessary parameters are passed here and stored + in the opject. + + Input: + ------------------- + F, L, Qc, P_inf : matrices + Parameters of corresponding continuous state model + dt: array + All time steps + compute_derivatives: bool + Whether to calculate derivatives + + dP_inf, dF, dQc: 3D array + Derivatives if they are required + + Output: + ------------------- + Nothing + """ + As, Qs, reconstruct_indices, dAs, dQs = ContDescrStateSpace.lti_sde_to_descrete(F, + L,Qc,dt,compute_derivatives, + grad_params_no=grad_params_no, P_inf=P_inf, dP_inf=dP_inf, dF=dF, dQc=dQc) + + self.As = As + self.Qs = Qs + self.dAs = dAs + self.dQs = dQs + self.reconstruct_indices = reconstruct_indices + self.total_size_of_data = self.As.nbytes + self.Qs.nbytes +\ + (self.dAs.nbytes if (self.dAs is not None) else 0) +\ + (self.dQs.nbytes if (self.dQs is not None) else 0) +\ + (self.reconstruct_indices.nbytes if (self.reconstruct_indices is not None) else 0) + + self.Q_svd_dict = {} + self.last_k = None + # !!!Print statistics! Which object is created + # !!!Print statistics! Print sizes of matrices + + def f_a(self, k,m,A): + """ + Dynamic model + """ + return np.dot(A, m) # default dynamic model + + def reset(self, compute_derivatives=False): + """ + For reusing this object e.g. in smoother computation. It makes sence + because necessary matrices have been already computed for all + time steps. + """ + return self + + def Ak(self,k,m,P): + self.last_k = k + return self.As[:,:, self.reconstruct_indices[k]] + + def Qk(self,k): + self.last_k = k + return self.Qs[:,:, self.reconstruct_indices[k]] + + def dAk(self,k): + self.last_k = k + return self.dAs[:,:, :, self.reconstruct_indices[k]] + + def dQk(self,k): + self.last_k = k + return self.dQs[:,:, :, self.reconstruct_indices[k]] + + + def Q_srk(self,k): + """ + Square root of the noise matrix Q + """ + matrix_index = self.reconstruct_indices[k] + if matrix_index in self.Q_svd_dict: + square_root = self.Q_svd_dict[matrix_index] + else: + (U, S, Vh) = sp.linalg.svd( self.Qs[:,:, matrix_index], + full_matrices=False, compute_uv=True, + overwrite_a=False, check_finite=False) + square_root = U * np.sqrt(S) + self.Q_svd_dict[matrix_index] = square_root + + return square_root + + def return_last(self): + """ + Function returns last available matrices. + """ + + if (self.last_k is None): + raise ValueError("Matrices are not computed.") + else: + ind = self.reconstruct_indices[self.last_k] + A = self.As[:,:, ind] + Q = self.Qs[:,:, ind] + dA = self.dAs[:,:, :, ind] + dQ = self.dQs[:,:, :, ind] + + return self.last_k, A, Q, dA, dQ + + @classmethod + def cont_discr_kalman_filter(cls, F, L, Qc, p_H, p_R, P_inf, X, Y, index = None, + m_init=None, P_init=None, + p_kalman_filter_type='regular', + calc_log_likelihood=False, + calc_grad_log_likelihood=False, + grad_params_no=0, grad_calc_params=None): + """ + This function implements the continuous-discrete Kalman Filter algorithm + These notations for the State-Space model are assumed: + d/dt x(t) = F * x(t) + L * w(t); w(t) ~ N(0, Qc) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated filter distributions x_{k} ~ N(m_{k}, P(k)) + + Current Features: + ---------------------------------------- + 1) The function generaly do not modify the passed parameters. If + it happens then it is an error. There are several exeprions: scalars + can be modified into a matrix, in some rare cases shapes of + the derivatives matrices may be changed, it is ignored for now. + + 2) Copies of F,L,Qc are created in memory because they may be used later + in smoother. References to copies are kept in "AQcomp" object + return parameter. + + 3) Function support "multiple time series mode" which means that exactly + the same State-Space model is used to filter several sets of measurements. + In this case third dimension of Y should include these state-space measurements + Log_likelihood and Grad_log_likelihood have the corresponding dimensions then. + + 4) Calculation of Grad_log_likelihood is not supported if matrices + H, or R changes overf time (with index k). (later may be changed) + + 5) Measurement may include missing values. In this case update step is + not done for this measurement. (later may be changed) + + Input: + ----------------- + + F: (state_dim, state_dim) matrix + F in the model. + + L: (state_dim, noise_dim) matrix + L in the model. + + Qc: (noise_dim, noise_dim) matrix + Q_c in the model. + + p_H: scalar, matrix (measurement_dim, state_dim) , 3D array + H_{k} in the model. If matrix then H_{k} = H - constant. + If it is 3D array then H_{k} = p_Q[:,:, index[2,k]] + + p_R: scalar, square symmetric matrix, 3D array + R_{k} in the model. If matrix then R_{k} = R - constant. + If it is 3D array then R_{k} = p_R[:,:, index[3,k]] + + P_inf: (state_dim, state_dim) matrix + State varince matrix on infinity. + + X: 1D array + Time points of measurements. Needed for converting continuos + problem to the discrete one. + + Y: matrix or vector or 3D array + Data. If Y is matrix then samples are along 0-th dimension and + features along the 1-st. If 3D array then third dimension + correspond to "multiple time series mode". + + index: vector + Which indices (on 3-rd dimension) from arrays p_H, p_R to use + on every time step. If this parameter is None then it is assumed + that p_H, p_R do not change over time and indices are not needed. + index[0,:] - correspond to H, index[1,:] - correspond to R + If index.shape[0] == 1, it is assumed that indides for all matrices + are the same. + + m_init: vector or matrix + Initial distribution mean. If None it is assumed to be zero. + For "multiple time series mode" it is matrix, second dimension of + which correspond to different time series. In regular case ("one + time series mode") it is a vector. + + P_init: square symmetric matrix or scalar + Initial covariance of the states. If the parameter is scalar + then it is assumed that initial covariance matrix is unit matrix + multiplied by this scalar. If None the unit matrix is used instead. + "multiple time series mode" does not affect it, since it does not + affect anything related to state variaces. + + p_kalman_filter_type: string, one of ('regular', 'svd') + Which Kalman Filter is used. Regular or SVD. SVD is more numerically + stable, in particular, Covariace matrices are guarantied to be + positive semi-definite. However, 'svd' works slower, especially for + small data due to SVD call overhead. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then "grad_calc_params" parameter must + provide the extra parameters for gradient calculation. + + grad_params_no: int + If previous parameter is true, then this parameters gives the + total number of parameters in the gradient. + + grad_calc_params: dictionary + Dictionary with derivatives of model matrices with respect + to parameters "dF", "dL", "dQc", "dH", "dR", "dm_init", "dP_init". + They can be None, in this case zero matrices (no dependence on parameters) + is assumed. If there is only one parameter then third dimension is + automatically added. + + Output: + -------------- + + M: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array + Filter estimates of the state means. In the extra step the initial + value is included. In the "multiple time series mode" third dimension + correspond to different timeseries. + + P: (no_steps+1, state_dim, state_dim) 3D array + Filter estimates of the state covariances. In the extra step the initial + value is included. + + log_likelihood: double or (1, time_series_no) 3D array. + + If the parameter calc_log_likelihood was set to true, return + logarithm of marginal likelihood of the state-space model. If + the parameter was false, return None. In the "multiple time series mode" it is a vector + providing log_likelihood for each time series. + + grad_log_likelihood: column vector or (grad_params_no, time_series_no) matrix + If calc_grad_log_likelihood is true, return gradient of log likelihood + with respect to parameters. It returns it column wise, so in + "multiple time series mode" gradients for each time series is in the + corresponding column. + + AQcomp: object + Contains some pre-computed values for converting continuos model into + discrete one. It can be used later in the smoothing pahse. + """ + + p_H = np.atleast_1d(p_H) + p_R = np.atleast_1d(p_R) + + X.shape, old_X_shape = cls._reshape_input_data(X.shape, 2) # represent as column + if (X.shape[1] != 1): + raise ValueError("Only one dimensional X data is supported.") + + Y.shape, old_Y_shape = cls._reshape_input_data(Y.shape) # represent as column + + state_dim = F.shape[0] + measurement_dim = Y.shape[1] + time_series_no = Y.shape[2] # multiple time series mode + + if ((len(p_H.shape) == 3) and (len(p_H.shape[2]) != 1)) or\ + ((len(p_R.shape) == 3) and (len(p_R.shape[2]) != 1)): + model_matrices_chage_with_time = True + else: + model_matrices_chage_with_time = False + + # Check index + old_index_shape = None + if index is None: + if (len(p_H.shape) == 3) or (len(p_R.shape) == 3): + raise ValueError("Parameter index can not be None for time varying matrices (third dimension is present)") + else: # matrices do not change in time, so form dummy zero indices. + index = np.zeros((1,Y.shape[0])) + else: + if len(index.shape) == 1: + index.shape = (1,index.shape[0]) + old_index_shape = (index.shape[0],) + + if (index.shape[1] != Y.shape[0]): + raise ValueError("Number of measurements must be equal the number of H_{k}, R_{k}") + + if (index.shape[0] == 1): + H_time_var_index = 0; R_time_var_index = 0 + elif (index.shape[0] == 4): + H_time_var_index = 0; R_time_var_index = 1 + else: + raise ValueError("First Dimension of index must be either 1 or 2.") + + (p_H, old_H_shape) = cls._check_SS_matrix(p_H, state_dim, measurement_dim, which='H') + (p_R, old_R_shape) = cls._check_SS_matrix(p_R, state_dim, measurement_dim, which='R') + + if m_init is None: + m_init = np.zeros((state_dim, time_series_no)) + else: + m_init = np.atleast_2d(m_init).T + + if P_init is None: + P_init = P_inf.copy() + + if p_kalman_filter_type not in ('regular', 'svd'): + raise ValueError("Kalman filer type neither 'regular nor 'svd'.") + + # Functions to pass to the kalman_filter algorithm: + # Parameters: + # k - number of Kalman filter iteration + # m - vector for calculating matrices. Required for EKF. Not used here. + # f_hl = lambda k,m,H: np.dot(H, m) + # f_H = lambda k,m,P: p_H[:,:, index[H_time_var_index, k]] + #f_R = lambda k: p_R[:,:, index[R_time_var_index, k]] + #o_R = R_handling( p_R, index, R_time_var_index, 20) + + if calc_grad_log_likelihood: + + dF = cls._check_grad_state_matrices(grad_calc_params.get('dF'), state_dim, grad_params_no, which = 'dA') + dQc = cls._check_grad_state_matrices(grad_calc_params.get('dQc'), state_dim, grad_params_no, which = 'dQ') + dP_inf = cls._check_grad_state_matrices(grad_calc_params.get('dP_inf'), state_dim, grad_params_no, which = 'dA') + + dH = cls._check_grad_measurement_matrices(grad_calc_params.get('dH'), state_dim, grad_params_no, measurement_dim, which = 'dH') + dR = cls._check_grad_measurement_matrices(grad_calc_params.get('dR'), state_dim, grad_params_no, measurement_dim, which = 'dR') + + dm_init = grad_calc_params.get('dm_init') # Initial values for the Kalman Filter + if dm_init is None: + # multiple time series mode. Keep grad_params always as a last dimension + dm_init = np.zeros( (state_dim, time_series_no, grad_params_no) ) + + dP_init = grad_calc_params.get('dP_init') # Initial values for the Kalman Filter + if dP_init is None: + dP_init = dP_inf(0).copy() # get the dP_init matrix, because now it is a function + + else: + dP_inf = None + dF = None + dQc = None + dH = None + dR = None + dm_init = None + dP_init = None + + measurement_callables = Std_Measurement_Callables_Class(p_H, H_time_var_index, p_R, index, R_time_var_index, 20, dH, dR) + #import pdb; pdb.set_trace() + + dynamic_callables = cls._cont_to_discrete_object(X, F, L, Qc, compute_derivatives=calc_grad_log_likelihood, + grad_params_no=grad_params_no, + P_inf=P_inf, dP_inf=dP_inf, dF = dF, dQc=dQc) + + if print_verbose: + print("General: run Continuos-Discrete Kalman Filter") + # Also for dH, dR and probably for all derivatives + (M, P, log_likelihood, grad_log_likelihood, AQcomp) = cls._cont_discr_kalman_filter_raw(state_dim, + dynamic_callables, measurement_callables, + X, Y, m_init=m_init, P_init=P_init, + p_kalman_filter_type=p_kalman_filter_type, + calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, grad_params_no=grad_params_no, + dm_init=dm_init, dP_init=dP_init) + + if old_index_shape is not None: + index.shape = old_index_shape + + if old_X_shape is not None: + X.shape = old_X_shape + + if old_Y_shape is not None: + Y.shape = old_Y_shape + + if old_H_shape is not None: + p_H.shape = old_H_shape + + if old_R_shape is not None: + p_R.shape = old_R_shape + + return (M, P, log_likelihood, grad_log_likelihood, AQcomp) + + @classmethod + def _cont_discr_kalman_filter_raw(cls,state_dim, p_dynamic_callables, p_measurement_callables, X, Y, + m_init, P_init, + p_kalman_filter_type='regular', + calc_log_likelihood=False, + calc_grad_log_likelihood=False, grad_params_no=None, + dm_init=None, dP_init=None): + """ + General filtering algorithm for inference in the continuos-discrete + state-space model: + + d/dt x(t) = F * x(t) + L * w(t); w(t) ~ N(0, Qc) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated filter distributions x_{k} ~ N(m_{k}, P(k)) + + Current Features: + ---------------------------------------- + + 1) Function support "multiple time series mode" which means that exactly + the same State-Space model is used to filter several sets of measurements. + In this case third dimension of Y should include these state-space measurements + Log_likelihood and Grad_log_likelihood have the corresponding dimensions then. + + 2) Measurement may include missing values. In this case update step is + not done for this measurement. (later may be changed) + + Input: + ----------------- + state_dim: int + Demensionality of the states + + F: (state_dim, state_dim) matrix + F in the model. + + L: (state_dim, noise_dim) matrix + L in the model. + + Qc: (noise_dim, noise_dim) matrix + Q_c in the model. + + P_inf: (state_dim, state_dim) matrix + State varince matrix on infinity. + + p_h: function (k, x_{k}, H_{k}). Measurement function. + k (iteration number), + x_{k} + H_{k} Jacobian matrices of f_h. In the linear case it is exactly H_{k}. + + f_H: function (k, m, P) return Jacobian of dynamic function, it is + passed into p_h. + k (iteration number), + m: point where Jacobian is evaluated, + P: parameter for Jacobian, usually covariance matrix. + + p_f_R: function (k). Returns noise matrix of measurement equation + on iteration k. + k (iteration number). + + m_init: vector or matrix + Initial distribution mean. For "multiple time series mode" + it is matrix, second dimension of which correspond to different + time series. In regular case ("one time series mode") it is a + vector. + + P_init: matrix or scalar + Initial covariance of the states. Must be not None + "multiple time series mode" does not affect it, since it does not + affect anything related to state variaces. + + p_kalman_filter_type: string, one of ('regular', 'svd') + Which Kalman Filter is used. Regular or SVD. SVD is more numerically + stable, in particular, Covariace matrices are guarantied to be + positive semi-definite. However, 'svd' works slower, especially for + small data due to SVD call overhead. + + calc_log_likelihood: boolean + Whether to calculate marginal likelihood of the state-space model. + + calc_grad_log_likelihood: boolean + Whether to calculate gradient of the marginal likelihood + of the state-space model. If true then the next parameter must + provide the extra parameters for gradient calculation. + + grad_params_no: int + Number of gradient parameters + + dP_inf, dF, dQc, dH, dR, dm_init, dP_init: matrices or 3D arrays. + Necessary parameters for derivatives calculation. + + """ + + #import pdb; pdb.set_trace() + steps_no = Y.shape[0] # number of steps in the Kalman Filter + time_series_no = Y.shape[2] # multiple time series mode + + # Allocate space for results + # Mean estimations. Initial values will be included + M = np.empty(((steps_no+1),state_dim,time_series_no)) + M[0,:,:] = m_init # Initialize mean values + # Variance estimations. Initial values will be included + P = np.empty(((steps_no+1),state_dim,state_dim)) + P_init = 0.5*( P_init + P_init.T) # symmetrize initial covariance. In some ustable cases this is uiseful + P[0,:,:] = P_init # Initialize initial covariance matrix + + #import pdb;pdb.set_trace() + if p_kalman_filter_type == 'svd': + (U,S,Vh) = sp.linalg.svd( P_init,full_matrices=False, compute_uv=True, + overwrite_a=False,check_finite=True) + S[ (S==0) ] = 1e-17 # allows to run algorithm for singular initial variance + P_upd = (P_init, S,U) + #log_likelihood = 0 + #grad_log_likelihood = np.zeros((grad_params_no,1)) + log_likelihood = 0 if calc_log_likelihood else None + grad_log_likelihood = 0 if calc_grad_log_likelihood else None + + #setting initial values for derivatives update + dm_upd = dm_init + dP_upd = dP_init + # Main loop of the Kalman filter + for k in range(0,steps_no): + # In this loop index for new estimations is (k+1), old - (k) + # This happened because initial values are stored at 0-th index. + #import pdb; pdb.set_trace() + + prev_mean = M[k,:,:] # mean from the previous step + + if p_kalman_filter_type == 'svd': + m_pred, P_pred, dm_pred, dP_pred = \ + cls._kalman_prediction_step_SVD(k, prev_mean ,P_upd, p_dynamic_callables, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_upd, p_dP = dP_upd) + else: + m_pred, P_pred, dm_pred, dP_pred = \ + cls._kalman_prediction_step(k, prev_mean ,P[k,:,:], p_dynamic_callables, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_upd, p_dP = dP_upd ) + + #import pdb; pdb.set_trace() + k_measurment = Y[k,:,:] + + if (np.any(np.isnan(k_measurment)) == False): + + if p_kalman_filter_type == 'svd': + m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + cls._kalman_update_step_SVD(k, m_pred , P_pred, p_measurement_callables, + k_measurment, calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_pred, p_dP = dP_pred ) + + + # m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + # cls._kalman_update_step(k, m_pred , P_pred[0], f_h, f_H, p_R.f_R, k_measurment, + # calc_log_likelihood=calc_log_likelihood, + # calc_grad_log_likelihood=calc_grad_log_likelihood, + # p_dm = dm_pred, p_dP = dP_pred, grad_calc_params_2 = (dH, dR)) + # + # (U,S,Vh) = sp.linalg.svd( P_upd,full_matrices=False, compute_uv=True, + # overwrite_a=False,check_finite=True) + # P_upd = (P_upd, S,U) + else: + m_upd, P_upd, log_likelihood_update, dm_upd, dP_upd, d_log_likelihood_update = \ + cls._kalman_update_step(k, m_pred , P_pred, p_measurement_callables, k_measurment, + calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + p_dm = dm_pred, p_dP = dP_pred ) + else: + if k_measurment.shape != (1,1): + raise ValueError("Nan measurements are currently not supported for \ + multidimensional output and multiple tiem series.") + else: + m_upd = m_pred; P_upd = P_pred; dm_upd = dm_pred; dP_upd = dP_pred + log_likelihood_update = 0.0; + d_log_likelihood_update = 0.0; + + + if calc_log_likelihood: + log_likelihood += log_likelihood_update + + if calc_grad_log_likelihood: + grad_log_likelihood += d_log_likelihood_update + + M[k+1,:,:] = m_upd # separate mean value for each time series + + if p_kalman_filter_type == 'svd': + P[k+1,:,:] = P_upd[0] + else: + P[k+1,:,:] = P_upd + #print("kf it: %i" % k) + # !!!Print statistics! Print sizes of matrices + # !!!Print statistics! Print iteration time base on another boolean variable + return (M, P, log_likelihood, grad_log_likelihood, p_dynamic_callables.reset(False)) + + @classmethod + def cont_discr_rts_smoother(cls,state_dim, filter_means, filter_covars, + p_dynamic_callables=None, X=None, F=None,L=None,Qc=None): + """ + + Continuos-discrete Rauch–Tung–Striebel(RTS) smoother. + + This function implements Rauch–Tung–Striebel(RTS) smoother algorithm + based on the results of _cont_discr_kalman_filter_raw. + + Model: + d/dt x(t) = F * x(t) + L * w(t); w(t) ~ N(0, Qc) + y_{k} = H_{k} * x_{k} + r_{k}; r_{k-1} ~ N(0, R_{k}) + + Returns estimated smoother distributions x_{k} ~ N(m_{k}, P(k)) + + Input: + -------------- + + filter_means: (no_steps+1,state_dim) matrix or (no_steps+1,state_dim, time_series_no) 3D array + Results of the Kalman Filter means estimation. + + filter_covars: (no_steps+1, state_dim, state_dim) 3D array + Results of the Kalman Filter covariance estimation. + + Dynamic_callables: object or None + Object form the filter phase which provides functions for computing + A, Q, dA, dQ fro discrete model from the continuos model. + + X, F, L, Qc: matrices + If AQcomp is None, these matrices are used to create this object from scratch. + + Output: + ------------- + + M: (no_steps+1,state_dim) matrix + Smoothed estimates of the state means + + P: (no_steps+1,state_dim, state_dim) 3D array + Smoothed estimates of the state covariances + """ + + f_a = lambda k,m,A: np.dot(A, m) # state dynamic model + if p_dynamic_callables is None: # make this object from scratch + p_dynamic_callables = cls._cont_to_discrete_object(cls, X, F,L,Qc,f_a,compute_derivatives=False, + grad_params_no=None, P_inf=None, dP_inf=None, dF = None, dQc=None) + + no_steps = filter_covars.shape[0]-1# number of steps (minus initial covariance) + + M = np.empty(filter_means.shape) # smoothed means + P = np.empty(filter_covars.shape) # smoothed covars + + if print_verbose: + print("General: run Continuos-Discrete Kalman Smoother") + + M[-1,:,:] = filter_means[-1,:,:] + P[-1,:,:] = filter_covars[-1,:,:] + for k in range(no_steps-1,-1,-1): + + prev_mean = filter_means[k,:] # mean from the previous step + m_pred, P_pred, tmp1, tmp2 = \ + cls._kalman_prediction_step(k, prev_mean, + filter_covars[k,:,:], p_dynamic_callables, + calc_grad_log_likelihood=False) + p_m = filter_means[k,:] + p_m_prev_step = M[(k+1),:] + + m_upd, P_upd, tmp_G = cls._rts_smoother_update_step(k, + p_m ,filter_covars[k,:,:], + m_pred, P_pred, p_m_prev_step ,P[(k+1),:,:], p_dynamic_callables) + + M[k,:,:] = m_upd + P[k,:,:] = P_upd + # Return values + return (M, P) + + @classmethod + def _cont_to_discrete_object(cls, X, F, L, Qc, compute_derivatives=False, + grad_params_no=None, + P_inf=None, dP_inf=None, dF = None, dQc=None): + """ + Function return the object which is used in Kalman filter and/or + smoother to obtain matrices A, Q and their derivatives for discrete model + from the continuous model. + + There are 2 objects AQcompute_once and AQcompute_batch and the function + returs the appropriate one based on the number of different time steps. + + Input: + ---------------------- + X, F, L, Qc: matrices + Continuous model matrices + + f_a: function + Dynamic Function is attached to the Dynamic_Model_Callables class + compute_derivatives: boolean + Whether to compute derivatives + + grad_params_no: int + Number of parameters in the gradient + + P_inf, dP_inf, dF, dQ: matrices and 3D objects + Data necessary to compute derivatives. + + Output: + -------------------------- + AQcomp: object + Its methods return matrices (and optionally derivatives) for the + discrete state-space model. + + """ + + unique_round_decimals = 10 + threshold_number_of_unique_time_steps = 20 # above which matrices are separately each time + dt = np.empty((X.shape[0],)) + dt[1:] = np.diff(X[:,0],axis=0) + dt[0] = 0#dt[1] + unique_indices = np.unique(np.round(dt, decimals=unique_round_decimals)) + number_unique_indices = len(unique_indices) + + #import pdb; pdb.set_trace() + if use_cython: + class AQcompute_batch(state_space_cython.AQcompute_batch_Cython): + def __init__(self, F,L,Qc,dt,compute_derivatives=False, grad_params_no=None, P_inf=None, dP_inf=None, dF = None, dQc=None): + As, Qs, reconstruct_indices, dAs, dQs = ContDescrStateSpace.lti_sde_to_descrete(F, + L,Qc,dt,compute_derivatives, + grad_params_no=grad_params_no, P_inf=P_inf, dP_inf=dP_inf, dF=dF, dQc=dQc) + + super(AQcompute_batch,self).__init__(As, Qs, reconstruct_indices, dAs,dQs) + else: + AQcompute_batch = cls.AQcompute_batch_Python + + if number_unique_indices > threshold_number_of_unique_time_steps: + AQcomp = cls.AQcompute_once(F,L,Qc, dt,compute_derivatives=compute_derivatives, + grad_params_no=grad_params_no, P_inf=P_inf, dP_inf=dP_inf, dF=dF, dQc=dQc) + if print_verbose: + print("CDO: Continue-to-discrete INSTANTANEOUS object is created.") + print("CDO: Number of different time steps: %i" % (number_unique_indices,) ) + + else: + AQcomp = AQcompute_batch(F,L,Qc,dt,compute_derivatives=compute_derivatives, + grad_params_no=grad_params_no, P_inf=P_inf, dP_inf=dP_inf, dF=dF, dQc=dQc) + if print_verbose: + print("CDO: Continue-to-discrete BATCH object is created.") + print("CDO: Number of different time steps: %i" % (number_unique_indices,) ) + print("CDO: Total size if its data: %i" % (AQcomp.total_size_of_data,) ) + + return AQcomp + + @staticmethod + def lti_sde_to_descrete(F,L,Qc,dt,compute_derivatives=False, + grad_params_no=None, P_inf=None, + dP_inf=None, dF = None, dQc=None): + """ + Linear Time-Invariant Stochastic Differential Equation (LTI SDE): + + dx(t) = F x(t) dt + L d \beta ,where + + x(t): (vector) stochastic process + \beta: (vector) Brownian motion process + F, L: (time invariant) matrices of corresponding dimensions + Qc: covariance of noise. + + This function rewrites it into the corresponding state-space form: + + x_{k} = A_{k} * x_{k-1} + q_{k-1}; q_{k-1} ~ N(0, Q_{k-1}) + + + Input: + -------------- + F,L: LTI SDE matrices of corresponding dimensions + + Qc: matrix (n,n) + Covarince between different dimensions of noise \beta. + n is the dimensionality of the noise. + + dt: double or iterable + Time difference used on this iteration. + If dt is iterable, then A and Q_noise are computed for every + unique dt + + compute_derivatives: boolean + Whether derivatives of A and Q are required. + + grad_params_no: int + Number of gradient parameters + + P_inf: (state_dim. state_dim) matrix + + dP_inf + + dF: 3D array + Derivatives of F + + dQc: 3D array + Derivatives of Qc + + dR: 3D array + Derivatives of R + + Output: + -------------- + + A: matrix + A_{k}. Because we have LTI SDE only dt can affect on matrix + difference for different k. + + Q_noise: matrix + Covariance matrix of (vector) q_{k-1}. Only dt can affect the + matrix difference for different k. + + reconstruct_index: array + If dt was iterable return three dimensinal arrays A and Q_noise. + Third dimension of these arrays correspond to unique dt's. + This reconstruct_index contain indices of the original dt's + in the uninue dt sequence. A[:,:, reconstruct_index[5]] + is matrix A of 6-th(indices start from zero) dt in the original + sequence. + dA: 3D array + Derivatives of A + + dQ: 3D array + Derivatives of Q + """ + # Dimensionality + n = F.shape[0] + + if not isinstance(dt, collections.Iterable): # not iterable, scalar + + # The dynamical model + A = matrix_exponent(F*dt) + if np.any( np.isnan(A)): + A = linalg.expm3(F*dt) + + # The covariance matrix Q by matrix fraction decomposition -> + Phi = np.zeros((2*n,2*n)) + Phi[:n,:n] = F + Phi[:n,n:] = L.dot(Qc).dot(L.T) + Phi[n:,n:] = -F.T + AB = matrix_exponent(Phi*dt) + AB = np.dot(AB, np.vstack((np.zeros((n,n)),np.eye(n)))) + + Q_noise_1 = linalg.solve(AB[n:,:].T,AB[:n,:].T) + Q_noise_2 = P_inf - A.dot(P_inf).dot(A.T) + # The covariance matrix Q by matrix fraction decomposition <- + + if compute_derivatives: + dA = np.zeros([n, n, grad_params_no]) + dQ = np.zeros([n, n, grad_params_no]) + + #AA = np.zeros([2*n, 2*n, nparam]) + FF = np.zeros([2*n, 2*n]) + AA = np.zeros([2*n, 2*n, grad_params_no]) + + for p in range(0, grad_params_no): + + FF[:n,:n] = F + FF[n:,:n] = dF[:,:,p] + FF[n:,n:] = F + + # Solve the matrix exponential + AA[:,:,p] = matrix_exponent(FF*dt) + + # Solve the differential equation + #foo = AA[:,:,p].dot(np.vstack([m, dm[:,p]])) + #mm = foo[:n,:] + #dm[:,p] = foo[n:,:] + + # The discrete-time dynamical model* + if p==0: + A = AA[:n,:n,p] + Q_noise_2 = P_inf - A.dot(P_inf).dot(A.T) + Q_noise = Q_noise_2 + #PP = A.dot(P).dot(A.T) + Q_noise_2 + + # The derivatives of A and Q + dA[:,:,p] = AA[n:,:n,p] + dQ[:,:,p] = dP_inf[:,:,p] - dA[:,:,p].dot(P_inf).dot(A.T) \ + - A.dot(dP_inf[:,:,p]).dot(A.T) - A.dot(P_inf).dot(dA[:,:,p].T) # Rewrite not ro multiply two times + + else: + dA = None + dQ = None + Q_noise = Q_noise_2 + # Innacuracies have been observed when Q_noise_1 was used. + + #Q_noise = Q_noise_1 + + # Return + return A, Q_noise,None, dA, dQ + + else: # iterable, array + + # Time discretizations (round to 14 decimals to avoid problems) + dt_unique, tmp, reconstruct_index = np.unique(np.round(dt,8), + return_index=True,return_inverse=True) + del tmp + # Allocate space for A and Q + A = np.empty((n,n,dt_unique.shape[0])) + Q_noise = np.empty((n,n,dt_unique.shape[0])) + + if compute_derivatives: + dA = np.empty((n,n,grad_params_no,dt_unique.shape[0])) + dQ = np.empty((n,n,grad_params_no,dt_unique.shape[0])) + else: + dA = None + dQ = None + # Call this function for each unique dt + for j in range(0,dt_unique.shape[0]): + A[:,:,j], Q_noise[:,:,j], tmp1, dA_t, dQ_t = ContDescrStateSpace.lti_sde_to_descrete(F,L,Qc,dt_unique[j], + compute_derivatives=compute_derivatives, grad_params_no=grad_params_no, P_inf=P_inf, dP_inf=dP_inf, dF = dF, dQc=dQc) + if compute_derivatives: + dA[:,:,:,j] = dA_t + dQ[:,:,:,j] = dQ_t + + # Return + return A, Q_noise, reconstruct_index, dA, dQ + +def matrix_exponent(M): + """ + The function computes matrix exponent and handles some special cases + """ + + if (M.shape[0] == 1): # 1*1 matrix + Mexp = np.array( ((np.exp(M[0,0]) ,),) ) + + else: # matrix is larger + method = None + try: + Mexp = linalg.expm(M) + method = 1 + except (Exception,) as e: + Mexp = linalg.expm3(M) + method = 2 + finally: + if np.any(np.isnan(Mexp)): + if method == 2: + raise ValueError("Matrix Exponent is not computed 1") + else: + Mexp = linalg.expm3(M) + method = 2 + if np.any(np.isnan(Mexp)): + raise ValueError("Matrix Exponent is not computed 2") + + return Mexp + +def balance_matrix(A): + """ + Balance matrix, i.e. finds such similarity transformation of the original + matrix A: A = T * bA * T^{-1}, where norms of columns of bA and of rows of bA + are as close as possible. It is usually used as a preprocessing step in + eigenvalue calculation routine. It is useful also for State-Space models. + + See also: + [1] Beresford N. Parlett and Christian Reinsch (1969). Balancing + a matrix for calculation of eigenvalues and eigenvectors. + Numerische Mathematik, 13(4): 293-304. + + Input: + ---------------------- + A: square matrix + Matrix to be balanced + + Output: + ---------------- + bA: matrix + Balanced matrix + + T: matrix + Left part of the similarity transformation + + T_inv: matrix + Right part of the similarity transformation. + """ + + if len(A.shape) != 2 or (A.shape[0] != A.shape[1]): + raise ValueError('balance_matrix: Expecting square matrix') + + N = A.shape[0] # matrix size + + gebal = sp.linalg.lapack.get_lapack_funcs('gebal',(A,)) + bA, lo, hi, pivscale, info = gebal(A, permute=True, scale=True,overwrite_a=False) + if info < 0: + raise ValueError('balance_matrix: Illegal value in %d-th argument of internal gebal ' % -info) + # calculating the similarity transforamtion: + def perm_matr(D, c1,c2): + """ + Function creates the permutation matrix which swaps columns c1 and c2. + + Input: + -------------- + D: int + Size of the permutation matrix + c1: int + Column 1. Numeration starts from 1...D + c2: int + Column 2. Numeration starts from 1...D + """ + i1 = c1-1; i2 = c2-1 # indices + P = np.eye(D); + P[i1,i1] = 0.0; P[i2,i2] = 0.0; # nullify diagonal elements + P[i1,i2] = 1.0; P[i2,i1] = 1.0 + + return P + + P = np.eye(N) # permutation matrix + if (hi != N-1): # there are row permutations + for k in range(N-1,hi,-1): + new_perm = perm_matr(N, k+1, pivscale[k]) + P = np.dot(P,new_perm) + if (lo != 0): + for k in range(0,lo,1): + new_perm = perm_matr(N, k+1, pivscale[k]) + P = np.dot(P,new_perm) + D = pivscale.copy() + D[0:lo] = 1.0; D[hi+1:N] = 1.0 # thesee scaling factors must be set to one. + #D = np.diag(D) # make a diagonal matrix + + T = np.dot(P,np.diag(D)) # similarity transformation in question + T_inv = np.dot(np.diag(D**(-1)),P.T) + + #print( np.max(A - np.dot(T, np.dot(bA, T_inv) )) ) + return bA.copy(), T, T_inv + +def balance_ss_model(F,L,Qc,H,Pinf,P0,dF=None,dQc=None,dPinf=None,dP0=None): + """ + Balances State-Space model for more numerical stability + + This is based on the following: + + dx/dt = F x + L w + y = H x + + Let T z = x, which gives + + dz/dt = inv(T) F T z + inv(T) L w + y = H T z + """ + + bF,T,T_inv = balance_matrix(F) + + bL = np.dot( T_inv, L) + bQc = Qc # not affected + + bH = np.dot(H, T) + + bPinf = np.dot(T_inv, np.dot(Pinf, T_inv.T)) + + #import pdb; pdb.set_trace() +# LL,islower = linalg.cho_factor(Pinf) +# inds = np.triu_indices(Pinf.shape[0],k=1) +# LL[inds] = 0.0 +# bLL = np.dot(T_inv, LL) +# bPinf = np.dot( bLL, bLL.T) + + bP0 = np.dot(T_inv, np.dot(P0, T_inv.T)) + + if dF is not None: + bdF = np.zeros(dF.shape) + for i in range(dF.shape[2]): + bdF[:,:,i] = np.dot( T_inv, np.dot( dF[:,:,i], T)) + + else: + bdF = None + + if dPinf is not None: + bdPinf = np.zeros(dPinf.shape) + for i in range(dPinf.shape[2]): + bdPinf[:,:,i] = np.dot( T_inv, np.dot( dPinf[:,:,i], T_inv.T)) + +# LL,islower = linalg.cho_factor(dPinf[:,:,i]) +# inds = np.triu_indices(dPinf[:,:,i].shape[0],k=1) +# LL[inds] = 0.0 +# bLL = np.dot(T_inv, LL) +# bdPinf[:,:,i] = np.dot( bLL, bLL.T) + + + else: + bdPinf = None + + if dP0 is not None: + bdP0 = np.zeros(dP0.shape) + for i in range(dP0.shape[2]): + bdP0[:,:,i] = np.dot( T_inv, np.dot( dP0[:,:,i], T_inv.T)) + else: + bdP0 = None + + + bdQc = dQc # not affected + + # (F,L,Qc,H,Pinf,P0,dF,dQc,dPinf,dP0) + + return bF, bL, bQc, bH, bPinf, bP0, bdF, bdQc, bdPinf, bdP0, T diff --git a/GPy/models/state_space_model.py b/GPy/models/state_space_model.py new file mode 100644 index 00000000..5d22c0fc --- /dev/null +++ b/GPy/models/state_space_model.py @@ -0,0 +1,424 @@ +# Copyright (c) 2013, Arno Solin. +# Licensed under the BSD 3-clause license (see LICENSE.txt) +# +# This implementation of converting GPs to state space models is based on the article: +# +# @article{Sarkka+Solin+Hartikainen:2013, +# author = {Simo S\"arkk\"a and Arno Solin and Jouni Hartikainen}, +# year = {2013}, +# title = {Spatiotemporal learning via infinite-dimensional {B}ayesian filtering and smoothing}, +# journal = {IEEE Signal Processing Magazine}, +# volume = {30}, +# number = {4}, +# pages = {51--61} +# } +# + +import numpy as np +from scipy import stats +from .. import likelihoods +#from . import state_space_setup as ss_setup +from ..core import Model +from . import state_space_main as ssm +from . import state_space_setup as ss_setup + +class StateSpace(Model): + def __init__(self, X, Y, kernel=None, noise_var=1.0, kalman_filter_type = 'regular', use_cython = False, name='StateSpace'): + super(StateSpace, self).__init__(name=name) + + if len(X.shape) == 1: + X = np.atleast_2d(X).T + self.num_data, self.input_dim = X.shape + + if len(Y.shape) == 1: + Y = np.atleast_2d(Y).T + + assert self.input_dim==1, "State space methods are only for 1D data" + + if len(Y.shape)==2: + num_data_Y, self.output_dim = Y.shape + ts_number = None + elif len(Y.shape)==3: + num_data_Y, self.output_dim, ts_number = Y.shape + + self.ts_number = ts_number + + assert num_data_Y == self.num_data, "X and Y data don't match" + assert self.output_dim == 1, "State space methods are for single outputs only" + + self.kalman_filter_type = kalman_filter_type + #self.kalman_filter_type = 'svd' # temp test + ss_setup.use_cython = use_cython + + #import pdb; pdb.set_trace() + + global ssm + #from . import state_space_main as ssm + if (ssm.cython_code_available) and (ssm.use_cython != ss_setup.use_cython): + reload(ssm) + # Make sure the observations are ordered in time + sort_index = np.argsort(X[:,0]) + self.X = X[sort_index] + self.Y = Y[sort_index] + + # Noise variance + self.likelihood = likelihoods.Gaussian(variance=noise_var) + + # Default kernel + if kernel is None: + raise ValueError("State-Space Model: the kernel must be provided.") + else: + self.kern = kernel + + self.link_parameter(self.kern) + self.link_parameter(self.likelihood) + self.posterior = None + + # Assert that the kernel is supported + if not hasattr(self.kern, 'sde'): + raise NotImplementedError('SDE must be implemented for the kernel being used') + #assert self.kern.sde() not False, "This kernel is not supported for state space estimation" + + def parameters_changed(self): + """ + Parameters have now changed + """ + + #np.set_printoptions(16) + #print(self.param_array) + #import pdb; pdb.set_trace() + + # Get the model matrices from the kernel + (F,L,Qc,H,P_inf, P0, dFt,dQct,dP_inft, dP0t) = self.kern.sde() + + # necessary parameters + measurement_dim = self.output_dim + grad_params_no = dFt.shape[2]+1 # we also add measurement noise as a parameter + + # add measurement noise as a parameter and get the gradient matrices + dF = np.zeros([dFt.shape[0],dFt.shape[1],grad_params_no]) + dQc = np.zeros([dQct.shape[0],dQct.shape[1],grad_params_no]) + dP_inf = np.zeros([dP_inft.shape[0],dP_inft.shape[1],grad_params_no]) + dP0 = np.zeros([dP0t.shape[0],dP0t.shape[1],grad_params_no]) + + # Assign the values for the kernel function + dF[:,:,:-1] = dFt + dQc[:,:,:-1] = dQct + dP_inf[:,:,:-1] = dP_inft + dP0[:,:,:-1] = dP0t + + # The sigma2 derivative + dR = np.zeros([measurement_dim,measurement_dim,grad_params_no]) + dR[:,:,-1] = np.eye(measurement_dim) + + # Balancing + #(F,L,Qc,H,P_inf,P0, dF,dQc,dP_inf,dP0) = ssm.balance_ss_model(F,L,Qc,H,P_inf,P0, dF,dQc,dP_inf, dP0) + + # Use the Kalman filter to evaluate the likelihood + grad_calc_params = {} + grad_calc_params['dP_inf'] = dP_inf + grad_calc_params['dF'] = dF + grad_calc_params['dQc'] = dQc + grad_calc_params['dR'] = dR + grad_calc_params['dP_init'] = dP0 + + kalman_filter_type = self.kalman_filter_type + + # The following code is required because sometimes the shapes of self.Y + # becomes 3D even though is must be 2D. The reason is undescovered. + Y = self.Y + if self.ts_number is None: + Y.shape = (self.num_data,1) + else: + Y.shape = (self.num_data,1,self.ts_number) + + (filter_means, filter_covs, log_likelihood, + grad_log_likelihood,SmootherMatrObject) = ssm.ContDescrStateSpace.cont_discr_kalman_filter(F,L,Qc,H, + float(self.Gaussian_noise.variance),P_inf,self.X,Y,m_init=None, + P_init=P0, p_kalman_filter_type = kalman_filter_type, calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=grad_params_no, + grad_calc_params=grad_calc_params) + + if np.any( np.isfinite(log_likelihood) == False): + #import pdb; pdb.set_trace() + print("State-Space: NaN valkues in the log_likelihood") + + if np.any( np.isfinite(grad_log_likelihood) == False): + #import pdb; pdb.set_trace() + print("State-Space: NaN valkues in the grad_log_likelihood") + #print(grad_log_likelihood) + + grad_log_likelihood_sum = np.sum(grad_log_likelihood,axis=1) + grad_log_likelihood_sum.shape = (grad_log_likelihood_sum.shape[0],1) + self._log_marginal_likelihood = np.sum( log_likelihood,axis=1 ) + self.likelihood.update_gradients(grad_log_likelihood_sum[-1,0]) + + self.kern.sde_update_gradient_full(grad_log_likelihood_sum[:-1,0]) + + def log_likelihood(self): + return self._log_marginal_likelihood + + def _raw_predict(self, Xnew=None, Ynew=None, filteronly=False, **kw): + """ + Performs the actual prediction for new X points. + Inner function. It is called only from inside this class. + + Input: + --------------------- + + Xnews: vector or (n_points,1) matrix + New time points where to evaluate predictions. + + Ynews: (n_train_points, ts_no) matrix + This matrix can substitude the original training points (in order + to use only the parameters of the model). + + filteronly: bool + Use only Kalman Filter for prediction. In this case the output does + not coincide with corresponding Gaussian process. + + Output: + -------------------- + + m: vector + Mean prediction + + V: vector + Variance in every point + """ + + # Set defaults + if Ynew is None: + Ynew = self.Y + + # Make a single matrix containing training and testing points + if Xnew is not None: + X = np.vstack((self.X, Xnew)) + Y = np.vstack((Ynew, np.nan*np.zeros(Xnew.shape))) + predict_only_training = False + else: + X = self.X + Y = Ynew + predict_only_training = True + + # Sort the matrix (save the order) + _, return_index, return_inverse = np.unique(X,True,True) + X = X[return_index] # TODO they are not used + Y = Y[return_index] + + # Get the model matrices from the kernel + (F,L,Qc,H,P_inf, P0, dF,dQc,dP_inf,dP0) = self.kern.sde() + state_dim = F.shape[0] + + #Y = self.Y[:, 0,0] + # Run the Kalman filter + #import pdb; pdb.set_trace() + kalman_filter_type = self.kalman_filter_type + + (M, P, log_likelihood, + grad_log_likelihood,SmootherMatrObject) = ssm.ContDescrStateSpace.cont_discr_kalman_filter( + F,L,Qc,H,float(self.Gaussian_noise.variance),P_inf,X,Y,m_init=None, + P_init=P0, p_kalman_filter_type = kalman_filter_type, + calc_log_likelihood=False, + calc_grad_log_likelihood=False) + +# (filter_means, filter_covs, log_likelihood, +# grad_log_likelihood,SmootherMatrObject) = ssm.ContDescrStateSpace.cont_discr_kalman_filter(F,L,Qc,H, +# float(self.Gaussian_noise.variance),P_inf,self.X,self.Y,m_init=None, +# P_init=P0, p_kalman_filter_type = kalman_filter_type, calc_log_likelihood=True, +# calc_grad_log_likelihood=True, +# grad_params_no=grad_params_no, +# grad_calc_params=grad_calc_params) + + # Run the Rauch-Tung-Striebel smoother + if not filteronly: + (M, P) = ssm.ContDescrStateSpace.cont_discr_rts_smoother(state_dim, M, P, + p_dynamic_callables=SmootherMatrObject, X=X, F=F,L=L,Qc=Qc) + + # remove initial values + M = M[1:,:,:] + P = P[1:,:,:] + + # Put the data back in the original order + M = M[return_inverse,:,:] + P = P[return_inverse,:,:] + + # Only return the values for Xnew + if not predict_only_training: + M = M[self.num_data:,:,:] + P = P[self.num_data:,:,:] + + # Calculate the mean and variance + # after einsum m has dimension in 3D (sample_num, dim_no,time_series_no) + m = np.einsum('ijl,kj', M, H)# np.dot(M,H.T) + m.shape = (m.shape[0], m.shape[1]) # remove the third dimension + + V = np.einsum('ij,ajk,kl', H, P, H.T) + + V.shape = (V.shape[0], V.shape[1]) # remove the third dimension + + # Return the posterior of the state + return (m, V) + + def predict(self, Xnew=None, filteronly=False, include_likelihood=True, **kw): + + # Run the Kalman filter to get the state + (m, V) = self._raw_predict(Xnew,filteronly=filteronly) + + # Add the noise variance to the state variance + if include_likelihood: + V += float(self.likelihood.variance) + + # Lower and upper bounds + #lower = m - 2*np.sqrt(V) + #upper = m + 2*np.sqrt(V) + + # Return mean and variance + return m, V + + def predict_quantiles(self, Xnew=None, quantiles=(2.5, 97.5), **kw): + mu, var = self._raw_predict(Xnew) + #import pdb; pdb.set_trace() + return [stats.norm.ppf(q/100.)*np.sqrt(var + float(self.Gaussian_noise.variance)) + mu for q in quantiles] + + +# def plot(self, plot_limits=None, levels=20, samples=0, fignum=None, +# ax=None, resolution=None, plot_raw=False, plot_filter=False, +# linecol=Tango.colorsHex['darkBlue'],fillcol=Tango.colorsHex['lightBlue']): +# +# # Deal with optional parameters +# if ax is None: +# fig = pb.figure(num=fignum) +# ax = fig.add_subplot(111) +# +# # Define the frame on which to plot +# resolution = resolution or 200 +# Xgrid, xmin, xmax = x_frame1D(self.X, plot_limits=plot_limits) +# +# # Make a prediction on the frame and plot it +# if plot_raw: +# m, v = self.predict_raw(Xgrid,filteronly=plot_filter) +# lower = m - 2*np.sqrt(v) +# upper = m + 2*np.sqrt(v) +# Y = self.Y +# else: +# m, v, lower, upper = self.predict(Xgrid,filteronly=plot_filter) +# Y = self.Y +# +# # Plot the values +# gpplot(Xgrid, m, lower, upper, axes=ax, edgecol=linecol, fillcol=fillcol) +# ax.plot(self.X, self.Y, 'kx', mew=1.5) +# +# # Optionally plot some samples +# if samples: +# if plot_raw: +# Ysim = self.posterior_samples_f(Xgrid, samples) +# else: +# Ysim = self.posterior_samples(Xgrid, samples) +# for yi in Ysim.T: +# ax.plot(Xgrid, yi, Tango.colorsHex['darkBlue'], linewidth=0.25) +# +# # Set the limits of the plot to some sensible values +# ymin, ymax = min(np.append(Y.flatten(), lower.flatten())), max(np.append(Y.flatten(), upper.flatten())) +# ymin, ymax = ymin - 0.1 * (ymax - ymin), ymax + 0.1 * (ymax - ymin) +# ax.set_xlim(xmin, xmax) +# ax.set_ylim(ymin, ymax) +# +# def prior_samples_f(self,X,size=10): +# +# # Sort the matrix (save the order) +# (_, return_index, return_inverse) = np.unique(X,True,True) +# X = X[return_index] +# +# # Get the model matrices from the kernel +# (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() +# +# # Allocate space for results +# Y = np.empty((size,X.shape[0])) +# +# # Simulate random draws +# #for j in range(0,size): +# # Y[j,:] = H.dot(self.simulate(F,L,Qc,Pinf,X.T)) +# Y = self.simulate(F,L,Qc,Pinf,X.T,size) +# +# # Only observations +# Y = np.tensordot(H[0],Y,(0,0)) +# +# # Reorder simulated values +# Y = Y[:,return_inverse] +# +# # Return trajectory +# return Y.T +# +# def posterior_samples_f(self,X,size=10): +# +# # Sort the matrix (save the order) +# (_, return_index, return_inverse) = np.unique(X,True,True) +# X = X[return_index] +# +# # Get the model matrices from the kernel +# (F,L,Qc,H,Pinf,dF,dQc,dPinf) = self.kern.sde() +# +# # Run smoother on original data +# (m,V) = self.predict_raw(X) +# +# # Simulate random draws from the GP prior +# y = self.prior_samples_f(np.vstack((self.X, X)),size) +# +# # Allocate space for sample trajectories +# Y = np.empty((size,X.shape[0])) +# +# # Run the RTS smoother on each of these values +# for j in range(0,size): +# yobs = y[0:self.num_data,j:j+1] + np.sqrt(self.sigma2)*np.random.randn(self.num_data,1) +# (m2,V2) = self.predict_raw(X,Ynew=yobs) +# Y[j,:] = m.T + y[self.num_data:,j].T - m2.T +# +# # Reorder simulated values +# Y = Y[:,return_inverse] +# +# # Return posterior sample trajectories +# return Y.T +# +# def posterior_samples(self, X, size=10): +# +# # Make samples of f +# Y = self.posterior_samples_f(X,size) +# +# # Add noise +# Y += np.sqrt(self.sigma2)*np.random.randn(Y.shape[0],Y.shape[1]) +# +# # Return trajectory +# return Y +# +# +# def simulate(self,F,L,Qc,Pinf,X,size=1): +# # Simulate a trajectory using the state space model +# +# # Allocate space for results +# f = np.zeros((F.shape[0],size,X.shape[1])) +# +# # Initial state +# f[:,:,1] = np.linalg.cholesky(Pinf).dot(np.random.randn(F.shape[0],size)) +# +# # Time step lengths +# dt = np.empty(X.shape) +# dt[:,0] = X[:,1]-X[:,0] +# dt[:,1:] = np.diff(X) +# +# # Solve the LTI SDE for these time steps +# As, Qs, index = ssm.ContDescrStateSpace.lti_sde_to_descrete(F,L,Qc,dt) +# +# # Sweep through remaining time points +# for k in range(1,X.shape[1]): +# +# # Form discrete-time model +# A = As[:,:,index[1-k]] +# Q = Qs[:,:,index[1-k]] +# +# # Draw the state +# f[:,:,k] = A.dot(f[:,:,k-1]) + np.dot(np.linalg.cholesky(Q),np.random.randn(A.shape[0],size)) +# +# # Return values +# return f diff --git a/GPy/models/state_space_setup.py b/GPy/models/state_space_setup.py new file mode 100644 index 00000000..f5c4f735 --- /dev/null +++ b/GPy/models/state_space_setup.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +This module is intended for the setup of state_space_main module. +The need of this module appeared because of the way state_space_main module +connected with cython code. +""" + +use_cython = False \ No newline at end of file diff --git a/GPy/models/warped_gp.py b/GPy/models/warped_gp.py index df947d3e..a24401fe 100644 --- a/GPy/models/warped_gp.py +++ b/GPy/models/warped_gp.py @@ -2,65 +2,56 @@ # Licensed under the BSD 3-clause license (see LICENSE.txt) import numpy as np -from ..util.warping_functions import * +#from ..util.warping_functions import * from ..core import GP from .. import likelihoods -from GPy.util.warping_functions import TanhWarpingFunction_d +from paramz import ObsAr +#from GPy.util.warping_functions import TanhFunction +from ..util.warping_functions import TanhFunction from GPy import kern class WarpedGP(GP): - def __init__(self, X, Y, kernel=None, warping_function=None, warping_terms=3): - + """ + This defines a GP Regression model that applies a + warping function to the output. + """ + def __init__(self, X, Y, kernel=None, warping_function=None, warping_terms=3, normalizer=False): if kernel is None: kernel = kern.RBF(X.shape[1]) - if warping_function == None: - self.warping_function = TanhWarpingFunction_d(warping_terms) + self.warping_function = TanhFunction(warping_terms) self.warping_params = (np.random.randn(self.warping_function.n_terms * 3 + 1) * 1) else: self.warping_function = warping_function - - self.scale_data = False - if self.scale_data: - Y = self._scale_data(Y) - #self.has_uncertain_inputs = False - self.Y_untransformed = Y.copy() - self.predict_in_warped_space = True likelihood = likelihoods.Gaussian() - - GP.__init__(self, X, self.transform_data(), likelihood=likelihood, kernel=kernel) + super(WarpedGP, self).__init__(X, Y.copy(), likelihood=likelihood, kernel=kernel, normalizer=normalizer) + self.Y_normalized = self.Y_normalized.copy() + self.Y_untransformed = self.Y_normalized.copy() + self.predict_in_warped_space = True self.link_parameter(self.warping_function) - def _scale_data(self, Y): - self._Ymax = Y.max() - self._Ymin = Y.min() - return (Y - self._Ymin) / (self._Ymax - self._Ymin) - 0.5 - - def _unscale_data(self, Y): - return (Y + 0.5) * (self._Ymax - self._Ymin) + self._Ymin + def set_XY(self, X=None, Y=None): + super(WarpedGP, self).set_XY(X, Y) + self.Y_untransformed = self.Y_normalized.copy() + self.update_model(True) def parameters_changed(self): - self.Y[:] = self.transform_data() + """ + Notice that we update the warping function gradients here. + """ + self.Y_normalized[:] = self.transform_data() super(WarpedGP, self).parameters_changed() - Kiy = self.posterior.woodbury_vector.flatten() - - grad_y = self.warping_function.fgrad_y(self.Y_untransformed) - grad_y_psi, grad_psi = self.warping_function.fgrad_y_psi(self.Y_untransformed, - return_covar_chain=True) - djac_dpsi = ((1.0 / grad_y[:, :, None, None]) * grad_y_psi).sum(axis=0).sum(axis=0) - dquad_dpsi = (Kiy[:, None, None, None] * grad_psi).sum(axis=0).sum(axis=0) - - warping_grads = -dquad_dpsi + djac_dpsi - - self.warping_function.psi.gradient[:] = warping_grads[:, :-1] - self.warping_function.d.gradient[:] = warping_grads[0, -1] + self.warping_function.update_grads(self.Y_untransformed, Kiy) def transform_data(self): Y = self.warping_function.f(self.Y_untransformed.copy()).copy() return Y def log_likelihood(self): + """ + Notice we add the jacobian of the warping function here. + """ ll = GP.log_likelihood(self) jacobian = self.warping_function.fgrad_y(self.Y_untransformed) return ll + np.log(jacobian).sum() @@ -73,36 +64,42 @@ class WarpedGP(GP): arg2 = np.ones(shape=gh_samples.shape).dot(mean.T) return self.warping_function.f_inv(arg1 + arg2, y=pred_init) - def _get_warped_mean(self, mean, std, pred_init=None, deg_gauss_hermite=100): + def _get_warped_mean(self, mean, std, pred_init=None, deg_gauss_hermite=20): """ Calculate the warped mean by using Gauss-Hermite quadrature. """ gh_samples, gh_weights = np.polynomial.hermite.hermgauss(deg_gauss_hermite) - gh_samples = gh_samples[:,None] - gh_weights = gh_weights[None,:] + gh_samples = gh_samples[:, None] + gh_weights = gh_weights[None, :] return gh_weights.dot(self._get_warped_term(mean, std, gh_samples)) / np.sqrt(np.pi) - def _get_warped_variance(self, mean, std, pred_init=None, deg_gauss_hermite=100): + def _get_warped_variance(self, mean, std, pred_init=None, deg_gauss_hermite=20): """ Calculate the warped variance by using Gauss-Hermite quadrature. """ gh_samples, gh_weights = np.polynomial.hermite.hermgauss(deg_gauss_hermite) - gh_samples = gh_samples[:,None] - gh_weights = gh_weights[None,:] + gh_samples = gh_samples[:, None] + gh_weights = gh_weights[None, :] arg1 = gh_weights.dot(self._get_warped_term(mean, std, gh_samples, pred_init=pred_init) ** 2) / np.sqrt(np.pi) arg2 = self._get_warped_mean(mean, std, pred_init=pred_init, deg_gauss_hermite=deg_gauss_hermite) return arg1 - (arg2 ** 2) - def predict(self, Xnew, which_parts='all', pred_init=None, full_cov=False, Y_metadata=None, - median=False, deg_gauss_hermite=100): - # normalize X values - # Xnew = (Xnew.copy() - self._Xoffset) / self._Xscale - mu, var = GP._raw_predict(self, Xnew) - + def predict(self, Xnew, kern=None, pred_init=None, Y_metadata=None, + median=False, deg_gauss_hermite=20, likelihood=None): + """ + Prediction results depend on: + - The value of the self.predict_in_warped_space flag + - The median flag passed as argument + The likelihood keyword is never used, it is just to follow the plotting API. + """ + #mu, var = GP._raw_predict(self, Xnew) # now push through likelihood - mean, var = self.likelihood.predictive_values(mu, var) + #mean, var = self.likelihood.predictive_values(mu, var) + + mean, var = super(WarpedGP, self).predict(Xnew, kern=kern, full_cov=False, likelihood=likelihood) + if self.predict_in_warped_space: std = np.sqrt(var) @@ -116,13 +113,9 @@ class WarpedGP(GP): else: wmean = mean wvar = var - - if self.scale_data: - pred = self._unscale_data(pred) - return wmean, wvar - def predict_quantiles(self, X, quantiles=(2.5, 97.5), Y_metadata=None): + def predict_quantiles(self, X, quantiles=(2.5, 97.5), Y_metadata=None, likelihood=None, kern=None): """ Get the predictive quantiles around the prediction at X @@ -133,19 +126,38 @@ class WarpedGP(GP): :returns: list of quantiles for each X and predictive quantiles for interval combination :rtype: [np.ndarray (Xnew x self.input_dim), np.ndarray (Xnew x self.input_dim)] """ - m, v = self._raw_predict(X, full_cov=False) - if self.normalizer is not None: - m, v = self.normalizer.inverse_mean(m), self.normalizer.inverse_variance(v) - a, b = self.likelihood.predictive_quantiles(m, v, quantiles, Y_metadata) - #return [a, b] - if not self.predict_in_warped_space: - return [a, b] - #print a.shape - new_a = self.warping_function.f_inv(a) - new_b = self.warping_function.f_inv(b) + qs = super(WarpedGP, self).predict_quantiles(X, quantiles, Y_metadata=Y_metadata, likelihood=likelihood, kern=kern) + if self.predict_in_warped_space: + return [self.warping_function.f_inv(q) for q in qs] + return qs + #m, v = self._raw_predict(X, full_cov=False) + #if self.normalizer is not None: + # m, v = self.normalizer.inverse_mean(m), self.normalizer.inverse_variance(v) + #a, b = self.likelihood.predictive_quantiles(m, v, quantiles, Y_metadata) + #if not self.predict_in_warped_space: + # return [a, b] + #new_a = self.warping_function.f_inv(a) + #new_b = self.warping_function.f_inv(b) + #return [new_a, new_b] - return [new_a, new_b] - #return self.likelihood.predictive_quantiles(m, v, quantiles, Y_metadata) + def log_predictive_density(self, x_test, y_test, Y_metadata=None): + """ + Calculation of the log predictive density. Notice we add + the jacobian of the warping function here. + + .. math: + p(y_{*}|D) = p(y_{*}|f_{*})p(f_{*}|\mu_{*}\\sigma^{2}_{*}) + + :param x_test: test locations (x_{*}) + :type x_test: (Nx1) array + :param y_test: test observations (y_{*}) + :type y_test: (Nx1) array + :param Y_metadata: metadata associated with the test points + """ + mu_star, var_star = self._raw_predict(x_test) + fy = self.warping_function.f(y_test) + ll_lpd = self.likelihood.log_predictive_density(fy, mu_star, var_star, Y_metadata=Y_metadata) + return ll_lpd + np.log(self.warping_function.fgrad_y(y_test)) if __name__ == '__main__': diff --git a/GPy/plotting/__init__.py b/GPy/plotting/__init__.py index 0bb91254..359a841a 100644 --- a/GPy/plotting/__init__.py +++ b/GPy/plotting/__init__.py @@ -50,8 +50,23 @@ def inject_plotting(): GP.plot_samples = gpy_plot.gp_plots.plot_samples GP.plot = gpy_plot.gp_plots.plot GP.plot_f = gpy_plot.gp_plots.plot_f + GP.plot_latent = gpy_plot.gp_plots.plot_f + GP.plot_noiseless = gpy_plot.gp_plots.plot_f GP.plot_magnification = gpy_plot.latent_plots.plot_magnification + from ..models import StateSpace + StateSpace.plot_data = gpy_plot.data_plots.plot_data + StateSpace.plot_data_error = gpy_plot.data_plots.plot_data_error + StateSpace.plot_errorbars_trainset = gpy_plot.data_plots.plot_errorbars_trainset + StateSpace.plot_mean = gpy_plot.gp_plots.plot_mean + StateSpace.plot_confidence = gpy_plot.gp_plots.plot_confidence + StateSpace.plot_density = gpy_plot.gp_plots.plot_density + StateSpace.plot_samples = gpy_plot.gp_plots.plot_samples + StateSpace.plot = gpy_plot.gp_plots.plot + StateSpace.plot_f = gpy_plot.gp_plots.plot_f + StateSpace.plot_latent = gpy_plot.gp_plots.plot_f + StateSpace.plot_noiseless = gpy_plot.gp_plots.plot_f + from ..core import SparseGP SparseGP.plot_inducing = gpy_plot.data_plots.plot_inducing diff --git a/GPy/plotting/abstract_plotting_library.py b/GPy/plotting/abstract_plotting_library.py index 64061b99..95377ed7 100644 --- a/GPy/plotting/abstract_plotting_library.py +++ b/GPy/plotting/abstract_plotting_library.py @@ -61,6 +61,8 @@ class AbstractPlottingLibrary(object): """ Get a new figure with nrows and ncolumns subplots. Does not initialize the canvases yet. + + There is individual kwargs for the individual plotting libraries to use. """ raise NotImplementedError("Implement all plot functions in AbstractPlottingLibrary in order to use your own plotting library") diff --git a/GPy/plotting/gpy_plot/data_plots.py b/GPy/plotting/gpy_plot/data_plots.py index a24a67ab..e806f1e2 100644 --- a/GPy/plotting/gpy_plot/data_plots.py +++ b/GPy/plotting/gpy_plot/data_plots.py @@ -158,7 +158,7 @@ def _plot_data_error(self, canvas, which_data_rows='all', return plots -def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', **plot_kwargs): +def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', legend=True, **plot_kwargs): """ Plot the inducing inputs of a sparse gp model @@ -167,7 +167,7 @@ def plot_inducing(self, visible_dims=None, projection='2d', label='inducing', ** """ canvas, kwargs = pl().new_canvas(projection=projection, **plot_kwargs) plots = _plot_inducing(self, canvas, visible_dims, projection, label, **kwargs) - return pl().add_to_canvas(canvas, plots, legend=label is not None) + return pl().add_to_canvas(canvas, plots, legend=legend) def _plot_inducing(self, canvas, visible_dims, projection, label, **plot_kwargs): if visible_dims is None: @@ -175,7 +175,7 @@ def _plot_inducing(self, canvas, visible_dims, projection, label, **plot_kwargs) visible_dims = [i for i in sig_dims if i is not None] free_dims = get_free_dims(self, visible_dims, None) - Z = self.Z[:, free_dims] + Z = self.Z.values plots = {} #one dimensional plotting diff --git a/GPy/plotting/gpy_plot/latent_plots.py b/GPy/plotting/gpy_plot/latent_plots.py index 5427e013..f76fda1c 100644 --- a/GPy/plotting/gpy_plot/latent_plots.py +++ b/GPy/plotting/gpy_plot/latent_plots.py @@ -112,26 +112,29 @@ def plot_latent_inducing(self, which_indices=None, legend=False, plot_limits=None, - marker='^', - num_samples=1000, + marker=None, projection='2d', **kwargs): """ Plot a scatter plot of the inducing inputs. - :param array-like labels: a label for each data point (row) of the inputs - :param (int, int) which_indices: which input dimensions to plot against each other + :param [int] which_indices: which input dimensions to plot against each other :param bool legend: whether to plot the legend on the figure :param plot_limits: the plot limits for the plot :type plot_limits: (xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax)) - :param str marker: markers to use - cycle if more labels then markers are given + :param str marker: marker to use [default is custom arrow like] :param kwargs: the kwargs for the scatter plots + :param str projection: for now 2d or 3d projection (other projections can be implemented, see developer documentation) """ canvas, projection, kwargs, sig_dims = _new_canvas(self, projection, kwargs, which_indices) - Z = self.Z.values - labels = np.array(['inducing'] * Z.shape[0]) - scatters = _plot_latent_scatter(canvas, Z, sig_dims, labels, marker, num_samples, projection=projection, **kwargs) + if legend: label = 'inducing' + else: label = None + if marker is not None: + kwargs['marker'] = marker + update_not_existing_kwargs(kwargs, pl().defaults.inducing_2d) # @UndefinedVariable + from .data_plots import _plot_inducing + scatters = _plot_inducing(self, canvas, sig_dims[:2], projection, label, **kwargs) return pl().add_to_canvas(canvas, dict(scatter=scatters), legend=legend) diff --git a/GPy/plotting/gpy_plot/plot_util.py b/GPy/plotting/gpy_plot/plot_util.py index 3089af20..7bd1723f 100644 --- a/GPy/plotting/gpy_plot/plot_util.py +++ b/GPy/plotting/gpy_plot/plot_util.py @@ -31,6 +31,7 @@ import numpy as np from scipy import sparse import itertools +from ...models import WarpedGP def in_ipynb(): try: @@ -190,6 +191,7 @@ def scatter_label_generator(labels, X, visible_dims, marker=None): x = X[index, input_1] y = X[index, input_2] z = X[index, input_3] + yield x, y, z, this_label, index, m def subsample_X(X, labels, num_samples=1000): @@ -294,6 +296,10 @@ def get_x_y_var(model): Y = model.Y.values except AttributeError: Y = model.Y + + if isinstance(model, WarpedGP) and not model.predict_in_warped_space: + Y = model.Y_normalized + if sparse.issparse(Y): Y = Y.todense().view(np.ndarray) return X, X_variance, Y @@ -379,5 +385,5 @@ def x_frame2D(X,plot_limits=None,resolution=None): resolution = resolution or 50 xx, yy = np.mgrid[xmin[0]:xmax[0]:1j*resolution,xmin[1]:xmax[1]:1j*resolution] - Xnew = np.vstack((xx.flatten(),yy.flatten())).T + Xnew = np.c_[xx.flat, yy.flat] return Xnew, xx, yy, xmin, xmax diff --git a/GPy/plotting/matplot_dep/defaults.py b/GPy/plotting/matplot_dep/defaults.py index 69257c8c..8518b9d0 100644 --- a/GPy/plotting/matplot_dep/defaults.py +++ b/GPy/plotting/matplot_dep/defaults.py @@ -1,21 +1,21 @@ #=============================================================================== # Copyright (c) 2015, Max Zwiessele # All rights reserved. -# +# # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: -# +# # * Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. -# +# # * Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. -# +# # * Neither the name of GPy nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. -# +# # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -34,20 +34,20 @@ from .. import Tango ''' This file is for defaults for the gpy plot, specific to the plotting library. -Create a kwargs dictionary with the right name for the plotting function +Create a kwargs dictionary with the right name for the plotting function you are implementing. If you do not provide defaults, the default behaviour of -the plotting library will be used. +the plotting library will be used. -In the code, always ise plotting.gpy_plots.defaults to get the defaults, as +In the code, always ise plotting.gpy_plots.defaults to get the defaults, as it gives back an empty default, when defaults are not defined. ''' # Data plots: -data_1d = dict(lw=1.5, marker='x', edgecolor='k') +data_1d = dict(lw=1.5, marker='x', color='k') data_2d = dict(s=35, edgecolors='none', linewidth=0., cmap=cm.get_cmap('hot'), alpha=.5) -inducing_1d = dict(lw=0, s=500, facecolors=Tango.colorsHex['darkRed']) -inducing_2d = dict(s=14, edgecolors='k', linewidth=.4, facecolors='white', alpha=.5, marker='^') -inducing_3d = dict(lw=.3, s=500, facecolors='white', edgecolors='k') +inducing_1d = dict(lw=0, s=500, color=Tango.colorsHex['darkRed']) +inducing_2d = dict(s=17, edgecolor='k', linewidth=.4, color='white', alpha=.5, marker='^') +inducing_3d = dict(lw=.3, s=500, color=Tango.colorsHex['darkRed'], edgecolor='k') xerrorbar = dict(color='k', fmt='none', elinewidth=.5, alpha=.5) yerrorbar = dict(color=Tango.colorsHex['darkRed'], fmt='none', elinewidth=.5, alpha=.5) @@ -71,5 +71,5 @@ ard = dict(edgecolor='k', linewidth=1.2) latent = dict(aspect='auto', cmap='Greys', interpolation='bicubic') gradient = dict(aspect='auto', cmap='RdBu', interpolation='nearest', alpha=.7) magnification = dict(aspect='auto', cmap='Greys', interpolation='bicubic') -latent_scatter = dict(s=40, linewidth=.2, edgecolor='k', alpha=.9) +latent_scatter = dict(s=20, linewidth=.2, edgecolor='k', alpha=.9) annotation = dict(fontdict=dict(family='sans-serif', weight='light', fontsize=9), zorder=.3, alpha=.7) diff --git a/GPy/plotting/matplot_dep/plot_definitions.py b/GPy/plotting/matplot_dep/plot_definitions.py index 52100ea3..0e3bc32d 100644 --- a/GPy/plotting/matplot_dep/plot_definitions.py +++ b/GPy/plotting/matplot_dep/plot_definitions.py @@ -106,7 +106,7 @@ class MatplotlibPlots(AbstractPlottingLibrary): return ax.plot(X, Y, color=color, zs=Z, label=label, **kwargs) return ax.plot(X, Y, color=color, label=label, **kwargs) - def plot_axis_lines(self, ax, X, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs): + def plot_axis_lines(self, ax, X, color=Tango.colorsHex['darkRed'], label=None, **kwargs): from matplotlib import transforms from matplotlib.path import Path if 'marker' not in kwargs: @@ -126,14 +126,14 @@ class MatplotlibPlots(AbstractPlottingLibrary): bottom=bottom, label=label, color=color, **kwargs) - def xerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs): + def xerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['darkRed'], label=None, **kwargs): if not('linestyle' in kwargs or 'ls' in kwargs): kwargs['ls'] = 'none' #if Z is not None: # return ax.errorbar(X, Y, Z, xerr=error, ecolor=color, label=label, **kwargs) return ax.errorbar(X, Y, xerr=error, ecolor=color, label=label, **kwargs) - def yerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs): + def yerrorbar(self, ax, X, Y, error, color=Tango.colorsHex['darkRed'], label=None, **kwargs): if not('linestyle' in kwargs or 'ls' in kwargs): kwargs['ls'] = 'none' #if Z is not None: diff --git a/GPy/plotting/matplot_dep/variational_plots.py b/GPy/plotting/matplot_dep/variational_plots.py index 34681552..3f20efeb 100644 --- a/GPy/plotting/matplot_dep/variational_plots.py +++ b/GPy/plotting/matplot_dep/variational_plots.py @@ -15,7 +15,9 @@ def plot(parameterized, fignum=None, ax=None, colors=None, figsize=(12, 6)): if ax is None: fig = pb.figure(num=fignum, figsize=figsize) if colors is None: - colors = pb.gca()._get_lines.color_cycle + from ..Tango import mediumList + from itertools import cycle + colors = cycle(mediumList) pb.clf() else: colors = iter(colors) @@ -32,7 +34,7 @@ def plot(parameterized, fignum=None, ax=None, colors=None, figsize=(12, 6)): else: raise ValueError("Need one ax per latent dimension input_dim") bg_lines.append(a.plot(means, c='k', alpha=.3)) - lines.extend(a.plot(x, means.T[i], c=colors.next(), label=r"$\mathbf{{X_{{{}}}}}$".format(i))) + lines.extend(a.plot(x, means.T[i], c=next(colors), label=r"$\mathbf{{X_{{{}}}}}$".format(i))) fills.append(a.fill_between(x, means.T[i] - 2 * np.sqrt(variances.T[i]), means.T[i] + 2 * np.sqrt(variances.T[i]), @@ -64,7 +66,9 @@ def plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_sid else: fig = pb.figure(num=fignum, figsize=(8, min(12, (2 * parameterized.mean.shape[1])))) if colors is None: - colors = pb.gca()._get_lines.color_cycle + from ..Tango import mediumList + from itertools import cycle + colors = cycle(mediumList) pb.clf() else: colors = iter(colors) @@ -82,7 +86,7 @@ def plot_SpikeSlab(parameterized, fignum=None, ax=None, colors=None, side_by_sid # mean and variance plot a = fig.add_subplot(*sub1) a.plot(means, c='k', alpha=.3) - plots.extend(a.plot(x, means.T[i], c=colors.next(), label=r"$\mathbf{{X_{{{}}}}}$".format(i))) + plots.extend(a.plot(x, means.T[i], c=next(colors), label=r"$\mathbf{{X_{{{}}}}}$".format(i))) a.fill_between(x, means.T[i] - 2 * np.sqrt(variances.T[i]), means.T[i] + 2 * np.sqrt(variances.T[i]), diff --git a/GPy/plotting/plotly_dep/plot_definitions.py b/GPy/plotting/plotly_dep/plot_definitions.py index eaa70f32..9e021fd8 100644 --- a/GPy/plotting/plotly_dep/plot_definitions.py +++ b/GPy/plotting/plotly_dep/plot_definitions.py @@ -131,14 +131,15 @@ class PlotlyPlots(AbstractPlottingLibrary): #not matplotlib marker pass marker_kwargs = marker_kwargs or {} - marker_kwargs.setdefault('symbol', marker) + if 'symbol' not in marker_kwargs: + marker_kwargs['symbol'] = marker if Z is not None: return Scatter3d(x=X, y=Y, z=Z, mode='markers', showlegend=label is not None, marker=Marker(color=color, colorscale=cmap, **marker_kwargs), name=label, **kwargs) return Scatter(x=X, y=Y, mode='markers', showlegend=label is not None, - marker=Marker(color=color, colorscale=cmap, **marker_kwargs or {}), + marker=Marker(color=color, colorscale=cmap, **marker_kwargs), name=label, **kwargs) def plot(self, ax, X, Y, Z=None, color=None, label=None, line_kwargs=None, **kwargs): diff --git a/GPy/testing/b-gplvm-save.npz b/GPy/testing/b-gplvm-save.npz new file mode 100644 index 00000000..bcbe84d7 Binary files /dev/null and b/GPy/testing/b-gplvm-save.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_gradient.npz b/GPy/testing/baseline/bayesian_gplvm_gradient.npz new file mode 100644 index 00000000..b48db887 Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_gradient.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_gradient.png b/GPy/testing/baseline/bayesian_gplvm_gradient.png deleted file mode 100644 index 5bf1286d..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_gradient.png and /dev/null differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing.npz b/GPy/testing/baseline/bayesian_gplvm_inducing.npz new file mode 100644 index 00000000..82e44f54 Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_inducing.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing.png b/GPy/testing/baseline/bayesian_gplvm_inducing.png deleted file mode 100644 index b3b154a8..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_inducing.png and /dev/null differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz b/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz new file mode 100644 index 00000000..e55b4b01 Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_inducing_3d.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_inducing_3d.png b/GPy/testing/baseline/bayesian_gplvm_inducing_3d.png deleted file mode 100644 index e8c73aca..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_inducing_3d.png and /dev/null differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent.npz b/GPy/testing/baseline/bayesian_gplvm_latent.npz new file mode 100644 index 00000000..3e27bc64 Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_latent.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent.png b/GPy/testing/baseline/bayesian_gplvm_latent.png deleted file mode 100644 index 9349f6db..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_latent.png and /dev/null differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz b/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz new file mode 100644 index 00000000..b4da4571 Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_latent_3d.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_latent_3d.png b/GPy/testing/baseline/bayesian_gplvm_latent_3d.png deleted file mode 100644 index f2ac36de..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_latent_3d.png and /dev/null differ diff --git a/GPy/testing/baseline/bayesian_gplvm_magnification.npz b/GPy/testing/baseline/bayesian_gplvm_magnification.npz new file mode 100644 index 00000000..dd83f22d Binary files /dev/null and b/GPy/testing/baseline/bayesian_gplvm_magnification.npz differ diff --git a/GPy/testing/baseline/bayesian_gplvm_magnification.png b/GPy/testing/baseline/bayesian_gplvm_magnification.png deleted file mode 100644 index 0ffaa918..00000000 Binary files a/GPy/testing/baseline/bayesian_gplvm_magnification.png and /dev/null differ diff --git a/GPy/testing/baseline/coverage_3d_plot.npz b/GPy/testing/baseline/coverage_3d_plot.npz new file mode 100644 index 00000000..6372cb73 Binary files /dev/null and b/GPy/testing/baseline/coverage_3d_plot.npz differ diff --git a/GPy/testing/baseline/coverage_3d_plot.png b/GPy/testing/baseline/coverage_3d_plot.png deleted file mode 100644 index 9b0d9d8f..00000000 Binary files a/GPy/testing/baseline/coverage_3d_plot.png and /dev/null differ diff --git a/GPy/testing/baseline/coverage_annotation_interact.npz b/GPy/testing/baseline/coverage_annotation_interact.npz new file mode 100644 index 00000000..16fd4e38 Binary files /dev/null and b/GPy/testing/baseline/coverage_annotation_interact.npz differ diff --git a/GPy/testing/baseline/coverage_annotation_interact.png b/GPy/testing/baseline/coverage_annotation_interact.png deleted file mode 100644 index c5367f34..00000000 Binary files a/GPy/testing/baseline/coverage_annotation_interact.png and /dev/null differ diff --git a/GPy/testing/baseline/coverage_gradient.npz b/GPy/testing/baseline/coverage_gradient.npz new file mode 100644 index 00000000..a55dd97b Binary files /dev/null and b/GPy/testing/baseline/coverage_gradient.npz differ diff --git a/GPy/testing/baseline/coverage_gradient.png b/GPy/testing/baseline/coverage_gradient.png deleted file mode 100644 index 13ee8bf4..00000000 Binary files a/GPy/testing/baseline/coverage_gradient.png and /dev/null differ diff --git a/GPy/testing/baseline/coverage_imshow_interact.npz b/GPy/testing/baseline/coverage_imshow_interact.npz new file mode 100644 index 00000000..55dd013c Binary files /dev/null and b/GPy/testing/baseline/coverage_imshow_interact.npz differ diff --git a/GPy/testing/baseline/coverage_imshow_interact.png b/GPy/testing/baseline/coverage_imshow_interact.png deleted file mode 100644 index b8f52c2f..00000000 Binary files a/GPy/testing/baseline/coverage_imshow_interact.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_2d_data.npz b/GPy/testing/baseline/gp_2d_data.npz new file mode 100644 index 00000000..0c703f69 Binary files /dev/null and b/GPy/testing/baseline/gp_2d_data.npz differ diff --git a/GPy/testing/baseline/gp_2d_data.png b/GPy/testing/baseline/gp_2d_data.png deleted file mode 100644 index b4c04b6c..00000000 Binary files a/GPy/testing/baseline/gp_2d_data.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_2d_in_error.npz b/GPy/testing/baseline/gp_2d_in_error.npz new file mode 100644 index 00000000..beb00720 Binary files /dev/null and b/GPy/testing/baseline/gp_2d_in_error.npz differ diff --git a/GPy/testing/baseline/gp_2d_in_error.png b/GPy/testing/baseline/gp_2d_in_error.png deleted file mode 100644 index 7fed0154..00000000 Binary files a/GPy/testing/baseline/gp_2d_in_error.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_2d_inducing.npz b/GPy/testing/baseline/gp_2d_inducing.npz new file mode 100644 index 00000000..2a249e27 Binary files /dev/null and b/GPy/testing/baseline/gp_2d_inducing.npz differ diff --git a/GPy/testing/baseline/gp_2d_inducing.png b/GPy/testing/baseline/gp_2d_inducing.png deleted file mode 100644 index 970c9132..00000000 Binary files a/GPy/testing/baseline/gp_2d_inducing.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_2d_mean.npz b/GPy/testing/baseline/gp_2d_mean.npz new file mode 100644 index 00000000..dd9ef64d Binary files /dev/null and b/GPy/testing/baseline/gp_2d_mean.npz differ diff --git a/GPy/testing/baseline/gp_2d_mean.png b/GPy/testing/baseline/gp_2d_mean.png deleted file mode 100644 index 3a66f4d7..00000000 Binary files a/GPy/testing/baseline/gp_2d_mean.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_3d_data.npz b/GPy/testing/baseline/gp_3d_data.npz new file mode 100644 index 00000000..e190118a Binary files /dev/null and b/GPy/testing/baseline/gp_3d_data.npz differ diff --git a/GPy/testing/baseline/gp_3d_data.png b/GPy/testing/baseline/gp_3d_data.png deleted file mode 100644 index e3030a88..00000000 Binary files a/GPy/testing/baseline/gp_3d_data.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_3d_inducing.npz b/GPy/testing/baseline/gp_3d_inducing.npz new file mode 100644 index 00000000..b6316363 Binary files /dev/null and b/GPy/testing/baseline/gp_3d_inducing.npz differ diff --git a/GPy/testing/baseline/gp_3d_inducing.png b/GPy/testing/baseline/gp_3d_inducing.png deleted file mode 100644 index 42a87969..00000000 Binary files a/GPy/testing/baseline/gp_3d_inducing.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_3d_mean.npz b/GPy/testing/baseline/gp_3d_mean.npz new file mode 100644 index 00000000..ae0a36ca Binary files /dev/null and b/GPy/testing/baseline/gp_3d_mean.npz differ diff --git a/GPy/testing/baseline/gp_3d_mean.png b/GPy/testing/baseline/gp_3d_mean.png deleted file mode 100644 index fd91fd1d..00000000 Binary files a/GPy/testing/baseline/gp_3d_mean.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_class_likelihood.npz b/GPy/testing/baseline/gp_class_likelihood.npz new file mode 100644 index 00000000..288b15ef Binary files /dev/null and b/GPy/testing/baseline/gp_class_likelihood.npz differ diff --git a/GPy/testing/baseline/gp_class_likelihood.png b/GPy/testing/baseline/gp_class_likelihood.png deleted file mode 100644 index e925b78c..00000000 Binary files a/GPy/testing/baseline/gp_class_likelihood.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_class_raw.npz b/GPy/testing/baseline/gp_class_raw.npz new file mode 100644 index 00000000..08bb56df Binary files /dev/null and b/GPy/testing/baseline/gp_class_raw.npz differ diff --git a/GPy/testing/baseline/gp_class_raw.png b/GPy/testing/baseline/gp_class_raw.png deleted file mode 100644 index ebe62e14..00000000 Binary files a/GPy/testing/baseline/gp_class_raw.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_class_raw_link.npz b/GPy/testing/baseline/gp_class_raw_link.npz new file mode 100644 index 00000000..01490f4c Binary files /dev/null and b/GPy/testing/baseline/gp_class_raw_link.npz differ diff --git a/GPy/testing/baseline/gp_class_raw_link.png b/GPy/testing/baseline/gp_class_raw_link.png deleted file mode 100644 index 307aee26..00000000 Binary files a/GPy/testing/baseline/gp_class_raw_link.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_conf.npz b/GPy/testing/baseline/gp_conf.npz new file mode 100644 index 00000000..3eaf087e Binary files /dev/null and b/GPy/testing/baseline/gp_conf.npz differ diff --git a/GPy/testing/baseline/gp_conf.png b/GPy/testing/baseline/gp_conf.png deleted file mode 100644 index 47491ec4..00000000 Binary files a/GPy/testing/baseline/gp_conf.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_data.npz b/GPy/testing/baseline/gp_data.npz new file mode 100644 index 00000000..2a4606df Binary files /dev/null and b/GPy/testing/baseline/gp_data.npz differ diff --git a/GPy/testing/baseline/gp_data.png b/GPy/testing/baseline/gp_data.png deleted file mode 100644 index 8bede27f..00000000 Binary files a/GPy/testing/baseline/gp_data.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_density.npz b/GPy/testing/baseline/gp_density.npz new file mode 100644 index 00000000..6a3235fa Binary files /dev/null and b/GPy/testing/baseline/gp_density.npz differ diff --git a/GPy/testing/baseline/gp_density.png b/GPy/testing/baseline/gp_density.png deleted file mode 100644 index cf5a28f5..00000000 Binary files a/GPy/testing/baseline/gp_density.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_in_error.npz b/GPy/testing/baseline/gp_in_error.npz new file mode 100644 index 00000000..072fbc12 Binary files /dev/null and b/GPy/testing/baseline/gp_in_error.npz differ diff --git a/GPy/testing/baseline/gp_in_error.png b/GPy/testing/baseline/gp_in_error.png deleted file mode 100644 index e44fa087..00000000 Binary files a/GPy/testing/baseline/gp_in_error.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_mean.npz b/GPy/testing/baseline/gp_mean.npz new file mode 100644 index 00000000..432b2c25 Binary files /dev/null and b/GPy/testing/baseline/gp_mean.npz differ diff --git a/GPy/testing/baseline/gp_mean.png b/GPy/testing/baseline/gp_mean.png deleted file mode 100644 index e955872e..00000000 Binary files a/GPy/testing/baseline/gp_mean.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_out_error.npz b/GPy/testing/baseline/gp_out_error.npz new file mode 100644 index 00000000..4e86a06d Binary files /dev/null and b/GPy/testing/baseline/gp_out_error.npz differ diff --git a/GPy/testing/baseline/gp_out_error.png b/GPy/testing/baseline/gp_out_error.png deleted file mode 100644 index 4ec4ef83..00000000 Binary files a/GPy/testing/baseline/gp_out_error.png and /dev/null differ diff --git a/GPy/testing/baseline/gp_samples.npz b/GPy/testing/baseline/gp_samples.npz new file mode 100644 index 00000000..774a576b Binary files /dev/null and b/GPy/testing/baseline/gp_samples.npz differ diff --git a/GPy/testing/baseline/gp_samples.png b/GPy/testing/baseline/gp_samples.png deleted file mode 100644 index b5a0b90e..00000000 Binary files a/GPy/testing/baseline/gp_samples.png and /dev/null differ diff --git a/GPy/testing/baseline/gplvm_gradient.npz b/GPy/testing/baseline/gplvm_gradient.npz new file mode 100644 index 00000000..fb6a1658 Binary files /dev/null and b/GPy/testing/baseline/gplvm_gradient.npz differ diff --git a/GPy/testing/baseline/gplvm_gradient.png b/GPy/testing/baseline/gplvm_gradient.png deleted file mode 100644 index d21b2777..00000000 Binary files a/GPy/testing/baseline/gplvm_gradient.png and /dev/null differ diff --git a/GPy/testing/baseline/gplvm_latent.npz b/GPy/testing/baseline/gplvm_latent.npz new file mode 100644 index 00000000..fac4cca9 Binary files /dev/null and b/GPy/testing/baseline/gplvm_latent.npz differ diff --git a/GPy/testing/baseline/gplvm_latent.png b/GPy/testing/baseline/gplvm_latent.png deleted file mode 100644 index bdb0c27d..00000000 Binary files a/GPy/testing/baseline/gplvm_latent.png and /dev/null differ diff --git a/GPy/testing/baseline/gplvm_latent_3d.npz b/GPy/testing/baseline/gplvm_latent_3d.npz new file mode 100644 index 00000000..2fe42704 Binary files /dev/null and b/GPy/testing/baseline/gplvm_latent_3d.npz differ diff --git a/GPy/testing/baseline/gplvm_latent_3d.png b/GPy/testing/baseline/gplvm_latent_3d.png deleted file mode 100644 index f2ac36de..00000000 Binary files a/GPy/testing/baseline/gplvm_latent_3d.png and /dev/null differ diff --git a/GPy/testing/baseline/gplvm_magnification.npz b/GPy/testing/baseline/gplvm_magnification.npz new file mode 100644 index 00000000..fb84f382 Binary files /dev/null and b/GPy/testing/baseline/gplvm_magnification.npz differ diff --git a/GPy/testing/baseline/gplvm_magnification.png b/GPy/testing/baseline/gplvm_magnification.png deleted file mode 100644 index 2c430a37..00000000 Binary files a/GPy/testing/baseline/gplvm_magnification.png and /dev/null differ diff --git a/GPy/testing/baseline/kern_ARD.npz b/GPy/testing/baseline/kern_ARD.npz new file mode 100644 index 00000000..7735251e Binary files /dev/null and b/GPy/testing/baseline/kern_ARD.npz differ diff --git a/GPy/testing/baseline/kern_ARD.png b/GPy/testing/baseline/kern_ARD.png deleted file mode 100644 index 26090ed9..00000000 Binary files a/GPy/testing/baseline/kern_ARD.png and /dev/null differ diff --git a/GPy/testing/baseline/kern_cov_1d.npz b/GPy/testing/baseline/kern_cov_1d.npz new file mode 100644 index 00000000..3bb0ac83 Binary files /dev/null and b/GPy/testing/baseline/kern_cov_1d.npz differ diff --git a/GPy/testing/baseline/kern_cov_1d.png b/GPy/testing/baseline/kern_cov_1d.png deleted file mode 100644 index 6ab80ec6..00000000 Binary files a/GPy/testing/baseline/kern_cov_1d.png and /dev/null differ diff --git a/GPy/testing/baseline/kern_cov_2d.npz b/GPy/testing/baseline/kern_cov_2d.npz new file mode 100644 index 00000000..78a5930b Binary files /dev/null and b/GPy/testing/baseline/kern_cov_2d.npz differ diff --git a/GPy/testing/baseline/kern_cov_2d.png b/GPy/testing/baseline/kern_cov_2d.png deleted file mode 100644 index 89eb6ea7..00000000 Binary files a/GPy/testing/baseline/kern_cov_2d.png and /dev/null differ diff --git a/GPy/testing/baseline/kern_cov_3d.npz b/GPy/testing/baseline/kern_cov_3d.npz new file mode 100644 index 00000000..a76f302f Binary files /dev/null and b/GPy/testing/baseline/kern_cov_3d.npz differ diff --git a/GPy/testing/baseline/kern_cov_3d.png b/GPy/testing/baseline/kern_cov_3d.png deleted file mode 100644 index e536dd0c..00000000 Binary files a/GPy/testing/baseline/kern_cov_3d.png and /dev/null differ diff --git a/GPy/testing/baseline/kern_cov_no_lim.npz b/GPy/testing/baseline/kern_cov_no_lim.npz new file mode 100644 index 00000000..019db745 Binary files /dev/null and b/GPy/testing/baseline/kern_cov_no_lim.npz differ diff --git a/GPy/testing/baseline/kern_cov_no_lim.png b/GPy/testing/baseline/kern_cov_no_lim.png deleted file mode 100644 index 686c8724..00000000 Binary files a/GPy/testing/baseline/kern_cov_no_lim.png and /dev/null differ diff --git a/GPy/testing/baseline/sparse_gp_class_likelihood.npz b/GPy/testing/baseline/sparse_gp_class_likelihood.npz new file mode 100644 index 00000000..64eb8299 Binary files /dev/null and b/GPy/testing/baseline/sparse_gp_class_likelihood.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_likelihood.png b/GPy/testing/baseline/sparse_gp_class_likelihood.png deleted file mode 100644 index fb212db4..00000000 Binary files a/GPy/testing/baseline/sparse_gp_class_likelihood.png and /dev/null differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw.npz b/GPy/testing/baseline/sparse_gp_class_raw.npz new file mode 100644 index 00000000..c3876b70 Binary files /dev/null and b/GPy/testing/baseline/sparse_gp_class_raw.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw.png b/GPy/testing/baseline/sparse_gp_class_raw.png deleted file mode 100644 index 6e9cda9c..00000000 Binary files a/GPy/testing/baseline/sparse_gp_class_raw.png and /dev/null differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw_link.npz b/GPy/testing/baseline/sparse_gp_class_raw_link.npz new file mode 100644 index 00000000..957003e9 Binary files /dev/null and b/GPy/testing/baseline/sparse_gp_class_raw_link.npz differ diff --git a/GPy/testing/baseline/sparse_gp_class_raw_link.png b/GPy/testing/baseline/sparse_gp_class_raw_link.png deleted file mode 100644 index 3db9362f..00000000 Binary files a/GPy/testing/baseline/sparse_gp_class_raw_link.png and /dev/null differ diff --git a/GPy/testing/baseline/sparse_gp_data_error.npz b/GPy/testing/baseline/sparse_gp_data_error.npz new file mode 100644 index 00000000..04a05f55 Binary files /dev/null and b/GPy/testing/baseline/sparse_gp_data_error.npz differ diff --git a/GPy/testing/baseline/sparse_gp_data_error.png b/GPy/testing/baseline/sparse_gp_data_error.png deleted file mode 100644 index 2d253bb8..00000000 Binary files a/GPy/testing/baseline/sparse_gp_data_error.png and /dev/null differ diff --git a/GPy/testing/gp_tests.py b/GPy/testing/gp_tests.py index 3ce3ffc4..97e3718d 100644 --- a/GPy/testing/gp_tests.py +++ b/GPy/testing/gp_tests.py @@ -24,9 +24,9 @@ class Test(unittest.TestCase): k = GPy.kern.RBF(1) m = GPy.models.BayesianGPLVM(self.Y, 1, kernel=k) mu, var = m.predict(m.X) - X = m.X.copy() + X = m.X Xnew = NormalPosterior(m.X.mean[:10].copy(), m.X.variance[:10].copy()) - m.set_XY(Xnew, m.Y[:10]) + m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) @@ -40,7 +40,7 @@ class Test(unittest.TestCase): mu, var = m.predict(m.X) X = m.X.copy() Xnew = X[:10].copy() - m.set_XY(Xnew, m.Y[:10]) + m.set_XY(Xnew, m.Y[:10].copy()) assert(m.checkgrad()) m.set_XY(X, self.Y) mu2, var2 = m.predict(m.X) diff --git a/GPy/testing/gpy_kernels_state_space_tests.py b/GPy/testing/gpy_kernels_state_space_tests.py new file mode 100644 index 00000000..f39eb9d0 --- /dev/null +++ b/GPy/testing/gpy_kernels_state_space_tests.py @@ -0,0 +1,391 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Testing state space related functions. +""" +import unittest +import numpy as np +import GPy +import GPy.models.state_space_model as SS_model +from .state_space_main_tests import generate_x_points, generate_sine_data, \ + generate_linear_data, generate_brownian_data, generate_linear_plus_sin +from nose import SkipTest + +#from state_space_main_tests import generate_x_points, generate_sine_data, \ +# generate_linear_data, generate_brownian_data, generate_linear_plus_sin + +class StateSpaceKernelsTests(np.testing.TestCase): + def setUp(self): + pass + + def run_for_model(self, X, Y, ss_kernel, kalman_filter_type = 'regular', + use_cython=False, check_gradients=True, + optimize=True, optimize_max_iters=250, predict_X=None, + compare_with_GP=True, gp_kernel=None, + mean_compare_decimal=10, var_compare_decimal=7): + + m1 = SS_model.StateSpace(X,Y, ss_kernel, + kalman_filter_type=kalman_filter_type, + use_cython=use_cython) + + m1.likelihood[:] = Y.var()/100. + + if check_gradients: + self.assertTrue(m1.checkgrad()) + + if 1:#optimize: + m1.optimize(optimizer='lbfgsb', max_iters=1) + + if compare_with_GP and (predict_X is None): + predict_X = X + + self.assertTrue(compare_with_GP) + if compare_with_GP: + m2 = GPy.models.GPRegression(X,Y, gp_kernel) + + m2[:] = m1[:] + + if (predict_X is not None): + x_pred_reg_1 = m1.predict(predict_X) + x_quant_reg_1 = m1.predict_quantiles(predict_X) + + x_pred_reg_2 = m2.predict(predict_X) + x_quant_reg_2 = m2.predict_quantiles(predict_X) + + np.testing.assert_array_almost_equal(x_pred_reg_1[0], x_pred_reg_2[0], mean_compare_decimal) + np.testing.assert_array_almost_equal(x_pred_reg_1[1], x_pred_reg_2[1], var_compare_decimal) + np.testing.assert_array_almost_equal(x_quant_reg_1[0], x_quant_reg_2[0], mean_compare_decimal) + np.testing.assert_array_almost_equal(x_quant_reg_1[1], x_quant_reg_2[1], mean_compare_decimal) + np.testing.assert_array_almost_equal(m1.gradient, m2.gradient, var_compare_decimal) + np.testing.assert_almost_equal(m1.log_likelihood(), m2.log_likelihood(), var_compare_decimal) + + + def test_Matern32_kernel(self,): + np.random.seed(234) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Matern32(1,active_dims=[0,]) + gp_kernel = GPy.kern.Matern32(1,active_dims=[0,]) + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + compare_with_GP=True, + gp_kernel=gp_kernel, + mean_compare_decimal=5, var_compare_decimal=5) + + def test_Matern52_kernel(self,): + np.random.seed(234) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Matern52(1,active_dims=[0,]) + gp_kernel = GPy.kern.Matern52(1,active_dims=[0,]) + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + optimize = True, predict_X=X, + compare_with_GP=True, gp_kernel=gp_kernel, + mean_compare_decimal=5, var_compare_decimal=5) + + def test_RBF_kernel(self,): + np.random.seed(234) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_RBF(1, 110., 1.5, active_dims=[0,]) + gp_kernel = GPy.kern.RBF(1, 110., 1.5, active_dims=[0,]) + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + optimize_max_iters=1000, + mean_compare_decimal=2, var_compare_decimal=1) + + def test_periodic_kernel(self,): + np.random.seed(322) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + ss_kernel.lengthscale.constrain_bounded(0.27, 1000) + ss_kernel.period.constrain_bounded(0.17, 100) + + gp_kernel = GPy.kern.StdPeriodic(1,active_dims=[0,]) + gp_kernel.lengthscale.constrain_bounded(0.27, 1000) + gp_kernel.period.constrain_bounded(0.17, 100) + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=3, var_compare_decimal=3) + + def test_quasi_periodic_kernel(self,): + np.random.seed(329) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Matern32(1)*GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + ss_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + ss_kernel.std_periodic.period.constrain_bounded(0.15, 100) + + gp_kernel = GPy.kern.Matern32(1)*GPy.kern.StdPeriodic(1,active_dims=[0,]) + gp_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + gp_kernel.std_periodic.period.constrain_bounded(0.15, 100) + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=1, var_compare_decimal=2) + + def test_linear_kernel(self,): + + np.random.seed(234) # seed the random number generator + (X,Y) = generate_linear_data(x_points=None, tangent=2.0, add_term=20.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Linear(1,X,active_dims=[0,]) + GPy.kern.sde_Bias(1, active_dims=[0,]) + gp_kernel = GPy.kern.Linear(1, active_dims=[0,]) + GPy.kern.Bias(1, active_dims=[0,]) + + self.run_for_model(X, Y, ss_kernel, check_gradients= False, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=5, var_compare_decimal=5) + + def test_brownian_kernel(self,): + np.random.seed(234) # seed the random number generator + (X,Y) = generate_brownian_data(x_points=None, kernel_var=2.0, noise_var = 0.1, + plot = False, points_num=50, x_interval = (0, 20), random=True) + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Brownian() + gp_kernel = GPy.kern.Brownian() + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=4, var_compare_decimal=4) + + def test_exponential_kernel(self,): + np.random.seed(12345) # seed the random number generator + (X,Y) = generate_linear_data(x_points=None, tangent=1.0, add_term=20.0, noise_var=2.0, + plot = False, points_num=10, x_interval = (0, 20), random=True) + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + ss_kernel = GPy.kern.sde_Exponential(1, Y.var(), X.ptp()/2., active_dims=[0,]) + gp_kernel = GPy.kern.Exponential(1, Y.var(), X.ptp()/2., active_dims=[0,]) + + Y -= Y.mean() + + self.run_for_model(X, Y, ss_kernel, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + optimize_max_iters=1000, + mean_compare_decimal=2, var_compare_decimal=2) + + def test_kernel_addition_svd(self,): + #np.random.seed(329) # seed the random number generator + np.random.seed(42) + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=5.0, noise_var=2.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + (X1,Y1) = generate_linear_data(x_points=X, tangent=1.0, add_term=20.0, noise_var=0.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + # Sine data <- + Y = Y + Y1 + Y -= Y.mean() + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + def get_new_kernels(): + ss_kernel = GPy.kern.sde_Linear(1, X, variances=1) + GPy.kern.sde_StdPeriodic(1, period=5.0, variance=300, lengthscale=3, active_dims=[0,]) + #ss_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + #ss_kernel.std_periodic.period.constrain_bounded(3, 8) + + gp_kernel = GPy.kern.Linear(1, variances=1) + GPy.kern.StdPeriodic(1, period=5.0, variance=300, lengthscale=3, active_dims=[0,]) + #gp_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + #gp_kernel.std_periodic.period.constrain_bounded(3, 8) + + return ss_kernel, gp_kernel + + # Cython is available only with svd. + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'svd', + use_cython=True, optimize_max_iters=10, check_gradients=False, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=3, var_compare_decimal=3) + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'svd', + use_cython=False, optimize_max_iters=10, check_gradients=False, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=3, var_compare_decimal=3) + + def test_kernel_addition_regular(self,): + #np.random.seed(329) # seed the random number generator + np.random.seed(42) + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=5.0, noise_var=2.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + (X1,Y1) = generate_linear_data(x_points=X, tangent=1.0, add_term=20.0, noise_var=0.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + # Sine data <- + Y = Y + Y1 + Y -= Y.mean() + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + def get_new_kernels(): + ss_kernel = GPy.kern.sde_Linear(1, X, variances=1) + GPy.kern.sde_StdPeriodic(1, period=5.0, variance=300, lengthscale=3, active_dims=[0,]) + #ss_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + #ss_kernel.std_periodic.period.constrain_bounded(3, 8) + + gp_kernel = GPy.kern.Linear(1, variances=1) + GPy.kern.StdPeriodic(1, period=5.0, variance=300, lengthscale=3, active_dims=[0,]) + #gp_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + #gp_kernel.std_periodic.period.constrain_bounded(3, 8) + + return ss_kernel, gp_kernel + + ss_kernel, gp_kernel = get_new_kernels() + try: + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'regular', + use_cython=False, optimize_max_iters=10, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + except AssertionError: + raise SkipTest("Skipping Regular kalman filter for kernel addition, as it seems to be bugged for some python versions") + + + def test_kernel_multiplication(self,): + np.random.seed(329) # seed the random number generator + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=50, x_interval = (0, 20), random=True) + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + + def get_new_kernels(): + ss_kernel = GPy.kern.sde_Matern32(1)*GPy.kern.sde_Matern52(1) + gp_kernel = GPy.kern.Matern32(1)*GPy.kern.sde_Matern52(1) + + return ss_kernel, gp_kernel + + ss_kernel, gp_kernel = get_new_kernels() + + #import ipdb;ipdb.set_trace() + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'svd', + use_cython=True, optimize_max_iters=10, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'regular', + use_cython=False, optimize_max_iters=10, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X, Y, ss_kernel, kalman_filter_type = 'svd', + use_cython=False, optimize_max_iters=10, check_gradients=True, + predict_X=X, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + + def test_forecast(self,): + """ + Test time-series forecasting. + """ + + # Generate data -> + np.random.seed(339) # seed the random number generator + #import pdb; pdb.set_trace() + (X,Y) = generate_sine_data(x_points=None, sin_period=5.0, sin_ampl=5.0, noise_var=2.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + (X1,Y1) = generate_linear_data(x_points=X, tangent=1.0, add_term=20.0, noise_var=0.0, + plot = False, points_num=100, x_interval = (0, 40), random=True) + + Y = Y + Y1 + + X_train = X[X <= 20] + Y_train = Y[X <= 20] + X_test = X[X > 20] + Y_test = Y[X > 20] + + X.shape = (X.shape[0],1); Y.shape = (Y.shape[0],1) + X_train.shape = (X_train.shape[0],1); Y_train.shape = (Y_train.shape[0],1) + X_test.shape = (X_test.shape[0],1); Y_test.shape = (Y_test.shape[0],1) + # Generate data <- + + #import pdb; pdb.set_trace() + + def get_new_kernels(): + periodic_kernel = GPy.kern.StdPeriodic(1,active_dims=[0,]) + gp_kernel = GPy.kern.Linear(1, active_dims=[0,]) + GPy.kern.Bias(1, active_dims=[0,]) + periodic_kernel + gp_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + gp_kernel.std_periodic.period.constrain_bounded(0.15, 100) + + periodic_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + ss_kernel = GPy.kern.sde_Linear(1,X,active_dims=[0,]) + \ + GPy.kern.sde_Bias(1, active_dims=[0,]) + periodic_kernel + + ss_kernel.std_periodic.lengthscale.constrain_bounded(0.25, 1000) + ss_kernel.std_periodic.period.constrain_bounded(0.15, 100) + + return ss_kernel, gp_kernel + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X_train, Y_train, ss_kernel, kalman_filter_type = 'regular', + use_cython=False, optimize_max_iters=30, check_gradients=True, + predict_X=X_test, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X_train, Y_train, ss_kernel, kalman_filter_type = 'svd', + use_cython=False, optimize_max_iters=30, check_gradients=False, + predict_X=X_test, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + + ss_kernel, gp_kernel = get_new_kernels() + self.run_for_model(X_train, Y_train, ss_kernel, kalman_filter_type = 'svd', + use_cython=True, optimize_max_iters=30, check_gradients=False, + predict_X=X_test, + gp_kernel=gp_kernel, + mean_compare_decimal=2, var_compare_decimal=2) + +if __name__ == "__main__": + print("Running state-space inference tests...") + unittest.main() + + #tt = StateSpaceKernelsTests('test_periodic_kernel') + #import pdb; pdb.set_trace() + #tt.test_Matern32_kernel() + #tt.test_Matern52_kernel() + #tt.test_RBF_kernel() + #tt.test_periodic_kernel() + #tt.test_quasi_periodic_kernel() + #tt.test_linear_kernel() + #tt.test_brownian_kernel() + #tt.test_exponential_kernel() + #tt.test_kernel_addition() + #tt.test_kernel_multiplication() + #tt.test_forecast() + diff --git a/GPy/testing/kernel_tests.py b/GPy/testing/kernel_tests.py index 57805eef..5babeb41 100644 --- a/GPy/testing/kernel_tests.py +++ b/GPy/testing/kernel_tests.py @@ -2,11 +2,15 @@ # Licensed under the BSD 3-clause license (see LICENSE.txt) import unittest -import numpy as np +from unittest.case import skip + import GPy from GPy.core.parameterization.param import Param +import numpy as np + from ..util.config import config + verbose = 0 try: @@ -100,7 +104,45 @@ class Kern_check_dKdiag_dX(Kern_check_dK_dX): def parameters_changed(self): self.X.gradient[:] = self.kernel.gradients_X_diag(self.dL_dK.diagonal(), self.X) +class Kern_check_d2K_dXdX(Kern_check_model): + """This class allows gradient checks for the secondderivative of a kernel with respect to X. """ + def __init__(self, kernel=None, dL_dK=None, X=None, X2=None): + Kern_check_model.__init__(self,kernel=kernel,dL_dK=dL_dK, X=X, X2=X2) + self.X = Param('X',X.copy()) + self.link_parameter(self.X) + self.Xc = X.copy() + def log_likelihood(self): + if self.X2 is None: + return self.kernel.gradients_X(self.dL_dK, self.X, self.Xc).sum() + return self.kernel.gradients_X(self.dL_dK, self.X, self.X2).sum() + + def parameters_changed(self): + #if self.kernel.name == 'rbf': + # import ipdb;ipdb.set_trace() + if self.X2 is None: + grads = -self.kernel.gradients_XX(self.dL_dK, self.X).sum(1).sum(1) + else: + grads = -self.kernel.gradients_XX(self.dL_dK.T, self.X2, self.X).sum(0).sum(1) + self.X.gradient[:] = grads + +class Kern_check_d2Kdiag_dXdX(Kern_check_model): + """This class allows gradient checks for the second derivative of a kernel with respect to X. """ + def __init__(self, kernel=None, dL_dK=None, X=None): + Kern_check_model.__init__(self,kernel=kernel,dL_dK=dL_dK, X=X) + self.X = Param('X',X) + self.link_parameter(self.X) + self.Xc = X.copy() + + def log_likelihood(self): + l = 0. + for i in range(self.X.shape[0]): + l += self.kernel.gradients_X(self.dL_dK[[i],[i]], self.X[[i]], self.Xc[[i]]).sum() + return l + + def parameters_changed(self): + grads = -self.kernel.gradients_XX_diag(self.dL_dK.diagonal(), self.X) + self.X.gradient[:] = grads.sum(-1) def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verbose=False, fixed_X_dims=None): """ @@ -151,7 +193,12 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb if verbose: print("Checking gradients of K(X, X2) wrt theta.") - result = Kern_check_dK_dtheta(kern, X=X, X2=X2).checkgrad(verbose=verbose) + try: + result = Kern_check_dK_dtheta(kern, X=X, X2=X2).checkgrad(verbose=verbose) + except NotImplementedError: + result=True + if verbose: + print(("update_gradients_full, with differing X and X2, not implemented for " + kern.name)) if result and verbose: print("Check passed.") if not result: @@ -238,6 +285,66 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb assert(result) return False + if verbose: + print("Checking gradients of dK(X, X2) wrt X2 with full cov in dimensions") + try: + testmodel = Kern_check_d2K_dXdX(kern, X=X, X2=X2) + if fixed_X_dims is not None: + testmodel.X[:,fixed_X_dims].fix() + result = testmodel.checkgrad(verbose=verbose) + except NotImplementedError: + result=True + if verbose: + print(("gradients_X not implemented for " + kern.name)) + if result and verbose: + print("Check passed.") + if not result: + print(("Gradient of dK(X, X2) wrt X failed for " + kern.name + " covariance function. Gradient values as follows:")) + testmodel.checkgrad(verbose=True) + assert(result) + pass_checks = False + return False + + if verbose: + print("Checking gradients of dK(X, X) wrt X with full cov in dimensions") + try: + testmodel = Kern_check_d2K_dXdX(kern, X=X, X2=None) + if fixed_X_dims is not None: + testmodel.X[:,fixed_X_dims].fix() + result = testmodel.checkgrad(verbose=verbose) + except NotImplementedError: + result=True + if verbose: + print(("gradients_X not implemented for " + kern.name)) + if result and verbose: + print("Check passed.") + if not result: + print(("Gradient of dK(X, X) wrt X with full cov in dimensions failed for " + kern.name + " covariance function. Gradient values as follows:")) + testmodel.checkgrad(verbose=True) + assert(result) + pass_checks = False + return False + + if verbose: + print("Checking gradients of dKdiag(X, X) wrt X with cov in dimensions") + try: + testmodel = Kern_check_d2Kdiag_dXdX(kern, X=X) + if fixed_X_dims is not None: + testmodel.X[:,fixed_X_dims].fix() + result = testmodel.checkgrad(verbose=verbose) + except NotImplementedError: + result=True + if verbose: + print(("gradients_X not implemented for " + kern.name)) + if result and verbose: + print("Check passed.") + if not result: + print(("Gradient of dKdiag(X, X) wrt X with cov in dimensions failed for " + kern.name + " covariance function. Gradient values as follows:")) + testmodel.checkgrad(verbose=True) + assert(result) + pass_checks = False + return False + return pass_checks @@ -245,8 +352,8 @@ def check_kernel_gradient_functions(kern, X=None, X2=None, output_ind=None, verb class KernelGradientTestsContinuous(unittest.TestCase): def setUp(self): self.N, self.D = 10, 5 - self.X = np.random.randn(self.N,self.D) - self.X2 = np.random.randn(self.N+10,self.D) + self.X = np.random.randn(self.N,self.D+1) + self.X2 = np.random.randn(self.N+10,self.D+1) continuous_kerns = ['RBF', 'Linear'] self.kernclasses = [getattr(GPy.kern, s) for s in continuous_kerns] @@ -295,7 +402,7 @@ class KernelGradientTestsContinuous(unittest.TestCase): def test_Add_dims(self): k = GPy.kern.Matern32(2, active_dims=[2,self.D]) + GPy.kern.RBF(2, active_dims=[0,4]) + GPy.kern.Linear(self.D) k.randomize() - self.assertRaises(IndexError, k.K, self.X) + self.assertRaises(IndexError, k.K, self.X[:, :self.D]) k = GPy.kern.Matern32(2, active_dims=[2,self.D-1]) + GPy.kern.RBF(2, active_dims=[0,4]) + GPy.kern.Linear(self.D) k.randomize() # assert it runs: @@ -310,7 +417,22 @@ class KernelGradientTestsContinuous(unittest.TestCase): self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) def test_RBF(self): - k = GPy.kern.RBF(self.D, ARD=True) + k = GPy.kern.RBF(self.D-1, ARD=True) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + + def test_integral(self): + k = GPy.kern.Integral(1) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + + def test_multidimensional_integral_limits(self): + k = GPy.kern.Multidimensional_Integral_Limits(2) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + + def test_integral_limits(self): + k = GPy.kern.Integral_Limits(2) k.randomize() self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) @@ -324,6 +446,13 @@ class KernelGradientTestsContinuous(unittest.TestCase): k.randomize() self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + def test_Fixed(self): + cov = np.dot(self.X, self.X.T) + X = np.arange(self.N).reshape(self.N, 1) + k = GPy.kern.Fixed(1, cov) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=X, X2=None, verbose=verbose)) + def test_Poly(self): k = GPy.kern.Poly(self.D, order=5) k.randomize() @@ -339,6 +468,43 @@ class KernelGradientTestsContinuous(unittest.TestCase): k.randomize() self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + def test_Precomputed(self): + Xall = np.concatenate([self.X, self.X2]) + cov = np.dot(Xall, Xall.T) + X = np.arange(self.N).reshape(self.N, 1) + X2 = np.arange(self.N,2*self.N+10).reshape(self.N+10, 1) + k = GPy.kern.Precomputed(1, cov) + k.randomize() + self.assertTrue(check_kernel_gradient_functions(k, X=X, X2=X2, verbose=verbose, fixed_X_dims=[0])) + + def test_basis_func_linear_slope(self): + start_stop = np.random.uniform(self.X.min(0), self.X.max(0), (4, self.X.shape[1])).T + start_stop.sort(axis=1) + ks = [] + for i in range(start_stop.shape[0]): + start, stop = np.split(start_stop[i], 2) + ks.append(GPy.kern.LinearSlopeBasisFuncKernel(1, start, stop, ARD=i%2==0, active_dims=[i])) + k = GPy.kern.Add(ks) + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + + def test_basis_func_changepoint(self): + points = np.random.uniform(self.X.min(0), self.X.max(0), (self.X.shape[1])) + ks = [] + for i in range(points.shape[0]): + ks.append(GPy.kern.ChangePointBasisFuncKernel(1, points[i], ARD=i%2==0, active_dims=[i])) + k = GPy.kern.Add(ks) + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + + def test_basis_func_domain(self): + start_stop = np.random.uniform(self.X.min(0), self.X.max(0), (4, self.X.shape[1])).T + start_stop.sort(axis=1) + ks = [] + for i in range(start_stop.shape[0]): + start, stop = np.split(start_stop[i], 2) + ks.append(GPy.kern.DomainKernel(1, start, stop, ARD=i%2==0, active_dims=[i])) + k = GPy.kern.Add(ks) + self.assertTrue(check_kernel_gradient_functions(k, X=self.X, X2=self.X2, verbose=verbose)) + class KernelTestsMiscellaneous(unittest.TestCase): def setUp(self): N, D = 100, 10 @@ -394,8 +560,13 @@ class KernelTestsNonContinuous(unittest.TestCase): self.X2[:(N0*2), -1] = 0 self.X2[(N0*2):, -1] = 1 - @unittest.expectedFailure def test_IndependentOutputs(self): + k = [GPy.kern.RBF(1, active_dims=[1], name='rbf1'), GPy.kern.RBF(self.D, active_dims=range(self.D), name='rbf012'), GPy.kern.RBF(2, active_dims=[0,2], name='rbf02')] + kern = GPy.kern.IndependentOutputs(k, -1, name='ind_split') + np.testing.assert_array_equal(kern.active_dims, [-1,0,1,2]) + np.testing.assert_array_equal(kern._all_dims_active, [0,1,2,-1]) + + def testIndependendGradients(self): k = GPy.kern.RBF(self.D, active_dims=range(self.D)) kern = GPy.kern.IndependentOutputs(k, -1, 'ind_single') self.assertTrue(check_kernel_gradient_functions(kern, X=self.X, X2=self.X2, verbose=verbose, fixed_X_dims=-1)) @@ -403,8 +574,13 @@ class KernelTestsNonContinuous(unittest.TestCase): kern = GPy.kern.IndependentOutputs(k, -1, name='ind_split') self.assertTrue(check_kernel_gradient_functions(kern, X=self.X, X2=self.X2, verbose=verbose, fixed_X_dims=-1)) - @unittest.expectedFailure def test_Hierarchical(self): + k = [GPy.kern.RBF(2, active_dims=[0,2], name='rbf1'), GPy.kern.RBF(2, active_dims=[0,2], name='rbf2')] + kern = GPy.kern.IndependentOutputs(k, -1, name='ind_split') + np.testing.assert_array_equal(kern.active_dims, [-1,0,2]) + np.testing.assert_array_equal(kern._all_dims_active, [0,1,2,-1]) + + def test_Hierarchical_gradients(self): k = [GPy.kern.RBF(2, active_dims=[0,2], name='rbf1'), GPy.kern.RBF(2, active_dims=[0,2], name='rbf2')] kern = GPy.kern.IndependentOutputs(k, -1, name='ind_split') self.assertTrue(check_kernel_gradient_functions(kern, X=self.X, X2=self.X2, verbose=verbose, fixed_X_dims=-1)) @@ -416,6 +592,10 @@ class KernelTestsNonContinuous(unittest.TestCase): X2 = self.X2[self.X2[:,-1]!=2] self.assertTrue(check_kernel_gradient_functions(kern, X=X, X2=X2, verbose=verbose, fixed_X_dims=-1)) + def test_Coregionalize(self): + kern = GPy.kern.Coregionalize(1, output_dim=3, active_dims=[-1]) + self.assertTrue(check_kernel_gradient_functions(kern, X=self.X, X2=self.X2, verbose=verbose, fixed_X_dims=-1)) + @unittest.skipIf(not config.getboolean('cython', 'working'),"Cython modules have not been built on this machine") class Coregionalize_cython_test(unittest.TestCase): """ diff --git a/GPy/testing/meanfunc_tests.py b/GPy/testing/meanfunc_tests.py index 815c024f..53482a7a 100644 --- a/GPy/testing/meanfunc_tests.py +++ b/GPy/testing/meanfunc_tests.py @@ -28,10 +28,49 @@ class MFtests(unittest.TestCase): A linear mean function with parameters that we'll learn alongside the kernel """ + X = np.linspace(-1,10,50).reshape(-1,1) + + Y = 3-np.abs((X-6)) + Y += .5*np.cos(3*X) + 0.3*np.random.randn(*X.shape) + + mf = GPy.mappings.PiecewiseLinear(1, 1, [-1,1], [9,2]) + + k =GPy.kern.RBF(1) + lik = GPy.likelihoods.Gaussian() + m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf) + self.assertTrue(m.checkgrad()) + + def test_parametric_mean_function_composition(self): + """ + A linear mean function with parameters that we'll learn alongside the kernel + """ + X = np.linspace(0,10,50).reshape(-1,1) Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X - mf = GPy.mappings.Linear(1,1) + mf = GPy.mappings.Compound(GPy.mappings.Linear(1,1), + GPy.mappings.Kernel(1, 1, np.random.normal(0,1,(1,1)), + GPy.kern.RBF(1)) + ) + + k =GPy.kern.RBF(1) + lik = GPy.likelihoods.Gaussian() + m = GPy.core.GP(X, Y, kernel=k, likelihood=lik, mean_function=mf) + self.assertTrue(m.checkgrad()) + + def test_parametric_mean_function_additive(self): + """ + A linear mean function with parameters that we'll learn alongside the kernel + """ + + X = np.linspace(0,10,50).reshape(-1,1) + Y = np.sin(X) + 0.5*np.cos(3*X) + 0.1*np.random.randn(*X.shape) + 3*X + + mf = GPy.mappings.Additive(GPy.mappings.Constant(1,1,3), + GPy.mappings.Additive(GPy.mappings.MLP(1,1), + GPy.mappings.Identity(1,1) + ) + ) k =GPy.kern.RBF(1) lik = GPy.likelihoods.Gaussian() diff --git a/GPy/testing/minibatch_tests.py b/GPy/testing/minibatch_tests.py index fbf12939..09bcc1dc 100644 --- a/GPy/testing/minibatch_tests.py +++ b/GPy/testing/minibatch_tests.py @@ -127,28 +127,32 @@ class SparseGPMinibatchTest(unittest.TestCase): def test_sparsegp_init(self): # Test if the different implementations give the exact same likelihood as the full model. # All of the following settings should give the same likelihood and gradients as the full model: - np.random.seed(1234) - Z = self.X[np.random.choice(self.X.shape[0], replace=False, size=10)].copy() - Q = Z.shape[1] - m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=True, stochastic=False) - assert(m.checkgrad()) - m.optimize('adadelta', max_iters=10) - assert(m.checkgrad()) - - m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=True, stochastic=True) - assert(m.checkgrad()) - m.optimize('rprop', max_iters=10) - assert(m.checkgrad()) - - m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=False, stochastic=False) - assert(m.checkgrad()) - m.optimize('rprop', max_iters=10) - assert(m.checkgrad()) - - m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=False, stochastic=True) - assert(m.checkgrad()) - m.optimize('adadelta', max_iters=10) - assert(m.checkgrad()) + try: + np.random.seed(1234) + Z = self.X[np.random.choice(self.X.shape[0], replace=False, size=10)].copy() + Q = Z.shape[1] + m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=True, stochastic=False) + assert(m.checkgrad()) + m.optimize('adadelta', max_iters=10) + assert(m.checkgrad()) + + m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=True, stochastic=True) + assert(m.checkgrad()) + m.optimize('rprop', max_iters=10) + assert(m.checkgrad()) + + m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=False, stochastic=False) + assert(m.checkgrad()) + m.optimize('rprop', max_iters=10) + assert(m.checkgrad()) + + m = GPy.models.sparse_gp_minibatch.SparseGPMiniBatch(self.X, self.Y, Z, GPy.kern.RBF(Q)+GPy.kern.Matern32(Q)+GPy.kern.Bias(Q), GPy.likelihoods.Gaussian(), missing_data=False, stochastic=True) + assert(m.checkgrad()) + m.optimize('adadelta', max_iters=10) + assert(m.checkgrad()) + except ImportError: + from nose import SkipTest + raise SkipTest('climin not installed, skipping stochastic gradients') def test_predict_missing_data(self): m = GPy.models.bayesian_gplvm_minibatch.BayesianGPLVMMiniBatch(self.Y, self.Q, X_variance=False, missing_data=True, stochastic=True, batchsize=self.Y.shape[1]) diff --git a/GPy/testing/model_tests.py b/GPy/testing/model_tests.py index 59a086cd..c0098ef9 100644 --- a/GPy/testing/model_tests.py +++ b/GPy/testing/model_tests.py @@ -27,7 +27,7 @@ class MiscTests(unittest.TestCase): Test whether the predicted variance of normal GP goes negative under numerical unstable situation. Thanks simbartonels@github for reporting the bug and providing the following example. """ - + # set seed for reproducability np.random.seed(3) # Definition of the Branin test function @@ -69,13 +69,13 @@ class MiscTests(unittest.TestCase): K_hat = k.K(self.X_new) - k.K(self.X_new, self.X).dot(Kinv).dot(k.K(self.X, self.X_new)) mu_hat = k.K(self.X_new, self.X).dot(Kinv).dot(m.Y_normalized) - mu, covar = m._raw_predict(self.X_new, full_cov=True) + mu, covar = m.predict_noiseless(self.X_new, full_cov=True) self.assertEquals(mu.shape, (self.N_new, self.D)) self.assertEquals(covar.shape, (self.N_new, self.N_new)) np.testing.assert_almost_equal(K_hat, covar) np.testing.assert_almost_equal(mu_hat, mu) - mu, var = m._raw_predict(self.X_new) + mu, var = m.predict_noiseless(self.X_new) self.assertEquals(mu.shape, (self.N_new, self.D)) self.assertEquals(var.shape, (self.N_new, 1)) np.testing.assert_almost_equal(np.diag(K_hat)[:, None], var) @@ -91,19 +91,33 @@ class MiscTests(unittest.TestCase): k = GPy.kern.RBF(1) m2 = GPy.models.GPRegression(self.X, (Y-mu)/std, kernel=k, normalizer=False) m2[:] = m[:] + mu1, var1 = m.predict(m.X, full_cov=True) mu2, var2 = m2.predict(m2.X, full_cov=True) np.testing.assert_allclose(mu1, (mu2*std)+mu) - np.testing.assert_allclose(var1, var2) + np.testing.assert_allclose(var1, var2*std**2) + mu1, var1 = m.predict(m.X, full_cov=False) mu2, var2 = m2.predict(m2.X, full_cov=False) + np.testing.assert_allclose(mu1, (mu2*std)+mu) - np.testing.assert_allclose(var1, var2) + np.testing.assert_allclose(var1, var2*std**2) q50n = m.predict_quantiles(m.X, (50,)) q50 = m2.predict_quantiles(m2.X, (50,)) + np.testing.assert_allclose(q50n[0], (q50[0]*std)+mu) + # Test variance component: + qs = np.array([2.5, 97.5]) + # The quantiles get computed before unormalization + # And transformed using the mean transformation: + c = np.random.choice(self.X.shape[0]) + q95 = m2.predict_quantiles(self.X[[c]], qs) + mu, var = m2.predict(self.X[[c]]) + from scipy.stats import norm + np.testing.assert_allclose((mu+(norm.ppf(qs/100.)*np.sqrt(var))).flatten(), np.array(q95).flatten()) + def check_jacobian(self): try: import autograd.numpy as np, autograd as ag, GPy, matplotlib.pyplot as plt @@ -166,9 +180,9 @@ class MiscTests(unittest.TestCase): # S = \int (f(x) - m)^2q(x|mu,S) dx = \int f(x)^2 q(x) dx - mu**2 = 4(mu^2 + S) - (2.mu)^2 = 4S Y_mu_true = 2*X_pred_mu Y_var_true = 4*X_pred_var - Y_mu_pred, Y_var_pred = m._raw_predict(X_pred) - np.testing.assert_allclose(Y_mu_true, Y_mu_pred, rtol=1e-4) - np.testing.assert_allclose(Y_var_true, Y_var_pred, rtol=1e-4) + Y_mu_pred, Y_var_pred = m.predict_noiseless(X_pred) + np.testing.assert_allclose(Y_mu_true, Y_mu_pred, rtol=1e-3) + np.testing.assert_allclose(Y_var_true, Y_var_pred, rtol=1e-3) def test_sparse_raw_predict(self): k = GPy.kern.RBF(1) @@ -181,13 +195,13 @@ class MiscTests(unittest.TestCase): K_hat = k.K(self.X_new) - k.K(self.X_new, Z).dot(Kinv).dot(k.K(Z, self.X_new)) K_hat = np.clip(K_hat, 1e-15, np.inf) - mu, covar = m._raw_predict(self.X_new, full_cov=True) + mu, covar = m.predict_noiseless(self.X_new, full_cov=True) self.assertEquals(mu.shape, (self.N_new, self.D)) self.assertEquals(covar.shape, (self.N_new, self.N_new)) np.testing.assert_almost_equal(K_hat, covar) # np.testing.assert_almost_equal(mu_hat, mu) - mu, var = m._raw_predict(self.X_new) + mu, var = m.predict_noiseless(self.X_new) self.assertEquals(mu.shape, (self.N_new, self.D)) self.assertEquals(var.shape, (self.N_new, 1)) np.testing.assert_almost_equal(np.diag(K_hat)[:, None], var) @@ -361,52 +375,143 @@ class MiscTests(unittest.TestCase): preds = m.predict(self.X) warp_k = GPy.kern.RBF(1) - warp_f = GPy.util.warping_functions.IdentityFunction() - warp_m = GPy.models.WarpedGP(self.X, self.Y, kernel=warp_k, warping_function=warp_f) + warp_f = GPy.util.warping_functions.IdentityFunction(closed_inverse=False) + warp_m = GPy.models.WarpedGP(self.X, self.Y, kernel=warp_k, + warping_function=warp_f) warp_m.optimize() warp_preds = warp_m.predict(self.X) - - np.testing.assert_almost_equal(preds, warp_preds) - @unittest.skip('Comment this to plot the modified sine function') - def test_warped_gp_sine(self): + warp_k_exact = GPy.kern.RBF(1) + warp_f_exact = GPy.util.warping_functions.IdentityFunction() + warp_m_exact = GPy.models.WarpedGP(self.X, self.Y, kernel=warp_k_exact, + warping_function=warp_f_exact) + warp_m_exact.optimize() + warp_preds_exact = warp_m_exact.predict(self.X) + + np.testing.assert_almost_equal(preds, warp_preds, decimal=4) + np.testing.assert_almost_equal(preds, warp_preds_exact, decimal=4) + + def test_warped_gp_log(self): """ - A test replicating the sine regression problem from - Snelson's paper. + A WarpedGP with the log warping function should be + equal to a standard GP with log labels. + Note that we predict the median here. + """ + k = GPy.kern.RBF(1) + Y = np.abs(self.Y) + logY = np.log(Y) + m = GPy.models.GPRegression(self.X, logY, kernel=k) + m.optimize() + preds = m.predict(self.X)[0] + + warp_k = GPy.kern.RBF(1) + warp_f = GPy.util.warping_functions.LogFunction(closed_inverse=False) + warp_m = GPy.models.WarpedGP(self.X, Y, kernel=warp_k, + warping_function=warp_f) + warp_m.optimize() + warp_preds = warp_m.predict(self.X, median=True)[0] + + warp_k_exact = GPy.kern.RBF(1) + warp_f_exact = GPy.util.warping_functions.LogFunction() + warp_m_exact = GPy.models.WarpedGP(self.X, Y, kernel=warp_k_exact, + warping_function=warp_f_exact) + warp_m_exact.optimize(messages=True) + warp_preds_exact = warp_m_exact.predict(self.X, median=True)[0] + + np.testing.assert_almost_equal(np.exp(preds), warp_preds, decimal=4) + np.testing.assert_almost_equal(np.exp(preds), warp_preds_exact, decimal=4) + + def test_warped_gp_cubic_sine(self, max_iters=100): + """ + A test replicating the cubic sine regression problem from + Snelson's paper. This test doesn't have any assertions, it's + just to ensure coverage of the tanh warping function code. """ X = (2 * np.pi) * np.random.random(151) - np.pi - Y = np.sin(X) + np.random.normal(0,0.1,151) - Y = np.exp(Y) - 5 - #Y = np.array([np.power(abs(y),float(1)/3) * (1,-1)[y<0] for y in Y]) + 0 - - #np.seterr(over='raise') - import matplotlib.pyplot as plt - warp_k = GPy.kern.RBF(1) - warp_f = GPy.util.warping_functions.TanhWarpingFunction_d(n_terms=2) - warp_m = GPy.models.WarpedGP(X[:, None], Y[:, None], kernel=warp_k, warping_function=warp_f) - #warp_m['.*variance.*'].constrain_fixed(0.25) - #warp_m['.*lengthscale.*'].constrain_fixed(1) - #warp_m['warp_tanh.d'].constrain_fixed(1) - #warp_m.randomize() - #warp_m['.*warp_tanh.psi*'][:,0:2].constrain_bounded(0,100) - #warp_m['.*warp_tanh.psi*'][:,0:1].constrain_fixed(1) - - #print(warp_m.checkgrad()) - #warp_m.plot() - #plt.show() + Y = np.sin(X) + np.random.normal(0,0.2,151) + Y = np.array([np.power(abs(y),float(1)/3) * (1,-1)[y<0] for y in Y]) + X = X[:, None] + Y = Y[:, None] - warp_m.optimize_restarts(parallel=True, robust=True) - #print(warp_m.checkgrad()) - print(warp_m) - print(warp_m['.*warp.*']) + warp_m = GPy.models.WarpedGP(X, Y)#, kernel=warp_k)#, warping_function=warp_f) + warp_m['.*\.d'].constrain_fixed(1.0) + warp_m.optimize_restarts(parallel=False, robust=False, num_restarts=5, + max_iters=max_iters) + warp_m.predict(X) + warp_m.predict_quantiles(X) + warp_m.log_predictive_density(X, Y) warp_m.predict_in_warped_space = False warp_m.plot() warp_m.predict_in_warped_space = True warp_m.plot() - warp_f.plot(X.min()-10, X.max()+10) - plt.show() - + def test_offset_regression(self): + #Tests GPy.models.GPOffsetRegression. Using two small time series + #from a sine wave, we confirm the algorithm determines that the + #likelihood is maximised when the offset hyperparameter is approximately + #equal to the actual offset in X between the two time series. + offset = 3 + X1 = np.arange(0,50,5.0)[:,None] + X2 = np.arange(0+offset,50+offset,5.0)[:,None] + X = np.vstack([X1,X2]) + ind = np.vstack([np.zeros([10,1]),np.ones([10,1])]) + X = np.hstack([X,ind]) + Y = np.sin((X[0:10,0])/30.0)[:,None] + Y = np.vstack([Y,Y]) + + m = GPy.models.GPOffsetRegression(X,Y) + m.rbf.lengthscale=5.0 #make it something other than one to check our gradients properly! + assert m.checkgrad(), "Gradients of offset parameters don't match numerical approximations." + m.optimize() + assert np.abs(m.offset[0]-offset)<0.1, ("GPOffsetRegression model failing to estimate correct offset (value estimated = %0.2f instead of %0.2f)" % (m.offset[0], offset)) + + def test_logistic_basis_func_gradients(self): + X = np.random.uniform(-4, 4, (20, 5)) + points = np.random.uniform(X.min(0), X.max(0), X.shape[1]) + ks = [] + for i in range(points.shape[0]): + if (i%2==0) and (i%3!=0): + self.assertRaises(AssertionError, GPy.kern.LogisticBasisFuncKernel, 1, points, ARD=i%2==0, ARD_slope=i%3==0, active_dims=[i]) + else: + ks.append(GPy.kern.LogisticBasisFuncKernel(1, points, ARD=i%2==0, ARD_slope=i%3==0, active_dims=[i])) + k = GPy.kern.Add(ks) + k.randomize() + + Y = np.random.normal(0, 1, (X.shape[0], 1)) + m = GPy.models.GPRegression(X, Y, kernel=k.copy()) + assert m.checkgrad() + + def test_posterior_inf_basis_funcs(self): + X = np.random.uniform(-4, 1, (50, 1)) + + # Logistic: + k = GPy.kern.LogisticBasisFuncKernel(1, [0, -2]) + + true_w = [1, 2] + true_slope = [5, -2] + + Y = 0 + for w, s, c in zip(true_w, true_slope, k.centers[0]): + Y += w/(1+np.exp(-s*(X-c))) + Y += np.random.normal(0, .000001) + + m = GPy.models.GPRegression(X,Y,kernel=k.copy()) + #m.likelihood.fix(1e-6) + m.optimize() + + wu, wv = m.kern.posterior_inf() + #_sort = np.argsort(wu.flat) + + #from scipy.stats import norm + #confidence_intervals = np.array(norm.interval(.95, loc=wu.flat[_sort], scale=np.sqrt(np.diag(wv))[_sort])).T + #for i in range(wu.size): + # s,t = confidence_intervals[i] + # v = true_w[i] + # assert ((s0: + for i in range(len(l)): + _tmp = _flatten(l[i], pre+"[{}]".format(i)) + for _n in _tmp: + arr["{}".format(_n)] = _tmp[_n] + else: + return flatten_axis(l, pre+'.') + return arr + + + for name, l in members: + if isinstance(l, np.ndarray): + arrays[prevname+name] = np.asarray(l) + elif isinstance(l, list) and len(l)>0: + for i in range(len(l)): + _tmp = _flatten(l[i], prevname+name+"[{}]".format(i)) + for _n in _tmp: + arrays["{}".format(_n)] = _tmp[_n] + + return arrays + +def _a(x,y,decimal): + np.testing.assert_array_almost_equal(x, y, decimal) + +def compare_axis_dicts(x, y, decimal=6): + try: + assert(len(x)==len(y)) + for name in x: + _a(x[name], y[name], decimal) + except AssertionError as e: + raise SkipTest(e.message) + def test_figure(): np.random.seed(1239847) from GPy.plotting import plotting_library as pl #import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False import warnings with warnings.catch_warnings(): @@ -162,7 +244,7 @@ def test_kernel(): np.random.seed(1239847) #import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False import warnings with warnings.catch_warnings(): @@ -174,7 +256,7 @@ def test_kernel(): k2.plot_ARD(['rbf', 'linear', 'bias'], legend=True) k2.plot_covariance(visible_dims=[0, 3], plot_limits=(-1,3)) k2.plot_covariance(visible_dims=[2], plot_limits=(-1, 3)) - k2.plot_covariance(visible_dims=[2, 4], plot_limits=((-1, 0), (5, 3)), projection='3d') + k2.plot_covariance(visible_dims=[2, 4], plot_limits=((-1, 0), (5, 3)), projection='3d', rstride=10, cstride=10) k2.plot_covariance(visible_dims=[1, 4]) for do_test in _image_comparison( baseline_images=['kern_{}'.format(sub) for sub in ["ARD", 'cov_2d', 'cov_1d', 'cov_3d', 'cov_no_lim']], @@ -185,7 +267,7 @@ def test_plot(): np.random.seed(111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False import warnings with warnings.catch_warnings(): @@ -212,7 +294,7 @@ def test_twod(): np.random.seed(11111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False X = np.random.uniform(-2, 2, (40, 2)) f = .2 * np.sin(1.3*X[:,[0]]) + 1.3*np.cos(2*X[:,[1]]) @@ -221,7 +303,7 @@ def test_twod(): #m.optimize() m.plot_data() m.plot_mean() - m.plot_inducing() + m.plot_inducing(legend=False, marker='s') #m.plot_errorbars_trainset() m.plot_data_error() for do_test in _image_comparison(baseline_images=['gp_2d_{}'.format(sub) for sub in ["data", "mean", @@ -235,7 +317,7 @@ def test_threed(): np.random.seed(11111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False X = np.random.uniform(-2, 2, (40, 2)) f = .2 * np.sin(1.3*X[:,[0]]) + 1.3*np.cos(2*X[:,[1]]) @@ -247,7 +329,7 @@ def test_threed(): m.plot_samples(projection='3d', plot_raw=False, samples=1) plt.close('all') m.plot_data(projection='3d') - m.plot_mean(projection='3d') + m.plot_mean(projection='3d', rstride=10, cstride=10) m.plot_inducing(projection='3d') #m.plot_errorbars_trainset(projection='3d') for do_test in _image_comparison(baseline_images=['gp_3d_{}'.format(sub) for sub in ["data", "mean", 'inducing', @@ -260,7 +342,7 @@ def test_sparse(): np.random.seed(11111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False X = np.random.uniform(-2, 2, (40, 1)) f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X) @@ -268,7 +350,9 @@ def test_sparse(): m = GPy.models.SparseGPRegression(X, Y, X_variance=np.ones_like(X)*0.1) #m.optimize() #m.plot_inducing() - m.plot_data() + _, ax = plt.subplots() + m.plot_data(ax=ax) + m.plot_data_error(ax=ax) for do_test in _image_comparison(baseline_images=['sparse_gp_{}'.format(sub) for sub in ['data_error']], extensions=extensions): yield (do_test, ) @@ -276,7 +360,7 @@ def test_classification(): np.random.seed(11111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False X = np.random.uniform(-2, 2, (40, 1)) f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X) @@ -300,7 +384,7 @@ def test_sparse_classification(): np.random.seed(11111) import matplotlib matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False X = np.random.uniform(-2, 2, (40, 1)) f = .2 * np.sin(1.3*X) + 1.3*np.cos(2*X) @@ -312,35 +396,43 @@ def test_sparse_classification(): m.plot(plot_raw=True, apply_link=False, samples=3) np.random.seed(111) m.plot(plot_raw=True, apply_link=True, samples=3) - for do_test in _image_comparison(baseline_images=['sparse_gp_class_{}'.format(sub) for sub in ["likelihood", "raw", 'raw_link']], extensions=extensions): + for do_test in _image_comparison(baseline_images=['sparse_gp_class_{}'.format(sub) for sub in ["likelihood", "raw", 'raw_link']], extensions=extensions, rtol=2): yield (do_test, ) def test_gplvm(): - from ..examples.dimensionality_reduction import _simulate_matern - from ..kern import RBF - from ..models import GPLVM + from GPy.models import GPLVM np.random.seed(12345) matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False - Q = 3 + #Q = 3 # Define dataset - N = 10 - k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) - k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) - k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) - X = np.random.normal(0, 1, (N, 5)) - A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T - B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T - C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #N = 60 + #k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) + #k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) + #k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) + #X = np.random.normal(0, 1, (N, 5)) + #A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T + #B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T + #C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #Y = np.vstack((A,B,C)) + #labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) - Y = np.vstack((A,B,C)) - labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + #k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) + pars = np.load(os.path.join(basedir, 'b-gplvm-save.npz')) + Y = pars['Y'] + Q = pars['Q'] + labels = pars['labels'] + + import warnings + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always') # always print + m = GPLVM(Y, Q, initialize=False) + m.update_model(False) + m.initialize_parameter() + m[:] = pars['gplvm_p'] + m.update_model(True) - k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) - m = GPLVM(Y, Q, init="PCA", kernel=k) - m.kern.lengthscale[:] = [1./.3, 1./.1, 1./.7] - m.likelihood.variance = .001 #m.optimize(messages=0) np.random.seed(111) m.plot_latent(labels=labels) @@ -355,31 +447,40 @@ def test_gplvm(): yield (do_test, ) def test_bayesian_gplvm(): - from ..examples.dimensionality_reduction import _simulate_matern - from ..kern import RBF from ..models import BayesianGPLVM np.random.seed(12345) matplotlib.rcParams.update(matplotlib.rcParamsDefault) - matplotlib.rcParams[u'figure.figsize'] = (4,3) + #matplotlib.rcParams[u'figure.figsize'] = (4,3) matplotlib.rcParams[u'text.usetex'] = False - Q = 3 + #Q = 3 # Define dataset - N = 10 - k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) - k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) - k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) - X = np.random.normal(0, 1, (N, 5)) - A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T - B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T - C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T + #N = 10 + #k1 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,10,10,0.1,0.1]), ARD=True) + #k2 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[10,0.1,10,0.1,10]), ARD=True) + #k3 = GPy.kern.RBF(5, variance=1, lengthscale=1./np.random.dirichlet(np.r_[0.1,0.1,10,10,10]), ARD=True) + #X = np.random.normal(0, 1, (N, 5)) + #A = np.random.multivariate_normal(np.zeros(N), k1.K(X), Q).T + #B = np.random.multivariate_normal(np.zeros(N), k2.K(X), Q).T + #C = np.random.multivariate_normal(np.zeros(N), k3.K(X), Q).T - Y = np.vstack((A,B,C)) - labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + #Y = np.vstack((A,B,C)) + #labels = np.hstack((np.zeros(A.shape[0]), np.ones(B.shape[0]), np.ones(C.shape[0])*2)) + + #k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) + pars = np.load(os.path.join(basedir, 'b-gplvm-save.npz')) + Y = pars['Y'] + Q = pars['Q'] + labels = pars['labels'] + + import warnings + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always') # always print + m = BayesianGPLVM(Y, Q, initialize=False) + m.update_model(False) + m.initialize_parameter() + m[:] = pars['bgplvm_p'] + m.update_model(True) - k = RBF(Q, ARD=True, lengthscale=2) # + kern.white(Q, _np.exp(-2)) # + kern.bias(Q) - m = BayesianGPLVM(Y, Q, init="PCA", kernel=k) - m.kern.lengthscale[:] = [1./.3, 1./.1, 1./.7] - m.likelihood.variance = .001 #m.optimize(messages=0) np.random.seed(111) m.plot_inducing(projection='2d') @@ -398,4 +499,4 @@ def test_bayesian_gplvm(): if __name__ == '__main__': import nose - nose.main() + nose.main(defaultTest='./plotting_tests.py') diff --git a/GPy/testing/prior_tests.py b/GPy/testing/prior_tests.py index ca03ad93..23822a5a 100644 --- a/GPy/testing/prior_tests.py +++ b/GPy/testing/prior_tests.py @@ -6,6 +6,29 @@ import numpy as np import GPy class PriorTests(unittest.TestCase): + def test_studentT(self): + xmin, xmax = 1, 2.5*np.pi + b, C, SNR = 1, 0, 0.1 + X = np.linspace(xmin, xmax, 500) + y = b*X + C + 1*np.sin(X) + y += 0.05*np.random.randn(len(X)) + X, y = X[:, None], y[:, None] + studentT = GPy.priors.StudentT(1, 2, 4) + + m = GPy.models.SparseGPRegression(X, y) + m.Z.set_prior(studentT) + + # setting a StudentT prior on non-negative parameters + # should raise an assertionerror. + self.assertRaises(AssertionError, m.rbf.set_prior, studentT) + + # The gradients need to be checked + self.assertTrue(m.checkgrad()) + + # Check the singleton pattern: + self.assertIs(studentT, GPy.priors.StudentT(1,2,4)) + self.assertIsNot(studentT, GPy.priors.StudentT(2,2,4)) + def test_lognormal(self): xmin, xmax = 1, 2.5*np.pi b, C, SNR = 1, 0, 0.1 @@ -74,7 +97,7 @@ class PriorTests(unittest.TestCase): # setting a Gaussian prior on non-negative parameters # should raise an assertionerror. #self.assertRaises(AssertionError, m.Z.set_prior, gaussian) - + self.assertTrue(m.checkgrad()) def test_fixed_domain_check(self): @@ -107,8 +130,6 @@ class PriorTests(unittest.TestCase): # should raise an assertionerror. self.assertRaises(AssertionError, m.rbf.set_prior, gaussian) - - if __name__ == "__main__": print("Running unit tests, please be (very) patient...") unittest.main() diff --git a/GPy/testing/state_space_main_tests.py b/GPy/testing/state_space_main_tests.py new file mode 100644 index 00000000..5a1e6cd0 --- /dev/null +++ b/GPy/testing/state_space_main_tests.py @@ -0,0 +1,977 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2015, Alex Grigorevskiy +# Licensed under the BSD 3-clause license (see LICENSE.txt) +""" +Test module for state_space_main.py +""" + +import unittest +import numpy as np +import matplotlib.pyplot as plt +from scipy.stats import norm + +import GPy.models.state_space_setup as ss_setup +import GPy.models.state_space_main as ssm + +def generate_x_points(points_num=100, x_interval = (0, 20), random=True): + """ + Function generates (sorted) points on the x axis. + + Input: + --------------------------- + points_num: int + How many points to generate + x_interval: tuple (a,b) + On which interval to generate points + random: bool + Regular points or random + + Output: + --------------------------- + x_points: np.array + Generated points + """ + + x_interval = np.asarray( x_interval ) + + if random: + x_points = np.random.rand(points_num) * ( x_interval[1] - x_interval[0] ) + x_interval[0] + x_points = np.sort( x_points ) + else: + x_points = np.linspace(x_interval[0], x_interval[1], num=points_num ) + + return x_points + +def generate_sine_data(x_points=None, sin_period=2.0, sin_ampl=10.0, noise_var=2.0, + plot = False, points_num=100, x_interval = (0, 20), random=True): + """ + Function generates sinusoidal data. + + Input: + -------------------------------- + + x_points: np.array + Previously generated X points + sin_period: float + Sine period + sin_ampl: float + Sine amplitude + noise_var: float + Gaussian noise variance added to the sine function + plot: bool + Whether to plot generated data + + (if x_points is None, the the following parameters are used to generate + those. They are the same as in 'generate_x_points' function) + + points_num: int + + x_interval: tuple (a,b) + + random: bool + """ + + sin_function = lambda xx: sin_ampl * np.sin( 2*np.pi/sin_period * xx ) + + if x_points is None: + x_points = generate_x_points(points_num, x_interval, random) + + y_points = sin_function( x_points ) + np.random.randn( len(x_points) ) * np.sqrt(noise_var) + + if plot: + pass + + return x_points, y_points + +def generate_linear_data(x_points=None, tangent=2.0, add_term=1.0, noise_var=2.0, + plot = False, points_num=100, x_interval = (0, 20), random=True): + """ + Function generates linear data. + + Input: + -------------------------------- + + x_points: np.array + Previously generated X points + tangent: float + Factor with which independent variable is multiplied in linear equation. + add_term: float + Additive term in linear equation. + noise_var: float + Gaussian noise variance added to the sine function + plot: bool + Whether to plot generated data + + (if x_points is None, the the following parameters are used to generate + those. They are the same as in 'generate_x_points' function) + + points_num: int + + x_interval: tuple (a,b) + + random: bool + """ + + linear_function = lambda xx: tangent*xx + add_term + + if x_points is None: + x_points = generate_x_points(points_num, x_interval, random) + + y_points = linear_function( x_points ) + np.random.randn( len(x_points) ) * np.sqrt(noise_var) + + if plot: + pass + + return x_points, y_points + +def generate_brownian_data(x_points=None, kernel_var = 2.0, noise_var = 2.0, + plot = False, points_num=100, x_interval = (0, 20), random=True): + """ + Generate brownian data - data from Brownian motion. + First point is always 0, and \Beta(0) = 0 - standard conditions for Brownian motion. + + Input: + -------------------------------- + + x_points: np.array + Previously generated X points + variance: float + Gaussian noise variance added to the sine function + plot: bool + Whether to plot generated data + + (if x_points is None, the the following parameters are used to generate + those. They are the same as in 'generate_x_points' function) + + points_num: int + + x_interval: tuple (a,b) + + random: bool + + """ + if x_points is None: + x_points = generate_x_points(points_num, x_interval, random) + if x_points[0] != 0: + x_points[0] = 0 + + y_points = np.zeros( (points_num,) ) + for i in range(1, points_num): + noise = np.random.randn() * np.sqrt(kernel_var * (x_points[i] - x_points[i-1])) + y_points[i] = y_points[i-1] + noise + + y_points += np.random.randn( len(x_points) ) * np.sqrt(noise_var) + + return x_points, y_points + +def generate_linear_plus_sin(x_points=None, tangent=2.0, add_term=1.0, noise_var=2.0, + sin_period=2.0, sin_ampl=10.0, plot = False, + points_num=100, x_interval = (0, 20), random=True): + """ + Generate the sum of linear trend and the sine function. + + For parameters see the 'generate_linear' and 'generate_sine'. + + Comment: Gaussian noise variance is added only once (for linear function). + """ + + x_points, y_linear_points = generate_linear_data(x_points, tangent, add_term, noise_var, + False, points_num, x_interval, random) + + x_points, y_sine_points = generate_sine_data(x_points, sin_period, sin_ampl, 0.0, + False, points_num, x_interval, random) + + y_points = y_linear_points + y_sine_points + + if plot: + pass + + return x_points, y_points + +def generate_random_y_data(samples, dim, ts_no): + """ + Generate data: + + Input: + ------------------ + + samples - how many samples + dim - dimensionality of the data + ts_no - number of time series + + Output: + -------------------------- + Y: np.array((samples, dim, ts_no)) + """ + + Y = np.empty((samples, dim, ts_no)); + + for i in range(0,samples): + for j in range(0,ts_no): + sample = np.random.randn(dim) + Y[i,:,j] = sample + + if (Y.shape[2] == 1): # ts_no = 1 + Y.shape=(Y.shape[0], Y.shape[1]) + return Y + + +class StateSpaceKernelsTests(np.testing.TestCase): + def setUp(self): + pass + + def run_descr_model(self, measurements, A,Q,H,R, true_states=None, + mean_compare_decimal=8, + m_init=None, P_init=None, dA=None,dQ=None, + dH=None,dR=None, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True): + + #import pdb; pdb.set_trace() + + state_dim = 1 if not isinstance(A,np.ndarray) else A.shape[0] + ts_no = 1 if (len(measurements.shape) < 3) else measurements.shape[2] + grad_params_no = None if dA is None else dA.shape[2] + + + ss_setup.use_cython = use_cython + global ssm + if (ssm.cython_code_available) and (ssm.use_cython != use_cython): + reload(ssm) + + grad_calc_params = None + if calc_grad_log_likelihood: + grad_calc_params = {} + grad_calc_params['dA'] = dA + grad_calc_params['dQ'] = dQ + grad_calc_params['dH'] = dH + grad_calc_params['dR'] = dR + + (f_mean, f_var, loglikelhood, g_loglikelhood, \ + dynamic_callables_smoother) = ssm.DescreteStateSpace.kalman_filter(A, Q, H, R, measurements, index=None, + m_init=m_init, P_init=P_init, p_kalman_filter_type = kalman_filter_type, + calc_log_likelihood=calc_log_likelihood, + calc_grad_log_likelihood=calc_grad_log_likelihood, + grad_params_no=grad_params_no, + grad_calc_params=grad_calc_params) + + f_mean_squeezed = np.squeeze(f_mean[1:,:]) # exclude initial value + f_var_squeezed = np.squeeze(f_var[1:,:]) # exclude initial value + + if true_states is not None: + #print np.max(np.abs(f_mean_squeezed-true_states)) + np.testing.assert_almost_equal(np.max(np.abs(f_mean_squeezed- \ + true_states)), 0, decimal=mean_compare_decimal) + + np.testing.assert_equal(f_mean.shape, (measurements.shape[0]+1,state_dim,ts_no) ) + np.testing.assert_equal(f_var.shape, (measurements.shape[0]+1,state_dim,state_dim) ) + + (M_smooth, P_smooth) = ssm.DescreteStateSpace.rts_smoother(state_dim, dynamic_callables_smoother, f_mean, + f_var) + + return f_mean, f_var + + def run_continuous_model(self, F, L, Qc, p_H, p_R, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=None, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=0, grad_calc_params=None): + + #import pdb; pdb.set_trace() + + state_dim = 1 if not isinstance(F,np.ndarray) else F.shape[0] + ts_no = 1 if (len(Y_data.shape) < 3) else Y_data.shape[2] + + ss_setup.use_cython = use_cython + global ssm + if (ssm.cython_code_available) and (ssm.use_cython != use_cython): + reload(ssm) + + (f_mean, f_var, loglikelhood, g_loglikelhood, \ + dynamic_callables_smoother) = ssm.ContDescrStateSpace.cont_discr_kalman_filter(F, L, Qc, p_H, p_R, + P_inf, X_data, Y_data, index = None, + m_init=None, P_init=None, + p_kalman_filter_type='regular', + calc_log_likelihood=False, + calc_grad_log_likelihood=False, + grad_params_no=0, grad_calc_params=grad_calc_params) + + f_mean_squeezed = np.squeeze(f_mean[1:,:]) # exclude initial value + f_var_squeezed = np.squeeze(f_var[1:,:]) # exclude initial value + + np.testing.assert_equal(f_mean.shape, (Y_data.shape[0]+1,state_dim,ts_no)) + np.testing.assert_equal(f_var.shape, (Y_data.shape[0]+1,state_dim,state_dim)) + + (M_smooth, P_smooth) = ssm.ContDescrStateSpace.cont_discr_rts_smoother(state_dim, f_mean, \ + f_var,dynamic_callables_smoother) + + return f_mean, f_var + + def test_discrete_ss_first(self,plot=False): + """ + Tests discrete State-Space model - first test. + """ + np.random.seed(235) # seed the random number generator + + A = 1.0 # For cython code to run properly need float input + H = 1.0 + Q = 1.0 + R = 1.0 + + steps_num = 100 + + # generate data -> + true_states = np.zeros((steps_num,)) + init_state = 0 + measurements = np.zeros((steps_num,)) + + for s in range(0, steps_num): + if s== 0: + true_states[0] = init_state + np.sqrt(Q)*np.random.randn() + else: + true_states[s] = true_states[s-1] + np.sqrt(R)*np.random.randn() + measurements[s] = true_states[s] + np.sqrt(R)*np.random.randn() + # generate data <- + + # descrete kalman filter -> + m_init = 0; P_init = 1 + d_num = 1000 + state_discr = np.linspace(-10,10,d_num) + + state_trans_matrix = np.empty((d_num,d_num)) + for i in range(d_num): + state_trans_matrix[:,i] = norm.pdf(state_discr, loc=A*state_discr[i], scale=np.sqrt(Q)) + + m_prev = norm.pdf(state_discr, loc = m_init, scale = np.sqrt(P_init)); #m_prev / np.sum(m_prev) + m = np.zeros((d_num, steps_num)) + i_mean = np.zeros((steps_num,)) + + for s in range(0, steps_num): + # Prediction step: + if (s==0): + m[:,s] = np.dot(state_trans_matrix, m_prev) + else: + m[:,s] = np.dot(state_trans_matrix, m[:,s-1]) + # Update step: + #meas_ind = np.argmin(np.abs(state_discr - measurements[s]) + y_vec = np.zeros( (d_num,)) + for i in range(d_num): + y_vec[i] = norm.pdf(measurements[s], loc=H*state_discr[i], scale=np.sqrt(R)) + norm_const = np.dot( y_vec, m[:,s] ) + m[:,s] = y_vec * m[:,s] / norm_const + + i_mean[s] = state_discr[ np.argmax(m[:,s]) ] + # descrete kalman filter <- + + (f_mean, f_var) = self.run_descr_model(measurements, A,Q,H,R, true_states=i_mean, + mean_compare_decimal=1, + m_init=m_init, P_init=P_init,use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=False) + + (f_mean, f_var) = self.run_descr_model(measurements, A,Q,H,R, true_states=i_mean, + mean_compare_decimal=1, + m_init=m_init, P_init=P_init,use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=False) + + (f_mean, f_var) = self.run_descr_model(measurements, A,Q,H,R, true_states=i_mean, + mean_compare_decimal=1, + m_init=m_init, P_init=P_init,use_cython=True, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=False) + + if plot: + # plotting -> + plt.figure() + plt.plot( true_states, 'g.-',label='true states') + #plt.plot( measurements, 'b.-', label='measurements') + plt.plot( f_mean, 'r.-',label='Kalman filter estimates') + plt.plot( i_mean, 'k.-', label='Discretization') + + plt.plot( f_mean + 2*np.sqrt(f_var), 'r.--') + plt.plot( f_mean - 2*np.sqrt(f_var), 'r.--') + plt.legend() + plt.show() + # plotting <- + return None + + def test_discrete_ss_1D(self,plot=False): + """ + This function tests Kalman filter and smoothing when the state + dimensionality is one dimensional. + """ + + np.random.seed(234) # seed the random number generator + + # 1D ss model + state_dim = 1; + param_num = 2 # sigma_Q, sigma_R - parameters + measurement_dim = 1 # dimensionality od measurement + + A = 1.0 + Q = 2.0 + dA= np.zeros((state_dim,state_dim,param_num)) + dQ = np.zeros((state_dim,state_dim,param_num)); dQ[0,0,0] = 1.0 + + # measurement related parameters (subject to change) -> + H = np.ones((measurement_dim,state_dim )) + R = 0.5 * np.eye(measurement_dim) + dH = np.zeros((measurement_dim,state_dim,param_num)) + dR = np.zeros((measurement_dim,measurement_dim,param_num)); dR[:,:,1] = np.eye(measurement_dim) + # measurement related parameters (subject to change) <- + + # 1D measurement, 1 ts_no -> + data = generate_random_y_data(10, 1, 1) # np.array((samples, dim, ts_no)) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=True, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:]+H*f_var[1:]*H), 'b--') + plt.plot( np.squeeze(f_mean[1:]-H*f_var[1:]*H), 'b--') +# plt.plot( np.squeeze(M_sm[1:]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:]+H*P_sm[1:]*H), 'r--') +# plt.plot( np.squeeze(M_sm[1:]-H*P_sm[1:]*H), 'r--') + plt.legend() + plt.title("1D state-space, 1D measurements, 1 ts_no") + plt.show() + # plotting <- + # 1D measurement, 1 ts_no <- + + + # 1D measurement, 3 ts_no -> + data = generate_random_y_data(10, 1, 3) # np.array((samples, dim, ts_no)) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=True, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + #import pdb; pdb.set_trace() + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data[:,:,1]), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:,0,1]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:,0,1])+np.squeeze(H*f_var[1:]*H), 'b--') + plt.plot( np.squeeze(f_mean[1:,0,1])-np.squeeze(H*f_var[1:]*H), 'b--') +# plt.plot( np.squeeze(M_sm[1:,0,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,0,1])+H*np.squeeze(P_sm[1:])*H, 'r--') +# plt.plot( np.squeeze(M_sm[1:,0,1])-H*np.squeeze(P_sm[1:])*H, 'r--') + plt.legend() + plt.title("1D state-space, 1D measurements, 3 ts_no. 2-nd ts ploted") + plt.show() + # plotting <- + # 1D measurement, 3 ts_no <- + measurement_dim = 2 # dimensionality of measurement + + H = np.ones((measurement_dim,state_dim)) + R = 0.5 * np.eye(measurement_dim) + dH = np.zeros((measurement_dim,state_dim,param_num)) + dR = np.zeros((measurement_dim,measurement_dim,param_num)); dR[:,:,1] = np.eye(measurement_dim) + # measurement related parameters (subject to change) < + + data = generate_random_y_data(10, 2, 3) # np.array((samples, dim, ts_no)) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + +# (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, +# mean_compare_decimal=16, +# m_init=None, P_init=None, dA=dA,dQ=dQ, +# dH=dH,dR=dR, use_cython=True, +# kalman_filter_type='svd', +# calc_log_likelihood=True, +# calc_grad_log_likelihood=True) + + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data[:,0,1]), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:,0,1]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:,0,1])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot( np.squeeze(f_mean[1:,0,1])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,0,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,0,1])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,0,1])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("1D state-space, 2D measurements, 3 ts_no. 1-st measurement, 2-nd ts ploted") + plt.show() + # plotting <- + # 2D measurement, 3 ts_no <- + + def test_discrete_ss_2D(self,plot=False): + """ + This function tests Kalman filter and smoothing when the state + dimensionality is two dimensional. + """ + + np.random.seed(234) # seed the random number generator + + # 1D ss model + state_dim = 2; + param_num = 3 # sigma_Q, sigma_R, one parameters in A - parameters + measurement_dim = 1 # dimensionality od measurement + + A = np.eye(state_dim); A[0,0] = 0.5 + Q = np.ones((state_dim,state_dim)); + dA = np.zeros((state_dim,state_dim,param_num)); dA[1,1,2] = 1 + dQ = np.zeros((state_dim,state_dim,param_num)); dQ[:,:,1] = np.eye(measurement_dim) + + # measurement related parameters (subject to change) -> + H = np.ones((measurement_dim,state_dim)) + R = 0.5 * np.eye(measurement_dim) + dH = np.zeros((measurement_dim,state_dim,param_num)) + dR = np.zeros((measurement_dim,measurement_dim,param_num)); dR[:,:,1] = np.eye(measurement_dim) + # measurement related parameters (subject to change) <- + + # 1D measurement, 1 ts_no -> + data = generate_random_y_data(10, 1, 1) # np.array((samples, dim, ts_no)) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=True, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:,0]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:,0])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot( np.squeeze(f_mean[1:,0])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,0]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,0])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,0])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("2D state-space, 1D measurements, 1 ts_no") + plt.show() + # plotting <- + # 1D measurement, 1 ts_no <- + + # 1D measurement, 3 ts_no -> + data = generate_random_y_data(10, 1, 3) # np.array((samples, dim, ts_no)) + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=True, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data[:,:,1]), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:,0,1]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:,0,1])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot( np.squeeze(f_mean[1:,0,1])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,0,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,0,1])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,0,1])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("2D state-space, 1D measurements, 3 ts_no. 2-nd ts ploted") + plt.show() + # plotting <- + # 1D measurement, 3 ts_no <- + + # 2D measurement, 3 ts_no -> + # measurement related parameters (subject to change) -> + measurement_dim = 2 # dimensionality od measurement + + H = np.ones((measurement_dim,state_dim)) + R = 0.5 * np.eye(measurement_dim) + dH = np.zeros((measurement_dim,state_dim,param_num)) + dR = np.zeros((measurement_dim,measurement_dim,param_num)); dR[:,:,1] = np.eye(measurement_dim) + # measurement related parameters (subject to change) < + + data = generate_random_y_data(10, 2, 3) # np.array((samples, dim, ts_no)) + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + + (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, + mean_compare_decimal=16, + m_init=None, P_init=None, dA=dA,dQ=dQ, + dH=dH,dR=dR, use_cython=False, + kalman_filter_type='svd', + calc_log_likelihood=True, + calc_grad_log_likelihood=True) + +# (f_mean, f_var) = self.run_descr_model(data, A,Q,H,R, true_states=None, +# mean_compare_decimal=16, +# m_init=None, P_init=None, dA=dA,dQ=dQ, +# dH=dH,dR=dR, use_cython=True, +# kalman_filter_type='svd', +# calc_log_likelihood=True, +# calc_grad_log_likelihood=True) + + if plot: + # plotting -> + plt.figure() + plt.plot( np.squeeze(data[:,0,1]), 'g.-', label='measurements') + plt.plot( np.squeeze(f_mean[1:,0,1]), 'b.-',label='Kalman filter estimates') + plt.plot( np.squeeze(f_mean[1:,0,1])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot( np.squeeze(f_mean[1:,0,1])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,0,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,0,1])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,0,1])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("2D state-space, 2D measurements, 3 ts_no. 1-st measurement, 2-nd ts ploted") + plt.show() + # plotting <- + # 2D measurement, 3 ts_no <- + + def test_continuos_ss(self,plot=False): + """ + This function tests the continuos state-space model. + """ + + # 1D measurements, 1 ts_no -> + measurement_dim = 1 # dimensionality of measurement + + X_data = generate_x_points(points_num=10, x_interval = (0, 20), random=True) + Y_data = generate_random_y_data(10, 1, 1) # np.array((samples, dim, ts_no)) + + try: + import GPy + except ImportError as e: + return None + + periodic_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + (F,L,Qc,H,P_inf,P0, dFt,dQct,dP_inft,dP0) = periodic_kernel.sde() + + state_dim = dFt.shape[0]; + param_num = dFt.shape[2] + + + grad_calc_params = {} + grad_calc_params['dP_inf'] = dP_inft + grad_calc_params['dF'] = dFt + grad_calc_params['dQc'] = dQct + grad_calc_params['dR'] = np.zeros((measurement_dim,measurement_dim,param_num)) + grad_calc_params['dP_init'] = dP0 + # dH matrix is None + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='rbc', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=True, + kalman_filter_type='rbc', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + if plot: + # plotting -> + plt.figure() + plt.plot( X_data, np.squeeze(Y_data[:,0]), 'g.-', label='measurements') + plt.plot( X_data, np.squeeze(f_mean[1:,15]), 'b.-',label='Kalman filter estimates') + plt.plot( X_data, np.squeeze(f_mean[1:,15])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot( X_data, np.squeeze(f_mean[1:,15])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + # plt.plot( np.squeeze(M_sm[1:,15]), 'r.-',label='Smoother Estimates') + # plt.plot( np.squeeze(M_sm[1:,15])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + # plt.plot( np.squeeze(M_sm[1:,15])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("1D measurements, 1 ts_no") + plt.show() + # plotting <- + # 1D measurements, 1 ts_no <- + + # 1D measurements, 3 ts_no -> + measurement_dim = 1 # dimensionality od measurement + + X_data = generate_x_points(points_num=10, x_interval = (0, 20), random=True) + Y_data = generate_random_y_data(10, 1, 3) # np.array((samples, dim, ts_no)) + + periodic_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + (F,L,Qc,H,P_inf,P0, dFt,dQct,dP_inft,dP0) = periodic_kernel.sde() + + state_dim = dFt.shape[0]; + param_num = dFt.shape[2] + + grad_calc_params = {} + grad_calc_params['dP_inf'] = dP_inft + grad_calc_params['dF'] = dFt + grad_calc_params['dQc'] = dQct + grad_calc_params['dR'] = np.zeros((measurement_dim,measurement_dim,param_num)) + grad_calc_params['dP_init'] = dP0 + # dH matrix is None + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='rbc', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, 1.5, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=True, + kalman_filter_type='rbc', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + if plot: + # plotting -> + plt.figure() + plt.plot(X_data, np.squeeze(Y_data[:,0,1]), 'g.-', label='measurements') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1]), 'b.-',label='Kalman filter estimates') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,15,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,15,1])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,15,1])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("1D measurements, 3 ts_no. 2-nd ts ploted") + plt.show() + # plotting <- + # 1D measurements, 3 ts_no <- + + + # 2D measurements, 3 ts_no -> + measurement_dim = 2 # dimensionality od measurement + + X_data = generate_x_points(points_num=10, x_interval = (0, 20), random=True) + Y_data = generate_random_y_data(10, 2, 3) # np.array((samples, dim, ts_no)) + + periodic_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) + (F,L,Qc,H,P_inf,P0, dFt,dQct,dP_inft,dP0) = periodic_kernel.sde() + H = np.vstack((H,H)) # make 2D measurements + R = 1.5 * np.eye(measurement_dim) + + state_dim = dFt.shape[0]; + param_num = dFt.shape[2] + + + grad_calc_params = {} + grad_calc_params['dP_inf'] = dP_inft + grad_calc_params['dF'] = dFt + grad_calc_params['dQc'] = dQct + grad_calc_params['dR'] = np.zeros((measurement_dim,measurement_dim,param_num)) + grad_calc_params['dP_init'] = dP0 + # dH matrix is None + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, R, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='regular', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + + (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, R, P_inf, X_data, Y_data, index = None, + m_init=None, P_init=P0, use_cython=False, + kalman_filter_type='rbc', + calc_log_likelihood=True, + calc_grad_log_likelihood=True, + grad_params_no=param_num, grad_calc_params=grad_calc_params) + +# (f_mean, f_var) = self.run_continuous_model(F, L, Qc, H, R, P_inf, X_data, Y_data, index = None, +# m_init=None, P_init=P0, use_cython=True, +# kalman_filter_type='rbc', +# calc_log_likelihood=True, +# calc_grad_log_likelihood=True, +# grad_params_no=param_num, grad_calc_params=grad_calc_params) + + if plot: + # plotting -> + plt.figure() + plt.plot(X_data, np.squeeze(Y_data[:,0,1]), 'g.-', label='measurements') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1]), 'b.-',label='Kalman filter estimates') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1])+np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') + plt.plot(X_data, np.squeeze(f_mean[1:,15,1])-np.einsum('ij,ajk,kl', H, f_var[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_sm[1:,15,1]), 'r.-',label='Smoother Estimates') +# plt.plot( np.squeeze(M_sm[1:,15,1])+np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') +# plt.plot( np.squeeze(M_sm[1:,15,1])-np.einsum('ij,ajk,kl', H, P_sm[1:], H.T)[:,0,0], 'r--') + plt.legend() + plt.title("1D measurements, 3 ts_no. 2-nd ts ploted") + plt.show() + # plotting <- + # 2D measurements, 3 ts_no <- + +#def test_EM_gradient(plot=False): +# """ +# Test EM gradient calculation. This method works (the formulas are such) +# that it works only for time invariant matrices A, Q, H, R. For the continuous +# model it means that time intervals are the same. +# """ +# +# np.random.seed(234) # seed the random number generator +# +# # 1D measurements, 1 ts_no -> +# measurement_dim = 1 # dimensionality of measurement +# +# x_data = generate_x_points(points_num=10, x_interval = (0, 20), random=False) +# data = generate_random_y_data(10, 1, 1) # np.array((samples, dim, ts_no)) +# +# import GPy +# #periodic_kernel = GPy.kern.sde_Matern32(1,active_dims=[0,]) +# periodic_kernel = GPy.kern.sde_StdPeriodic(1,active_dims=[0,]) +# (F,L,Qc,H,P_inf,P0, dFt,dQct,dP_inft,dP0t) = periodic_kernel.sde() +# +# state_dim = dFt.shape[0]; +# param_num = dFt.shape[2] +# +# grad_calc_params = {} +# grad_calc_params['dP_inf'] = dP_inft +# grad_calc_params['dF'] = dFt +# grad_calc_params['dQc'] = dQct +# grad_calc_params['dR'] = np.zeros((measurement_dim,measurement_dim,param_num)) +# grad_calc_params['dP_init'] = dP0t +# # dH matrix is None +# +# +# #(F,L,Qc,H,P_inf,dF,dQc,dP_inf) = ssm.balance_ss_model(F,L,Qc,H,P_inf,dF,dQc,dP_inf) +# # Use the Kalman filter to evaluate the likelihood +# +# #import pdb; pdb.set_trace() +# (M_kf, P_kf, log_likelihood, +# grad_log_likelihood,SmootherMatrObject) = ss.ContDescrStateSpace.cont_discr_kalman_filter(F, +# L, Qc, H, 1.5, P_inf, x_data, data, m_init=None, +# P_init=P0, calc_log_likelihood=True, +# calc_grad_log_likelihood=True, +# grad_params_no=param_num, +# grad_calc_params=grad_calc_params) +# +# if plot: +# # plotting -> +# plt.figure() +# plt.plot( np.squeeze(data[:,0]), 'g.-', label='measurements') +# plt.plot( np.squeeze(M_kf[1:,15]), 'b.-',label='Kalman filter estimates') +# plt.plot( np.squeeze(M_kf[1:,15])+np.einsum('ij,ajk,kl', H, P_kf[1:], H.T)[:,0,0], 'b--') +# plt.plot( np.squeeze(M_kf[1:,15])-np.einsum('ij,ajk,kl', H, P_kf[1:], H.T)[:,0,0], 'b--') +# plt.title("1D measurements, 1 ts_no") +# plt.show() +# # plotting <- +# # 1D measurements, 1 ts_no <- + +if __name__ == '__main__': + print("Running state-space inference tests...") + unittest.main() + + #tt = StateSpaceKernelsTests('test_discrete_ss_first') + #res = tt.test_discrete_ss_first(plot=True) + #res = tt.test_discrete_ss_1D(plot=True) + #res = tt.test_discrete_ss_2D(plot=False) + #res = tt.test_continuos_ss(plot=True) + + \ No newline at end of file diff --git a/GPy/testing/util_tests.py b/GPy/testing/util_tests.py index b89b3601..ba3d7ddf 100644 --- a/GPy/testing/util_tests.py +++ b/GPy/testing/util_tests.py @@ -29,6 +29,7 @@ #=============================================================================== import unittest, numpy as np +import GPy class TestDebug(unittest.TestCase): def test_checkFinite(self): @@ -96,3 +97,61 @@ class TestDebug(unittest.TestCase): self.assertTrue((2, np.median(X.mean.values[:,2])) in fixed) self.assertTrue(len([t for t in fixed if t[0] == 1]) == 0) # Unfixed input should not be in fixed + def test_subarray(self): + import GPy + X = np.zeros((3,6), dtype=bool) + X[[1,1,1],[0,4,5]] = 1 + X[1:,[2,3]] = 1 + d = GPy.util.subarray_and_sorting.common_subarrays(X,axis=1) + self.assertTrue(len(d) == 3) + X[:, d[tuple(X[:,0])]] + self.assertTrue(d[tuple(X[:,4])] == d[tuple(X[:,0])] == [0, 4, 5]) + self.assertTrue(d[tuple(X[:,1])] == [1]) + + def test_offset_cluster(self): + #Tests the GPy.util.cluster_with_offset.cluster utility with a small + #test data set. Not using random noise just in case it occasionally + #causes it not to cluster correctly. + #groundtruth cluster identifiers are: [0,1,1,0] + + #data contains a list of the four sets of time series (3 per data point) + + data = [np.array([[ 2.18094245, 1.96529789, 2.00265523, 2.18218742, 2.06795428], + [ 1.62254829, 1.75748448, 1.83879347, 1.87531326, 1.52503496], + [ 1.54589609, 1.61607914, 2.00463192, 1.48771394, 1.63339218]]), + np.array([[ 2.86766106, 2.97953437, 2.91958876, 2.92510506, 3.03239241], + [ 2.57368423, 2.59954886, 3.10000395, 2.75806125, 2.89865704], + [ 2.58916318, 2.53698259, 2.63858411, 2.63102504, 2.51853901]]), + np.array([[ 2.77834168, 2.9618564 , 2.88482141, 3.24259745, 2.9716821 ], + [ 2.60675576, 2.67095624, 2.94824436, 2.80520631, 2.87247516], + [ 2.49543562, 2.5492281 , 2.6505866 , 2.65015308, 2.59738616]]), + np.array([[ 1.76783086, 2.21666738, 2.07939706, 1.9268263 , 2.23360121], + [ 1.94305547, 1.94648592, 2.1278921 , 2.09481457, 2.08575238], + [ 1.69336013, 1.72285186, 1.6339506 , 1.61212022, 1.39198698]])] + + #inputs contains their associated X values + + inputs = [np.array([[ 0. ], + [ 0.68040097], + [ 1.20316795], + [ 1.798749 ], + [ 2.14891733]]), np.array([[ 0. ], + [ 0.51910637], + [ 0.98259352], + [ 1.57442965], + [ 1.82515098]]), np.array([[ 0. ], + [ 0.66645478], + [ 1.59464591], + [ 1.69769551], + [ 1.80932752]]), np.array([[ 0. ], + [ 0.87512108], + [ 1.71881079], + [ 2.67162871], + [ 3.23761907]])] + + #try doing the clustering + active = GPy.util.cluster_with_offset.cluster(data,inputs) + #check to see that the clustering has correctly clustered the time series. + clusters = set([frozenset(cluster) for cluster in active]) + assert set([1,2]) in clusters, "Offset Clustering algorithm failed" + assert set([0,3]) in clusters, "Offset Clustering algoirthm failed" diff --git a/GPy/util/__init__.py b/GPy/util/__init__.py index fb1eb0d6..685551fd 100644 --- a/GPy/util/__init__.py +++ b/GPy/util/__init__.py @@ -16,3 +16,4 @@ from . import initialization from . import multioutput from . import parallel from . import functions +from . import cluster_with_offset diff --git a/GPy/util/choleskies_cython.c b/GPy/util/choleskies_cython.c index 8205c62b..11afafab 100644 --- a/GPy/util/choleskies_cython.c +++ b/GPy/util/choleskies_cython.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.22 */ +/* Generated by Cython 0.21 */ #define PY_SSIZE_T_CLEAN #ifndef CYTHON_USE_PYLONG_INTERNALS @@ -19,7 +19,7 @@ #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000) #error Cython requires Python 2.6+ or Python 3.2+. #else -#define CYTHON_ABI "0_22" +#define CYTHON_ABI "0_21" #include #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) @@ -54,7 +54,7 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) +#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 #define Py_OptimizeFlag 0 #endif #define __PYX_BUILD_PY_SSIZE_T "n" @@ -73,6 +73,8 @@ #if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 +#endif +#if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif #if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE) @@ -99,12 +101,10 @@ #if CYTHON_COMPILING_IN_PYPY #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b) - #define __Pyx_PyFrozenSet_Size(s) PyObject_Size(s) #else #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b) #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \ PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b)) - #define __Pyx_PyFrozenSet_Size(s) PySet_Size(s) #endif #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) @@ -151,11 +151,6 @@ #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif #if PY_VERSION_HEX < 0x030200A4 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong @@ -165,9 +160,7 @@ #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif #if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) + #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #endif #ifndef CYTHON_INLINE #if defined(__GNUC__) @@ -203,22 +196,11 @@ static CYTHON_INLINE float __PYX_NAN() { return value; } #endif -#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None) #ifdef __cplusplus template void __Pyx_call_destructor(T* x) { x->~T(); } -template -class __Pyx_FakeReference { - public: - __Pyx_FakeReference() : ptr(NULL) { } - __Pyx_FakeReference(T& ref) : ptr(&ref) { } - T *operator->() { return ptr; } - operator T&() { return *ptr; } - private: - T *ptr; -}; #endif @@ -306,11 +288,11 @@ static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*); #endif #define __Pyx_PyObject_AsSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) #define __Pyx_PyObject_AsUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s) -#define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s) -#define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s) -#define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) +#define __Pyx_PyObject_FromUString(s) __Pyx_PyObject_FromString((const char*)s) +#define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((const char*)s) +#define __Pyx_PyByteArray_FromUString(s) __Pyx_PyByteArray_FromString((const char*)s) +#define __Pyx_PyStr_FromUString(s) __Pyx_PyStr_FromString((const char*)s) +#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s) #if PY_MAJOR_VERSION < 3 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { @@ -346,7 +328,7 @@ static int __Pyx_init_sys_getdefaultencoding_params(void) { const char* default_encoding_c; sys = PyImport_ImportModule("sys"); if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); + default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); Py_DECREF(sys); if (!default_encoding) goto bad; default_encoding_c = PyBytes_AsString(default_encoding); @@ -551,7 +533,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; #endif -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":723 * # in Cython to enable them only on the right systems. * * ctypedef npy_int8 int8_t # <<<<<<<<<<<<<< @@ -560,7 +542,7 @@ typedef volatile __pyx_atomic_int_type __pyx_atomic_int; */ typedef npy_int8 __pyx_t_5numpy_int8_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":727 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":724 * * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t # <<<<<<<<<<<<<< @@ -569,7 +551,7 @@ typedef npy_int8 __pyx_t_5numpy_int8_t; */ typedef npy_int16 __pyx_t_5numpy_int16_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":728 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":725 * ctypedef npy_int8 int8_t * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t # <<<<<<<<<<<<<< @@ -578,7 +560,7 @@ typedef npy_int16 __pyx_t_5numpy_int16_t; */ typedef npy_int32 __pyx_t_5numpy_int32_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":729 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":726 * ctypedef npy_int16 int16_t * ctypedef npy_int32 int32_t * ctypedef npy_int64 int64_t # <<<<<<<<<<<<<< @@ -587,7 +569,7 @@ typedef npy_int32 __pyx_t_5numpy_int32_t; */ typedef npy_int64 __pyx_t_5numpy_int64_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":730 * #ctypedef npy_int128 int128_t * * ctypedef npy_uint8 uint8_t # <<<<<<<<<<<<<< @@ -596,7 +578,7 @@ typedef npy_int64 __pyx_t_5numpy_int64_t; */ typedef npy_uint8 __pyx_t_5numpy_uint8_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":734 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":731 * * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t # <<<<<<<<<<<<<< @@ -605,7 +587,7 @@ typedef npy_uint8 __pyx_t_5numpy_uint8_t; */ typedef npy_uint16 __pyx_t_5numpy_uint16_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":735 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":732 * ctypedef npy_uint8 uint8_t * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t # <<<<<<<<<<<<<< @@ -614,7 +596,7 @@ typedef npy_uint16 __pyx_t_5numpy_uint16_t; */ typedef npy_uint32 __pyx_t_5numpy_uint32_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":736 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":733 * ctypedef npy_uint16 uint16_t * ctypedef npy_uint32 uint32_t * ctypedef npy_uint64 uint64_t # <<<<<<<<<<<<<< @@ -623,7 +605,7 @@ typedef npy_uint32 __pyx_t_5numpy_uint32_t; */ typedef npy_uint64 __pyx_t_5numpy_uint64_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":740 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":737 * #ctypedef npy_uint128 uint128_t * * ctypedef npy_float32 float32_t # <<<<<<<<<<<<<< @@ -632,7 +614,7 @@ typedef npy_uint64 __pyx_t_5numpy_uint64_t; */ typedef npy_float32 __pyx_t_5numpy_float32_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":741 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":738 * * ctypedef npy_float32 float32_t * ctypedef npy_float64 float64_t # <<<<<<<<<<<<<< @@ -641,7 +623,7 @@ typedef npy_float32 __pyx_t_5numpy_float32_t; */ typedef npy_float64 __pyx_t_5numpy_float64_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":750 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":747 * # The int types are mapped a bit surprising -- * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t # <<<<<<<<<<<<<< @@ -650,7 +632,7 @@ typedef npy_float64 __pyx_t_5numpy_float64_t; */ typedef npy_long __pyx_t_5numpy_int_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":748 * # numpy.int corresponds to 'l' and numpy.long to 'q' * ctypedef npy_long int_t * ctypedef npy_longlong long_t # <<<<<<<<<<<<<< @@ -659,7 +641,7 @@ typedef npy_long __pyx_t_5numpy_int_t; */ typedef npy_longlong __pyx_t_5numpy_long_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":752 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":749 * ctypedef npy_long int_t * ctypedef npy_longlong long_t * ctypedef npy_longlong longlong_t # <<<<<<<<<<<<<< @@ -668,7 +650,7 @@ typedef npy_longlong __pyx_t_5numpy_long_t; */ typedef npy_longlong __pyx_t_5numpy_longlong_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":754 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":751 * ctypedef npy_longlong longlong_t * * ctypedef npy_ulong uint_t # <<<<<<<<<<<<<< @@ -677,7 +659,7 @@ typedef npy_longlong __pyx_t_5numpy_longlong_t; */ typedef npy_ulong __pyx_t_5numpy_uint_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":752 * * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t # <<<<<<<<<<<<<< @@ -686,7 +668,7 @@ typedef npy_ulong __pyx_t_5numpy_uint_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":756 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":753 * ctypedef npy_ulong uint_t * ctypedef npy_ulonglong ulong_t * ctypedef npy_ulonglong ulonglong_t # <<<<<<<<<<<<<< @@ -695,7 +677,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulong_t; */ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":755 * ctypedef npy_ulonglong ulonglong_t * * ctypedef npy_intp intp_t # <<<<<<<<<<<<<< @@ -704,7 +686,7 @@ typedef npy_ulonglong __pyx_t_5numpy_ulonglong_t; */ typedef npy_intp __pyx_t_5numpy_intp_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":759 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":756 * * ctypedef npy_intp intp_t * ctypedef npy_uintp uintp_t # <<<<<<<<<<<<<< @@ -713,7 +695,7 @@ typedef npy_intp __pyx_t_5numpy_intp_t; */ typedef npy_uintp __pyx_t_5numpy_uintp_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":761 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":758 * ctypedef npy_uintp uintp_t * * ctypedef npy_double float_t # <<<<<<<<<<<<<< @@ -722,7 +704,7 @@ typedef npy_uintp __pyx_t_5numpy_uintp_t; */ typedef npy_double __pyx_t_5numpy_float_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":759 * * ctypedef npy_double float_t * ctypedef npy_double double_t # <<<<<<<<<<<<<< @@ -731,7 +713,7 @@ typedef npy_double __pyx_t_5numpy_float_t; */ typedef npy_double __pyx_t_5numpy_double_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":763 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":760 * ctypedef npy_double float_t * ctypedef npy_double double_t * ctypedef npy_longdouble longdouble_t # <<<<<<<<<<<<<< @@ -784,7 +766,7 @@ struct __pyx_MemviewEnum_obj; struct __pyx_memoryview_obj; struct __pyx_memoryviewslice_obj; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":765 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":762 * ctypedef npy_longdouble longdouble_t * * ctypedef npy_cfloat cfloat_t # <<<<<<<<<<<<<< @@ -793,7 +775,7 @@ struct __pyx_memoryviewslice_obj; */ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":763 * * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t # <<<<<<<<<<<<<< @@ -802,7 +784,7 @@ typedef npy_cfloat __pyx_t_5numpy_cfloat_t; */ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":767 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":764 * ctypedef npy_cfloat cfloat_t * ctypedef npy_cdouble cdouble_t * ctypedef npy_clongdouble clongdouble_t # <<<<<<<<<<<<<< @@ -811,7 +793,7 @@ typedef npy_cdouble __pyx_t_5numpy_cdouble_t; */ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t; -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":769 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":766 * ctypedef npy_clongdouble clongdouble_t * * ctypedef npy_cdouble complex_t # <<<<<<<<<<<<<< @@ -880,7 +862,7 @@ struct __pyx_memoryview_obj { }; -/* "View.MemoryView":921 +/* "View.MemoryView":922 * * @cname('__pyx_memoryviewslice') * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< @@ -917,7 +899,7 @@ struct __pyx_vtabstruct_memoryview { static struct __pyx_vtabstruct_memoryview *__pyx_vtabptr_memoryview; -/* "View.MemoryView":921 +/* "View.MemoryView":922 * * @cname('__pyx_memoryviewslice') * cdef class _memoryviewslice(memoryview): # <<<<<<<<<<<<<< @@ -929,8 +911,6 @@ struct __pyx_vtabstruct__memoryviewslice { struct __pyx_vtabstruct_memoryview __pyx_base; }; static struct __pyx_vtabstruct__memoryviewslice *__pyx_vtabptr__memoryviewslice; - -/* --- Runtime support code (head) --- */ #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif @@ -1077,26 +1057,6 @@ static void __Pyx_WriteUnraisable(const char *name, int clineno, static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); -#if PY_MAJOR_VERSION >= 3 -static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) { - PyObject *value; - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (!PyErr_Occurred()) { - PyObject* args = PyTuple_Pack(1, key); - if (likely(args)) - PyErr_SetObject(PyExc_KeyError, args); - Py_XDECREF(args); - } - return NULL; - } - Py_INCREF(value); - return value; -} -#else - #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key) -#endif - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); @@ -1535,38 +1495,38 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_6backprop_gradient_par( static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_8backprop_gradient_par_c(CYTHON_UNUSED PyObject *__pyx_self, __Pyx_memviewslice __pyx_v_dL, __Pyx_memviewslice __pyx_v_L); /* proto */ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_self, Py_buffer *__pyx_v_info); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ -static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ -static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ -static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */ -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ -static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static int __pyx_array_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer); /* proto */ +static int __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static void __pyx_array_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *get_memview_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_array_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr); /* proto */ +static PyObject *__pyx_array_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item); /* proto */ +static int __pyx_array_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value); /* proto */ +static int __pyx_MemviewEnum_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ +static PyObject *__pyx_MemviewEnum_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self); /* proto */ +static int __pyx_memoryview_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object); /* proto */ +static void __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ +static int __pyx_memoryview_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value); /* proto */ +static int __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags); /* proto */ +static PyObject *__pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static Py_ssize_t __pyx_memoryview_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryview_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self); /* proto */ +static void __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ +static PyObject *__pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self); /* proto */ static PyObject *__pyx_tp_new_array(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_Enum(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ static PyObject *__pyx_tp_new_memoryview(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ @@ -1670,7 +1630,7 @@ static char __pyx_k_itemsize_0_for_cython_array[] = "itemsize <= 0 for cython.ar static char __pyx_k_ndarray_is_not_C_contiguous[] = "ndarray is not C contiguous"; static char __pyx_k_unable_to_allocate_array_data[] = "unable to allocate array data."; static char __pyx_k_strided_and_direct_or_indirect[] = ""; -static char __pyx_k_home_james_work_GPy_GPy_util_ch[] = "/home/james/work/GPy/GPy/util/choleskies_cython.pyx"; +static char __pyx_k_Users_james_work_GPy_GPy_util_c[] = "/Users/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_All_dimensions_preceding_dimensi[] = "All dimensions preceding dimension %d must be indexed and not sliced"; static char __pyx_k_Buffer_view_does_not_expose_stri[] = "Buffer view does not expose strides"; @@ -1713,6 +1673,7 @@ static PyObject *__pyx_kp_s_Out_of_bounds_on_buffer_access_a; static PyObject *__pyx_n_s_RuntimeError; static PyObject *__pyx_n_s_TypeError; static PyObject *__pyx_kp_s_Unable_to_convert_item_to_object; +static PyObject *__pyx_kp_s_Users_james_work_GPy_GPy_util_c; static PyObject *__pyx_n_s_ValueError; static PyObject *__pyx_n_s_allocate_buffer; static PyObject *__pyx_n_s_asarray; @@ -1741,7 +1702,6 @@ static PyObject *__pyx_n_s_format; static PyObject *__pyx_n_s_fortran; static PyObject *__pyx_n_u_fortran; static PyObject *__pyx_kp_s_got_differing_extents_in_dimensi; -static PyObject *__pyx_kp_s_home_james_work_GPy_GPy_util_ch; static PyObject *__pyx_n_s_i; static PyObject *__pyx_n_s_id; static PyObject *__pyx_n_s_import; @@ -1797,30 +1757,29 @@ static PyObject *__pyx_tuple__6; static PyObject *__pyx_tuple__7; static PyObject *__pyx_tuple__8; static PyObject *__pyx_tuple__9; +static PyObject *__pyx_slice__14; static PyObject *__pyx_slice__15; static PyObject *__pyx_slice__16; -static PyObject *__pyx_slice__17; static PyObject *__pyx_tuple__10; static PyObject *__pyx_tuple__11; static PyObject *__pyx_tuple__12; static PyObject *__pyx_tuple__13; -static PyObject *__pyx_tuple__14; +static PyObject *__pyx_tuple__17; static PyObject *__pyx_tuple__18; -static PyObject *__pyx_tuple__19; -static PyObject *__pyx_tuple__21; -static PyObject *__pyx_tuple__23; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__27; +static PyObject *__pyx_tuple__20; +static PyObject *__pyx_tuple__22; +static PyObject *__pyx_tuple__24; +static PyObject *__pyx_tuple__26; +static PyObject *__pyx_tuple__28; static PyObject *__pyx_tuple__29; static PyObject *__pyx_tuple__30; static PyObject *__pyx_tuple__31; static PyObject *__pyx_tuple__32; -static PyObject *__pyx_tuple__33; -static PyObject *__pyx_codeobj__20; -static PyObject *__pyx_codeobj__22; -static PyObject *__pyx_codeobj__24; -static PyObject *__pyx_codeobj__26; -static PyObject *__pyx_codeobj__28; +static PyObject *__pyx_codeobj__19; +static PyObject *__pyx_codeobj__21; +static PyObject *__pyx_codeobj__23; +static PyObject *__pyx_codeobj__25; +static PyObject *__pyx_codeobj__27; /* "GPy/util/choleskies_cython.pyx":12 * cimport scipy.linalg.cython_blas as cblas @@ -3074,7 +3033,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_6backprop_gradient_par( #define unlikely(x) (x) #endif #ifdef _OPENMP - #pragma omp parallel private(__pyx_t_12, __pyx_t_9, __pyx_t_15, __pyx_t_17, __pyx_t_10, __pyx_t_19, __pyx_t_16, __pyx_t_18, __pyx_t_24, __pyx_t_26, __pyx_t_8, __pyx_t_13, __pyx_t_14, __pyx_t_20, __pyx_t_22, __pyx_t_21, __pyx_t_11, __pyx_t_23, __pyx_t_25) + #pragma omp parallel private(__pyx_t_22, __pyx_t_18, __pyx_t_11, __pyx_t_23, __pyx_t_26, __pyx_t_8, __pyx_t_13, __pyx_t_17, __pyx_t_10, __pyx_t_20, __pyx_t_16, __pyx_t_21, __pyx_t_24, __pyx_t_25, __pyx_t_12, __pyx_t_9, __pyx_t_15, __pyx_t_14, __pyx_t_19) #endif /* _OPENMP */ { @@ -3093,7 +3052,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_6backprop_gradient_par( if (__pyx_t_11 > 0) { #ifdef _OPENMP - #pragma omp for lastprivate(__pyx_v_j) firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) + #pragma omp for firstprivate(__pyx_v_i) lastprivate(__pyx_v_i) lastprivate(__pyx_v_j) #endif /* _OPENMP */ for (__pyx_t_10 = 0; __pyx_t_10 < __pyx_t_11; __pyx_t_10++){ { @@ -3657,6 +3616,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_8backprop_gradient_par_ PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; __Pyx_memviewslice __pyx_t_6 = { 0, 0, { 0 }, { 0 }, { 0 } }; + __Pyx_memviewslice __pyx_t_7 = { 0, 0, { 0 }, { 0 }, { 0 } }; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -3749,12 +3709,12 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_8backprop_gradient_par_ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(__pyx_t_1); - if (unlikely(!__pyx_t_6.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyObject_to_MemoryviewSlice_d_dc_double(__pyx_t_1); + if (unlikely(!__pyx_t_7.memview)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_L_cont = __pyx_t_6; - __pyx_t_6.memview = NULL; - __pyx_t_6.data = NULL; + __pyx_v_L_cont = __pyx_t_7; + __pyx_t_7.memview = NULL; + __pyx_t_7.data = NULL; /* "GPy/util/choleskies_cython.pyx":111 * cdef double[:, ::1] dL_dK = np.tril(dL) # makes a copy, c-contig @@ -3865,6 +3825,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_8backprop_gradient_par_ __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __PYX_XDEC_MEMVIEW(&__pyx_t_6, 1); + __PYX_XDEC_MEMVIEW(&__pyx_t_7, 1); __Pyx_AddTraceback("GPy.util.choleskies_cython.backprop_gradient_par_c", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -3877,7 +3838,7 @@ static PyObject *__pyx_pf_3GPy_4util_17choleskies_cython_8backprop_gradient_par_ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":194 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -3927,7 +3888,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __Pyx_GIVEREF(__pyx_v_info->obj); } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":200 * # of flags * * if info == NULL: return # <<<<<<<<<<<<<< @@ -3940,7 +3901,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P goto __pyx_L0; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":203 * * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -3949,7 +3910,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_endian_detector = 1; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":207 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":204 * cdef int copy_shape, i, ndim * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -3958,7 +3919,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":206 * cdef bint little_endian = ((&endian_detector)[0] != 0) * * ndim = PyArray_NDIM(self) # <<<<<<<<<<<<<< @@ -3967,7 +3928,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_ndim = PyArray_NDIM(__pyx_v_self); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":208 * ndim = PyArray_NDIM(self) * * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -3977,7 +3938,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":212 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":209 * * if sizeof(npy_intp) != sizeof(Py_ssize_t): * copy_shape = 1 # <<<<<<<<<<<<<< @@ -3989,7 +3950,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":211 * copy_shape = 1 * else: * copy_shape = 0 # <<<<<<<<<<<<<< @@ -4000,7 +3961,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L4:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":216 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":213 * copy_shape = 0 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4009,12 +3970,14 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_C_CONTIGUOUS) == PyBUF_C_CONTIGUOUS) != 0); if (__pyx_t_2) { + goto __pyx_L7_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L6_bool_binop_done; } + __pyx_L7_next_and:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":214 * * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4026,21 +3989,21 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_L6_bool_binop_done:; if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":220 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":217 * raise ValueError(u"ndarray is not C contiguous") * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) # <<<<<<<<<<<<<< @@ -4049,12 +4012,14 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = (((__pyx_v_flags & PyBUF_F_CONTIGUOUS) == PyBUF_F_CONTIGUOUS) != 0); if (__pyx_t_2) { + goto __pyx_L10_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L9_bool_binop_done; } + __pyx_L10_next_and:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): # <<<<<<<<<<<<<< @@ -4066,21 +4031,21 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_L9_bool_binop_done:; if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":219 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":224 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":221 * raise ValueError(u"ndarray is not Fortran contiguous") * * info.buf = PyArray_DATA(self) # <<<<<<<<<<<<<< @@ -4089,7 +4054,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->buf = PyArray_DATA(__pyx_v_self); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":225 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 * * info.buf = PyArray_DATA(self) * info.ndim = ndim # <<<<<<<<<<<<<< @@ -4098,7 +4063,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->ndim = __pyx_v_ndim; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":223 * info.buf = PyArray_DATA(self) * info.ndim = ndim * if copy_shape: # <<<<<<<<<<<<<< @@ -4108,7 +4073,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = (__pyx_v_copy_shape != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":226 * # Allocate new buffer for strides and shape info. * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) # <<<<<<<<<<<<<< @@ -4117,7 +4082,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)malloc((((sizeof(Py_ssize_t)) * ((size_t)__pyx_v_ndim)) * 2))); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":227 * # This is allocated as one block, strides first. * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim # <<<<<<<<<<<<<< @@ -4126,7 +4091,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->shape = (__pyx_v_info->strides + __pyx_v_ndim); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":231 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":228 * info.strides = stdlib.malloc(sizeof(Py_ssize_t) * ndim * 2) * info.shape = info.strides + ndim * for i in range(ndim): # <<<<<<<<<<<<<< @@ -4137,7 +4102,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":229 * info.shape = info.strides + ndim * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] # <<<<<<<<<<<<<< @@ -4146,7 +4111,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->strides[__pyx_v_i]) = (PyArray_STRIDES(__pyx_v_self)[__pyx_v_i]); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":230 * for i in range(ndim): * info.strides[i] = PyArray_STRIDES(self)[i] * info.shape[i] = PyArray_DIMS(self)[i] # <<<<<<<<<<<<<< @@ -4159,7 +4124,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":232 * info.shape[i] = PyArray_DIMS(self)[i] * else: * info.strides = PyArray_STRIDES(self) # <<<<<<<<<<<<<< @@ -4168,7 +4133,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->strides = ((Py_ssize_t *)PyArray_STRIDES(__pyx_v_self)); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":233 * else: * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) # <<<<<<<<<<<<<< @@ -4179,7 +4144,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L11:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":237 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":234 * info.strides = PyArray_STRIDES(self) * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL # <<<<<<<<<<<<<< @@ -4188,7 +4153,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->suboffsets = NULL; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":238 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":235 * info.shape = PyArray_DIMS(self) * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) # <<<<<<<<<<<<<< @@ -4197,7 +4162,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->itemsize = PyArray_ITEMSIZE(__pyx_v_self); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":236 * info.suboffsets = NULL * info.itemsize = PyArray_ITEMSIZE(self) * info.readonly = not PyArray_ISWRITEABLE(self) # <<<<<<<<<<<<<< @@ -4206,7 +4171,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->readonly = (!(PyArray_ISWRITEABLE(__pyx_v_self) != 0)); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":242 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":239 * * cdef int t * cdef char* f = NULL # <<<<<<<<<<<<<< @@ -4215,7 +4180,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_f = NULL; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":243 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":240 * cdef int t * cdef char* f = NULL * cdef dtype descr = self.descr # <<<<<<<<<<<<<< @@ -4227,7 +4192,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_descr = ((PyArray_Descr *)__pyx_t_3); __pyx_t_3 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":247 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":244 * cdef int offset * * cdef bint hasfields = PyDataType_HASFIELDS(descr) # <<<<<<<<<<<<<< @@ -4236,7 +4201,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_hasfields = PyDataType_HASFIELDS(__pyx_v_descr); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":249 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":246 * cdef bint hasfields = PyDataType_HASFIELDS(descr) * * if not hasfields and not copy_shape: # <<<<<<<<<<<<<< @@ -4245,16 +4210,18 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_2) { + goto __pyx_L16_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L15_bool_binop_done; } + __pyx_L16_next_and:; __pyx_t_2 = ((!(__pyx_v_copy_shape != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L15_bool_binop_done:; if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":251 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":248 * if not hasfields and not copy_shape: * # do not call releasebuffer * info.obj = None # <<<<<<<<<<<<<< @@ -4270,7 +4237,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":254 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":251 * else: * # need to call releasebuffer * info.obj = self # <<<<<<<<<<<<<< @@ -4285,7 +4252,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } __pyx_L14:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":253 * info.obj = self * * if not hasfields: # <<<<<<<<<<<<<< @@ -4295,7 +4262,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_1 = ((!(__pyx_v_hasfields != 0)) != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":254 * * if not hasfields: * t = descr.type_num # <<<<<<<<<<<<<< @@ -4305,7 +4272,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_t_4 = __pyx_v_descr->type_num; __pyx_v_t = __pyx_t_4; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":255 * if not hasfields: * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -4316,16 +4283,19 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P if (!__pyx_t_2) { goto __pyx_L20_next_or; } else { + goto __pyx_L21_next_and; } + __pyx_L21_next_and:; __pyx_t_2 = (__pyx_v_little_endian != 0); if (!__pyx_t_2) { + goto __pyx_L20_next_or; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } __pyx_L20_next_or:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":256 * t = descr.type_num * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -4334,30 +4304,32 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_t_2 = ((__pyx_v_descr->byteorder == '<') != 0); if (__pyx_t_2) { + goto __pyx_L22_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L19_bool_binop_done; } + __pyx_L22_next_and:; __pyx_t_2 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_1 = __pyx_t_2; __pyx_L19_bool_binop_done:; if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -4366,7 +4338,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ switch (__pyx_v_t) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":258 * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" # <<<<<<<<<<<<<< @@ -4377,7 +4349,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_b; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":259 * raise ValueError(u"Non-native byte order not supported") * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" # <<<<<<<<<<<<<< @@ -4388,7 +4360,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_B; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" # <<<<<<<<<<<<<< @@ -4399,7 +4371,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_h; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":261 * elif t == NPY_UBYTE: f = "B" * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" # <<<<<<<<<<<<<< @@ -4410,7 +4382,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_H; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":262 * elif t == NPY_SHORT: f = "h" * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" # <<<<<<<<<<<<<< @@ -4421,7 +4393,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_i; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":263 * elif t == NPY_USHORT: f = "H" * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" # <<<<<<<<<<<<<< @@ -4432,7 +4404,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_I; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":264 * elif t == NPY_INT: f = "i" * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" # <<<<<<<<<<<<<< @@ -4443,7 +4415,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_l; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":265 * elif t == NPY_UINT: f = "I" * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" # <<<<<<<<<<<<<< @@ -4454,7 +4426,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_L; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":266 * elif t == NPY_LONG: f = "l" * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" # <<<<<<<<<<<<<< @@ -4465,7 +4437,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_q; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":267 * elif t == NPY_ULONG: f = "L" * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" # <<<<<<<<<<<<<< @@ -4476,7 +4448,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Q; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":268 * elif t == NPY_LONGLONG: f = "q" * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" # <<<<<<<<<<<<<< @@ -4487,7 +4459,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_f; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":269 * elif t == NPY_ULONGLONG: f = "Q" * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" # <<<<<<<<<<<<<< @@ -4498,7 +4470,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_d; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":270 * elif t == NPY_FLOAT: f = "f" * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" # <<<<<<<<<<<<<< @@ -4509,7 +4481,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_g; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":271 * elif t == NPY_DOUBLE: f = "d" * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" # <<<<<<<<<<<<<< @@ -4520,7 +4492,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zf; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":275 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":272 * elif t == NPY_LONGDOUBLE: f = "g" * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" # <<<<<<<<<<<<<< @@ -4531,7 +4503,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zd; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":273 * elif t == NPY_CFLOAT: f = "Zf" * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" # <<<<<<<<<<<<<< @@ -4542,7 +4514,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P __pyx_v_f = __pyx_k_Zg; break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":274 * elif t == NPY_CDOUBLE: f = "Zd" * elif t == NPY_CLONGDOUBLE: f = "Zg" * elif t == NPY_OBJECT: f = "O" # <<<<<<<<<<<<<< @@ -4554,33 +4526,33 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P break; default: - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":279 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":276 * elif t == NPY_OBJECT: f = "O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * info.format = f * return */ - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} break; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":277 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f # <<<<<<<<<<<<<< @@ -4589,7 +4561,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = __pyx_v_f; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":281 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":278 * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * info.format = f * return # <<<<<<<<<<<<<< @@ -4601,7 +4573,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":280 * return * else: * info.format = stdlib.malloc(_buffer_format_string_len) # <<<<<<<<<<<<<< @@ -4610,7 +4582,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_info->format = ((char *)malloc(255)); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":284 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":281 * else: * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment # <<<<<<<<<<<<<< @@ -4619,7 +4591,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ (__pyx_v_info->format[0]) = '^'; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":285 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":282 * info.format = stdlib.malloc(_buffer_format_string_len) * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 # <<<<<<<<<<<<<< @@ -4628,17 +4600,17 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P */ __pyx_v_offset = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":283 * info.format[0] = c'^' # Native data types, manual alignment * offset = 0 * f = _util_dtypestring(descr, info.format + 1, # <<<<<<<<<<<<<< * info.format + _buffer_format_string_len, * &offset) */ - __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 286; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __pyx_f_5numpy__util_dtypestring(__pyx_v_descr, (__pyx_v_info->format + 1), (__pyx_v_info->format + 255), (&__pyx_v_offset)); if (unlikely(__pyx_t_7 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_7; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":286 * info.format + _buffer_format_string_len, * &offset) * f[0] = c'\0' # Terminate format string # <<<<<<<<<<<<<< @@ -4648,7 +4620,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P (__pyx_v_f[0]) = '\x00'; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":197 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":194 * # experimental exception made for __getbuffer__ and __releasebuffer__ * # -- the details of this may change. * def __getbuffer__(ndarray self, Py_buffer* info, int flags): # <<<<<<<<<<<<<< @@ -4680,7 +4652,7 @@ static int __pyx_pf_5numpy_7ndarray___getbuffer__(PyArrayObject *__pyx_v_self, P return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -4704,7 +4676,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s int __pyx_t_1; __Pyx_RefNannySetupContext("__releasebuffer__", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":289 * * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): # <<<<<<<<<<<<<< @@ -4714,7 +4686,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (PyArray_HASFIELDS(__pyx_v_self) != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":293 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":290 * def __releasebuffer__(ndarray self, Py_buffer* info): * if PyArray_HASFIELDS(self): * stdlib.free(info.format) # <<<<<<<<<<<<<< @@ -4726,7 +4698,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s } __pyx_L3:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":294 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 * if PyArray_HASFIELDS(self): * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): # <<<<<<<<<<<<<< @@ -4736,7 +4708,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __pyx_t_1 = (((sizeof(npy_intp)) != (sizeof(Py_ssize_t))) != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":295 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":292 * stdlib.free(info.format) * if sizeof(npy_intp) != sizeof(Py_ssize_t): * stdlib.free(info.strides) # <<<<<<<<<<<<<< @@ -4748,7 +4720,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s } __pyx_L4:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":291 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":288 * f[0] = c'\0' # Terminate format string * * def __releasebuffer__(ndarray self, Py_buffer* info): # <<<<<<<<<<<<<< @@ -4760,7 +4732,7 @@ static void __pyx_pf_5numpy_7ndarray_2__releasebuffer__(PyArrayObject *__pyx_v_s __Pyx_RefNannyFinishContext(); } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -4777,7 +4749,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew1", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":772 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":769 * * cdef inline object PyArray_MultiIterNew1(a): * return PyArray_MultiIterNew(1, a) # <<<<<<<<<<<<<< @@ -4785,13 +4757,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ * cdef inline object PyArray_MultiIterNew2(a, b): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(1, ((void *)__pyx_v_a)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":768 * ctypedef npy_cdouble complex_t * * cdef inline object PyArray_MultiIterNew1(a): # <<<<<<<<<<<<<< @@ -4810,7 +4782,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew1(PyObject *__ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -4827,7 +4799,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew2", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":772 * * cdef inline object PyArray_MultiIterNew2(a, b): * return PyArray_MultiIterNew(2, a, b) # <<<<<<<<<<<<<< @@ -4835,13 +4807,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ * cdef inline object PyArray_MultiIterNew3(a, b, c): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(2, ((void *)__pyx_v_a), ((void *)__pyx_v_b)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":771 * return PyArray_MultiIterNew(1, a) * * cdef inline object PyArray_MultiIterNew2(a, b): # <<<<<<<<<<<<<< @@ -4860,7 +4832,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew2(PyObject *__ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -4877,7 +4849,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew3", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":775 * * cdef inline object PyArray_MultiIterNew3(a, b, c): * return PyArray_MultiIterNew(3, a, b, c) # <<<<<<<<<<<<<< @@ -4885,13 +4857,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ * cdef inline object PyArray_MultiIterNew4(a, b, c, d): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(3, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":774 * return PyArray_MultiIterNew(2, a, b) * * cdef inline object PyArray_MultiIterNew3(a, b, c): # <<<<<<<<<<<<<< @@ -4910,7 +4882,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew3(PyObject *__ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -4927,7 +4899,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew4", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":778 * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): * return PyArray_MultiIterNew(4, a, b, c, d) # <<<<<<<<<<<<<< @@ -4935,13 +4907,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(4, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":777 * return PyArray_MultiIterNew(3, a, b, c) * * cdef inline object PyArray_MultiIterNew4(a, b, c, d): # <<<<<<<<<<<<<< @@ -4960,7 +4932,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew4(PyObject *__ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -4977,7 +4949,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("PyArray_MultiIterNew5", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":784 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":781 * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): * return PyArray_MultiIterNew(5, a, b, c, d, e) # <<<<<<<<<<<<<< @@ -4985,13 +4957,13 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyArray_MultiIterNew(5, ((void *)__pyx_v_a), ((void *)__pyx_v_b), ((void *)__pyx_v_c), ((void *)__pyx_v_d), ((void *)__pyx_v_e)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":780 * return PyArray_MultiIterNew(4, a, b, c, d) * * cdef inline object PyArray_MultiIterNew5(a, b, c, d, e): # <<<<<<<<<<<<<< @@ -5010,7 +4982,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_PyArray_MultiIterNew5(PyObject *__ return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -5042,7 +5014,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_util_dtypestring", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":793 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":790 * cdef int delta_offset * cdef tuple i * cdef int endian_detector = 1 # <<<<<<<<<<<<<< @@ -5051,7 +5023,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_endian_detector = 1; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":791 * cdef tuple i * cdef int endian_detector = 1 * cdef bint little_endian = ((&endian_detector)[0] != 0) # <<<<<<<<<<<<<< @@ -5060,7 +5032,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_little_endian = ((((char *)(&__pyx_v_endian_detector))[0]) != 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":797 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -5069,37 +5041,33 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ if (unlikely(__pyx_v_descr->names == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = __pyx_v_descr->names; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_XDECREF_SET(__pyx_v_childname, __pyx_t_3); __pyx_t_3 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":795 * * for childname in descr.names: * fields = descr.fields[childname] # <<<<<<<<<<<<<< * child, new_offset = fields * */ - if (unlikely(__pyx_v_descr->fields == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_3 = __Pyx_PyDict_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PyObject_GetItem(__pyx_v_descr->fields, __pyx_v_childname); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __Pyx_GOTREF(__pyx_t_3); - if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyTuple_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_fields, ((PyObject*)__pyx_t_3)); __pyx_t_3 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":796 * for childname in descr.names: * fields = descr.fields[childname] * child, new_offset = fields # <<<<<<<<<<<<<< @@ -5116,7 +5084,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); @@ -5124,52 +5092,52 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); #else - __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); #endif } else { - __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5numpy_dtype))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 796; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XDECREF_SET(__pyx_v_child, ((PyArray_Descr *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_XDECREF_SET(__pyx_v_new_offset, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":798 * child, new_offset = fields * * if (end - f) - (new_offset - offset[0]) < 15: # <<<<<<<<<<<<<< * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * */ - __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_v_new_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_6 = ((((__pyx_v_end - __pyx_v_f) - ((int)__pyx_t_5)) < 15) != 0); if (__pyx_t_6) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":804 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":801 * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") * * if ((child.byteorder == c'>' and little_endian) or # <<<<<<<<<<<<<< @@ -5180,16 +5148,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx if (!__pyx_t_7) { goto __pyx_L8_next_or; } else { + goto __pyx_L9_next_and; } + __pyx_L9_next_and:; __pyx_t_7 = (__pyx_v_little_endian != 0); if (!__pyx_t_7) { + goto __pyx_L8_next_or; } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } __pyx_L8_next_or:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":805 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 * * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): # <<<<<<<<<<<<<< @@ -5198,30 +5169,32 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_t_7 = ((__pyx_v_child->byteorder == '<') != 0); if (__pyx_t_7) { + goto __pyx_L10_next_and; } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L7_bool_binop_done; } + __pyx_L10_next_and:; __pyx_t_7 = ((!(__pyx_v_little_endian != 0)) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L7_bool_binop_done:; if (__pyx_t_6) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":813 * * # Output padding bytes * while offset[0] < new_offset: # <<<<<<<<<<<<<< @@ -5229,15 +5202,15 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx * f += 1 */ while (1) { - __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_offset[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_new_offset, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (!__pyx_t_6) break; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":817 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":814 * # Output padding bytes * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte # <<<<<<<<<<<<<< @@ -5246,7 +5219,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ (__pyx_v_f[0]) = 120; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":815 * while offset[0] < new_offset: * f[0] = 120 # "x"; pad byte * f += 1 # <<<<<<<<<<<<<< @@ -5255,7 +5228,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx */ __pyx_v_f = (__pyx_v_f + 1); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":819 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":816 * f[0] = 120 # "x"; pad byte * f += 1 * offset[0] += 1 # <<<<<<<<<<<<<< @@ -5266,7 +5239,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + 1); } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":818 * offset[0] += 1 * * offset[0] += child.itemsize # <<<<<<<<<<<<<< @@ -5276,7 +5249,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_8 = 0; (__pyx_v_offset[__pyx_t_8]) = ((__pyx_v_offset[__pyx_t_8]) + __pyx_v_child->elsize); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":820 * offset[0] += child.itemsize * * if not PyDataType_HASFIELDS(child): # <<<<<<<<<<<<<< @@ -5286,19 +5259,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = ((!(PyDataType_HASFIELDS(__pyx_v_child) != 0)) != 0); if (__pyx_t_6) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":824 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":821 * * if not PyDataType_HASFIELDS(child): * t = child.type_num # <<<<<<<<<<<<<< * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") */ - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_child->type_num); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_t, __pyx_t_4); __pyx_t_4 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":825 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":822 * if not PyDataType_HASFIELDS(child): * t = child.type_num * if end - f < 5: # <<<<<<<<<<<<<< @@ -5308,266 +5281,266 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_t_6 = (((__pyx_v_end - __pyx_v_f) < 5) != 0); if (__pyx_t_6) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 * * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" # <<<<<<<<<<<<<< * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" */ - __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_BYTE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 98; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":827 * # Until ticket #99 is fixed, use integers to avoid warnings * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" # <<<<<<<<<<<<<< * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" */ - __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_UBYTE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 66; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":828 * if t == NPY_BYTE: f[0] = 98 #"b" * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" # <<<<<<<<<<<<<< * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" */ - __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_SHORT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 104; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":829 * elif t == NPY_UBYTE: f[0] = 66 #"B" * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" # <<<<<<<<<<<<<< * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" */ - __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_USHORT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 72; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":830 * elif t == NPY_SHORT: f[0] = 104 #"h" * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" # <<<<<<<<<<<<<< * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" */ - __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_INT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 105; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":831 * elif t == NPY_USHORT: f[0] = 72 #"H" * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" # <<<<<<<<<<<<<< * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" */ - __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_UINT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 73; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":832 * elif t == NPY_INT: f[0] = 105 #"i" * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" # <<<<<<<<<<<<<< * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" */ - __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_LONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 108; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":833 * elif t == NPY_UINT: f[0] = 73 #"I" * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" # <<<<<<<<<<<<<< * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" */ - __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_ULONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 76; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":834 * elif t == NPY_LONG: f[0] = 108 #"l" * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" # <<<<<<<<<<<<<< * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" */ - __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_LONGLONG); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 113; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":835 * elif t == NPY_ULONG: f[0] = 76 #"L" * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" # <<<<<<<<<<<<<< * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" */ - __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_ULONGLONG); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 81; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":836 * elif t == NPY_LONGLONG: f[0] = 113 #"q" * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" # <<<<<<<<<<<<<< * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" */ - __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_FLOAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 102; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":837 * elif t == NPY_ULONGLONG: f[0] = 81 #"Q" * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" # <<<<<<<<<<<<<< * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf */ - __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_DOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 100; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":838 * elif t == NPY_FLOAT: f[0] = 102 #"f" * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" # <<<<<<<<<<<<<< * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd */ - __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_LONGDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 103; goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":839 * elif t == NPY_DOUBLE: f[0] = 100 #"d" * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf # <<<<<<<<<<<<<< * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg */ - __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_CFLOAT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -5576,18 +5549,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":843 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":840 * elif t == NPY_LONGDOUBLE: f[0] = 103 #"g" * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd # <<<<<<<<<<<<<< * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" */ - __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_CDOUBLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -5596,18 +5569,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":841 * elif t == NPY_CFLOAT: f[0] = 90; f[1] = 102; f += 1 # Zf * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg # <<<<<<<<<<<<<< * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: */ - __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(NPY_CLONGDOUBLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_t, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 90; @@ -5616,18 +5589,18 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx goto __pyx_L15; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":842 * elif t == NPY_CDOUBLE: f[0] = 90; f[1] = 100; f += 1 # Zd * elif t == NPY_CLONGDOUBLE: f[0] = 90; f[1] = 103; f += 1 # Zg * elif t == NPY_OBJECT: f[0] = 79 #"O" # <<<<<<<<<<<<<< * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) */ - __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(NPY_OBJECT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_t, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 842; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_6) { (__pyx_v_f[0]) = 79; @@ -5635,30 +5608,30 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":847 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":844 * elif t == NPY_OBJECT: f[0] = 79 #"O" * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) # <<<<<<<<<<<<<< * f += 1 * else: */ - __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyUnicode_Format(__pyx_kp_u_unknown_dtype_code_in_numpy_pxd, __pyx_v_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L15:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":848 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":845 * else: * raise ValueError(u"unknown dtype code in numpy.pxd (%d)" % t) * f += 1 # <<<<<<<<<<<<<< @@ -5670,19 +5643,19 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":852 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":849 * # Cython ignores struct boundary information ("T{...}"), * # so don't output it * f = _util_dtypestring(child, f, end, offset) # <<<<<<<<<<<<<< * return f * */ - __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __pyx_f_5numpy__util_dtypestring(__pyx_v_child, __pyx_v_f, __pyx_v_end, __pyx_v_offset); if (unlikely(__pyx_t_9 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f = __pyx_t_9; } __pyx_L13:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":797 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":794 * cdef tuple fields * * for childname in descr.names: # <<<<<<<<<<<<<< @@ -5692,7 +5665,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":853 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":850 * # so don't output it * f = _util_dtypestring(child, f, end, offset) * return f # <<<<<<<<<<<<<< @@ -5702,7 +5675,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx __pyx_r = __pyx_v_f; goto __pyx_L0; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":786 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":783 * return PyArray_MultiIterNew(5, a, b, c, d, e) * * cdef inline char* _util_dtypestring(dtype descr, char* f, char* end, int* offset) except NULL: # <<<<<<<<<<<<<< @@ -5727,7 +5700,7 @@ static CYTHON_INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *__pyx return __pyx_r; } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -5742,7 +5715,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a int __pyx_t_2; __Pyx_RefNannySetupContext("set_array_base", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":968 * cdef inline void set_array_base(ndarray arr, object base): * cdef PyObject* baseptr * if base is None: # <<<<<<<<<<<<<< @@ -5753,7 +5726,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 * cdef PyObject* baseptr * if base is None: * baseptr = NULL # <<<<<<<<<<<<<< @@ -5765,7 +5738,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":971 * baseptr = NULL * else: * Py_INCREF(base) # important to do this before decref below! # <<<<<<<<<<<<<< @@ -5774,7 +5747,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_INCREF(__pyx_v_base); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":975 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":972 * else: * Py_INCREF(base) # important to do this before decref below! * baseptr = base # <<<<<<<<<<<<<< @@ -5785,7 +5758,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a } __pyx_L3:; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":973 * Py_INCREF(base) # important to do this before decref below! * baseptr = base * Py_XDECREF(arr.base) # <<<<<<<<<<<<<< @@ -5794,7 +5767,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ Py_XDECREF(__pyx_v_arr->base); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":974 * baseptr = base * Py_XDECREF(arr.base) * arr.base = baseptr # <<<<<<<<<<<<<< @@ -5803,7 +5776,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a */ __pyx_v_arr->base = __pyx_v_baseptr; - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":969 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":966 * * * cdef inline void set_array_base(ndarray arr, object base): # <<<<<<<<<<<<<< @@ -5815,7 +5788,7 @@ static CYTHON_INLINE void __pyx_f_5numpy_set_array_base(PyArrayObject *__pyx_v_a __Pyx_RefNannyFinishContext(); } -/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 +/* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -5829,7 +5802,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py int __pyx_t_1; __Pyx_RefNannySetupContext("get_array_base", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":977 * * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: # <<<<<<<<<<<<<< @@ -5839,7 +5812,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py __pyx_t_1 = ((__pyx_v_arr->base == NULL) != 0); if (__pyx_t_1) { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":981 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":978 * cdef inline object get_array_base(ndarray arr): * if arr.base is NULL: * return None # <<<<<<<<<<<<<< @@ -5853,7 +5826,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py } /*else*/ { - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":983 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":980 * return None * else: * return arr.base # <<<<<<<<<<<<<< @@ -5864,7 +5837,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5numpy_get_array_base(PyArrayObject *__py goto __pyx_L0; } - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":979 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":976 * arr.base = baseptr * * cdef inline object get_array_base(ndarray arr): # <<<<<<<<<<<<<< @@ -5987,7 +5960,7 @@ static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, P if (unlikely(((PyObject *)__pyx_v_format) == Py_None)) { PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "format"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); + __pyx_r = __pyx_array_MemoryView_5array___cinit__(((struct __pyx_array_obj *)__pyx_v_self), __pyx_v_shape, __pyx_v_itemsize, __pyx_v_format, __pyx_v_mode, __pyx_v_allocate_buffer); /* "View.MemoryView":116 * cdef bint dtype_is_object @@ -6006,7 +5979,7 @@ static int __pyx_array___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, P return __pyx_r; } -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { +static int __pyx_array_MemoryView_5array___cinit__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_shape, Py_ssize_t __pyx_v_itemsize, PyObject *__pyx_v_format, PyObject *__pyx_v_mode, int __pyx_v_allocate_buffer) { int __pyx_v_idx; Py_ssize_t __pyx_v_i; Py_ssize_t __pyx_v_dim; @@ -6563,14 +6536,14 @@ static CYTHON_UNUSED int __pyx_array_getbuffer(PyObject *__pyx_v_self, Py_buffer int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __pyx_r = __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(((struct __pyx_array_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { +static int __pyx_array_getbuffer_MemoryView_5array_2__getbuffer__(struct __pyx_array_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_v_bufmode; int __pyx_r; __Pyx_RefNannyDeclarations @@ -6836,13 +6809,13 @@ static void __pyx_array___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_array___dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); + __pyx_array_MemoryView_5array_4__dealloc__(((struct __pyx_array_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } -static void __pyx_array___pyx_pf_15View_dot_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { +static void __pyx_array_MemoryView_5array_4__dealloc__(struct __pyx_array_obj *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); @@ -6947,14 +6920,14 @@ static PyObject *get_memview(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); + __pyx_r = get_memview_MemoryView_5array_7memview___get__(((struct __pyx_array_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { +static PyObject *get_memview_MemoryView_5array_7memview___get__(struct __pyx_array_obj *__pyx_v_self) { int __pyx_v_flags; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -7040,14 +7013,14 @@ static PyObject *__pyx_array___getattr__(PyObject *__pyx_v_self, PyObject *__pyx PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getattr__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); + __pyx_r = __pyx_array_MemoryView_5array_6__getattr__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_attr)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { +static PyObject *__pyx_array_MemoryView_5array_6__getattr__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_attr) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7108,14 +7081,14 @@ static PyObject *__pyx_array___getitem__(PyObject *__pyx_v_self, PyObject *__pyx PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); + __pyx_r = __pyx_array_MemoryView_5array_8__getitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_array___pyx_pf_15View_dot_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { +static PyObject *__pyx_array_MemoryView_5array_8__getitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7176,14 +7149,14 @@ static int __pyx_array___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_ite int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); + __pyx_r = __pyx_array_MemoryView_5array_10__setitem__(((struct __pyx_array_obj *)__pyx_v_self), ((PyObject *)__pyx_v_item), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_array___pyx_pf_15View_dot_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { +static int __pyx_array_MemoryView_5array_10__setitem__(struct __pyx_array_obj *__pyx_v_self, PyObject *__pyx_v_item, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7444,14 +7417,14 @@ static int __pyx_MemviewEnum___init__(PyObject *__pyx_v_self, PyObject *__pyx_ar __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); + __pyx_r = __pyx_MemviewEnum_MemoryView_4Enum___init__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self), __pyx_v_name); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { +static int __pyx_MemviewEnum_MemoryView_4Enum___init__(struct __pyx_MemviewEnum_obj *__pyx_v_self, PyObject *__pyx_v_name) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); @@ -7497,14 +7470,14 @@ static PyObject *__pyx_MemviewEnum___repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); + __pyx_r = __pyx_MemviewEnum_MemoryView_4Enum_2__repr__(((struct __pyx_MemviewEnum_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_MemviewEnum___pyx_pf_15View_dot_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { +static PyObject *__pyx_MemviewEnum_MemoryView_4Enum_2__repr__(struct __pyx_MemviewEnum_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__", 0); @@ -7690,14 +7663,14 @@ static int __pyx_memoryview___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_ar __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview___cinit__(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_obj, __pyx_v_flags, __pyx_v_dtype_is_object); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { +static int __pyx_memoryview_MemoryView_10memoryview___cinit__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_obj, int __pyx_v_flags, int __pyx_v_dtype_is_object) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -7743,10 +7716,12 @@ static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview___cinit_ __pyx_t_2 = (((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))) == ((PyObject *)((PyObject *)__pyx_memoryview_type))); __pyx_t_3 = (__pyx_t_2 != 0); if (!__pyx_t_3) { + goto __pyx_L5_next_or; } else { __pyx_t_1 = __pyx_t_3; goto __pyx_L4_bool_binop_done; } + __pyx_L5_next_or:; __pyx_t_3 = (__pyx_v_obj != Py_None); __pyx_t_2 = (__pyx_t_3 != 0); __pyx_t_1 = __pyx_t_2; @@ -7916,13 +7891,13 @@ static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_memoryview___dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } -static void __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { +static void __pyx_memoryview_MemoryView_10memoryview_2__dealloc__(struct __pyx_memoryview_obj *__pyx_v_self) { __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; @@ -8135,14 +8110,14 @@ static PyObject *__pyx_memoryview___getitem__(PyObject *__pyx_v_self, PyObject * PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_4__getitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_4__getitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index) { PyObject *__pyx_v_have_slices = NULL; PyObject *__pyx_v_indices = NULL; char *__pyx_v_itemp; @@ -8312,14 +8287,14 @@ static int __pyx_memoryview___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_ int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_6__setitem__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((PyObject *)__pyx_v_index), ((PyObject *)__pyx_v_value)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { +static int __pyx_memoryview_MemoryView_10memoryview_6__setitem__(struct __pyx_memoryview_obj *__pyx_v_self, PyObject *__pyx_v_index, PyObject *__pyx_v_value) { PyObject *__pyx_v_have_slices = NULL; PyObject *__pyx_v_obj = NULL; int __pyx_r; @@ -9525,14 +9500,14 @@ static CYTHON_UNUSED int __pyx_memoryview_getbuffer(PyObject *__pyx_v_self, Py_b int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getbuffer__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); + __pyx_r = __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(((struct __pyx_memoryview_obj *)__pyx_v_self), ((Py_buffer *)__pyx_v_info), ((int)__pyx_v_flags)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { +static int __pyx_memoryview_getbuffer_MemoryView_10memoryview_8__getbuffer__(struct __pyx_memoryview_obj *__pyx_v_self, Py_buffer *__pyx_v_info, int __pyx_v_flags) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -9777,14 +9752,14 @@ static PyObject *__pyx_memoryview_transpose(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_transpose_MemoryView_10memoryview_1T___get__(struct __pyx_memoryview_obj *__pyx_v_self) { struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -9863,14 +9838,14 @@ static PyObject *__pyx_memoryview__get__base(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview__get__base_MemoryView_10memoryview_4base___get__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); @@ -9906,7 +9881,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4base___get__(struc * property shape: * @cname('__pyx_memoryview_get_shape') * def __get__(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * return tuple([self.view.shape[i] for i in xrange(self.view.ndim)]) * */ @@ -9916,22 +9891,21 @@ static PyObject *__pyx_memoryview_get_shape(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_length; +static PyObject *__pyx_memoryview_get_shape_MemoryView_10memoryview_5shape___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - PyObject *__pyx_t_5 = NULL; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -9940,41 +9914,40 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_5shape___get__(stru /* "View.MemoryView":514 * @cname('__pyx_memoryview_get_shape') * def __get__(self): - * return tuple([length for length in self.view.shape[:self.view.ndim]]) # <<<<<<<<<<<<<< + * return tuple([self.view.shape[i] for i in xrange(self.view.ndim)]) # <<<<<<<<<<<<<< * * property strides: */ __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_4 = __pyx_v_self->view.shape; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) { - __pyx_t_2 = __pyx_t_4; - __pyx_v_length = (__pyx_t_2[0]); - __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_2 = __pyx_v_self->view.ndim; + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; + __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_self->view.shape[__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } - __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyList_AsTuple(((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; goto __pyx_L0; /* "View.MemoryView":513 * property shape: * @cname('__pyx_memoryview_get_shape') * def __get__(self): # <<<<<<<<<<<<<< - * return tuple([length for length in self.view.shape[:self.view.ndim]]) + * return tuple([self.view.shape[i] for i in xrange(self.view.ndim)]) * */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("View.MemoryView.memoryview.shape.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -9997,23 +9970,22 @@ static PyObject *__pyx_memoryview_get_strides(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_stride; +static PyObject *__pyx_memoryview_get_strides_MemoryView_10memoryview_7strides___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -10034,7 +10006,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + * return tuple([self.view.strides[i] for i in xrange(self.view.ndim)]) */ __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__13, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); @@ -10046,27 +10018,26 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st /* "View.MemoryView":523 * raise ValueError("Buffer view does not expose strides") * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) # <<<<<<<<<<<<<< + * return tuple([self.view.strides[i] for i in xrange(self.view.ndim)]) # <<<<<<<<<<<<<< * * property suboffsets: */ __Pyx_XDECREF(__pyx_r); __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = (__pyx_v_self->view.strides + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.strides; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_v_stride = (__pyx_t_3[0]); - __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_stride); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_6))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_3 = __pyx_v_self->view.ndim; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_self->view.strides[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } - __pyx_t_6 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; /* "View.MemoryView":518 @@ -10080,7 +10051,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("View.MemoryView.memoryview.strides.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -10094,7 +10065,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_7strides___get__(st * @cname('__pyx_memoryview_get_suboffsets') * def __get__(self): # <<<<<<<<<<<<<< * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim + * return [-1] * self.view.ndim */ /* Python wrapper */ @@ -10103,23 +10074,22 @@ static PyObject *__pyx_memoryview_get_suboffsets(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { - Py_ssize_t __pyx_v_suboffset; +static PyObject *__pyx_memoryview_get_suboffsets_MemoryView_10memoryview_10suboffsets___get__(struct __pyx_memoryview_obj *__pyx_v_self) { + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - Py_ssize_t *__pyx_t_6; + int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -10129,7 +10099,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ * @cname('__pyx_memoryview_get_suboffsets') * def __get__(self): * if self.view.suboffsets == NULL: # <<<<<<<<<<<<<< - * return (-1,) * self.view.ndim + * return [-1] * self.view.ndim * */ __pyx_t_1 = ((__pyx_v_self->view.suboffsets == NULL) != 0); @@ -10138,45 +10108,48 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ /* "View.MemoryView":529 * def __get__(self): * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< + * return [-1] * self.view.ndim # <<<<<<<<<<<<<< * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) + * return tuple([self.view.suboffsets[i] for i in xrange(self.view.ndim)]) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_self->view.ndim); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(1 * ((__pyx_v_self->view.ndim<0) ? 0:__pyx_v_self->view.ndim)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Multiply(__pyx_tuple__14, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; + { Py_ssize_t __pyx_temp; + for (__pyx_temp=0; __pyx_temp < __pyx_v_self->view.ndim; __pyx_temp++) { + __Pyx_INCREF(__pyx_int_neg_1); + PyList_SET_ITEM(__pyx_t_2, __pyx_temp, __pyx_int_neg_1); + __Pyx_GIVEREF(__pyx_int_neg_1); + } + } + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; } /* "View.MemoryView":531 - * return (-1,) * self.view.ndim + * return [-1] * self.view.ndim * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) # <<<<<<<<<<<<<< + * return tuple([self.view.suboffsets[i] for i in xrange(self.view.ndim)]) # <<<<<<<<<<<<<< * * property ndim: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = (__pyx_v_self->view.suboffsets + __pyx_v_self->view.ndim); - for (__pyx_t_6 = __pyx_v_self->view.suboffsets; __pyx_t_6 < __pyx_t_5; __pyx_t_6++) { - __pyx_t_4 = __pyx_t_6; - __pyx_v_suboffset = (__pyx_t_4[0]); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_suboffset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_t_2 = PyList_AsTuple(((PyObject*)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_3 = __pyx_v_self->view.ndim; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; + __pyx_t_5 = PyInt_FromSsize_t((__pyx_v_self->view.suboffsets[__pyx_v_i])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + if (unlikely(__Pyx_ListComp_Append(__pyx_t_2, (PyObject*)__pyx_t_5))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + } + __pyx_t_5 = PyList_AsTuple(((PyObject*)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 531; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_r = __pyx_t_5; + __pyx_t_5 = 0; goto __pyx_L0; /* "View.MemoryView":527 @@ -10184,13 +10157,13 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_10suboffsets___get_ * @cname('__pyx_memoryview_get_suboffsets') * def __get__(self): # <<<<<<<<<<<<<< * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim + * return [-1] * self.view.ndim */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("View.MemoryView.memoryview.suboffsets.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -10213,14 +10186,14 @@ static PyObject *__pyx_memoryview_get_ndim(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_get_ndim_MemoryView_10memoryview_4ndim___get__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10276,14 +10249,14 @@ static PyObject *__pyx_memoryview_get_itemsize(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_get_itemsize_MemoryView_10memoryview_8itemsize___get__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10339,14 +10312,14 @@ static PyObject *__pyx_memoryview_get_nbytes(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_get_nbytes_MemoryView_10memoryview_6nbytes___get__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10412,24 +10385,24 @@ static PyObject *__pyx_memoryview_get_size(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_get_size_MemoryView_10memoryview_4size___get__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_v_result = NULL; PyObject *__pyx_v_length = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; - Py_ssize_t *__pyx_t_3; - Py_ssize_t *__pyx_t_4; - Py_ssize_t *__pyx_t_5; - PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + Py_ssize_t __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -10451,7 +10424,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struc * if self._size is None: * result = 1 # <<<<<<<<<<<<<< * - * for length in self.view.shape[:self.view.ndim]: + * for length in self.shape: */ __Pyx_INCREF(__pyx_int_1); __pyx_v_result = __pyx_int_1; @@ -10459,30 +10432,74 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struc /* "View.MemoryView":554 * result = 1 * - * for length in self.view.shape[:self.view.ndim]: # <<<<<<<<<<<<<< + * for length in self.shape: # <<<<<<<<<<<<<< * result *= length * */ - __pyx_t_4 = (__pyx_v_self->view.shape + __pyx_v_self->view.ndim); - for (__pyx_t_5 = __pyx_v_self->view.shape; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) { - __pyx_t_3 = __pyx_t_5; - __pyx_t_6 = PyInt_FromSsize_t((__pyx_t_3[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_6); - __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_shape); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (likely(!__pyx_t_6)) { + if (likely(PyList_CheckExact(__pyx_t_4))) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } else { + if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + } + } else { + __pyx_t_3 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_3)) { + 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[2]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_3); + __pyx_t_3 = 0; /* "View.MemoryView":555 * - * for length in self.view.shape[:self.view.ndim]: + * for length in self.shape: * result *= length # <<<<<<<<<<<<<< * * self._size = result */ - __pyx_t_6 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_6); - __pyx_t_6 = 0; + __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_v_result, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF_SET(__pyx_v_result, __pyx_t_3); + __pyx_t_3 = 0; + + /* "View.MemoryView":554 + * result = 1 + * + * for length in self.shape: # <<<<<<<<<<<<<< + * result *= length + * + */ } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "View.MemoryView":557 * result *= length @@ -10522,7 +10539,8 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_10memoryview_4size___get__(struc /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("View.MemoryView.memoryview.size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -10547,14 +10565,14 @@ static Py_ssize_t __pyx_memoryview___len__(PyObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_10__len__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static Py_ssize_t __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { +static Py_ssize_t __pyx_memoryview_MemoryView_10memoryview_10__len__(struct __pyx_memoryview_obj *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -10619,14 +10637,14 @@ static PyObject *__pyx_memoryview___repr__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_12__repr__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_12__repr__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10727,14 +10745,14 @@ static PyObject *__pyx_memoryview___str__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_14__str__(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_14__str__(struct __pyx_memoryview_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10806,14 +10824,14 @@ static PyObject *__pyx_memoryview_is_c_contig(PyObject *__pyx_v_self, CYTHON_UNU PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_c_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_16is_c_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_16is_c_contig(struct __pyx_memoryview_obj *__pyx_v_self) { __Pyx_memviewslice *__pyx_v_mslice; __Pyx_memviewslice __pyx_v_tmp; PyObject *__pyx_r = NULL; @@ -10880,14 +10898,14 @@ static PyObject *__pyx_memoryview_is_f_contig(PyObject *__pyx_v_self, CYTHON_UNU PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("is_f_contig (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_18is_f_contig(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_18is_f_contig(struct __pyx_memoryview_obj *__pyx_v_self) { __Pyx_memviewslice *__pyx_v_mslice; __Pyx_memviewslice __pyx_v_tmp; PyObject *__pyx_r = NULL; @@ -10954,14 +10972,14 @@ static PyObject *__pyx_memoryview_copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyO PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("copy (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_20copy(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_20copy(struct __pyx_memoryview_obj *__pyx_v_self) { __Pyx_memviewslice __pyx_v_mslice; int __pyx_v_flags; PyObject *__pyx_r = NULL; @@ -11048,14 +11066,14 @@ static PyObject *__pyx_memoryview_copy_fortran(PyObject *__pyx_v_self, CYTHON_UN PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("copy_fortran (wrapper)", 0); - __pyx_r = __pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryview_MemoryView_10memoryview_22copy_fortran(((struct __pyx_memoryview_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_memoryview___pyx_pf_15View_dot_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { +static PyObject *__pyx_memoryview_MemoryView_10memoryview_22copy_fortran(struct __pyx_memoryview_obj *__pyx_v_self) { __Pyx_memviewslice __pyx_v_src; __Pyx_memviewslice __pyx_v_dst; int __pyx_v_flags; @@ -11453,9 +11471,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_7); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < ((__pyx_v_ndim - __pyx_t_8) + 1); __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__15); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__15); - __Pyx_GIVEREF(__pyx_slice__15); + __Pyx_INCREF(__pyx_slice__14); + PyList_SET_ITEM(__pyx_t_7, __pyx_temp, __pyx_slice__14); + __Pyx_GIVEREF(__pyx_slice__14); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_7); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -11480,7 +11498,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * have_slices = True * else: */ - __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__16); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyList_Append(__pyx_v_result, __pyx_slice__15); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L7:; @@ -11506,10 +11524,12 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __pyx_t_2 = PySlice_Check(__pyx_v_item); __pyx_t_10 = ((!(__pyx_t_2 != 0)) != 0); if (__pyx_t_10) { + goto __pyx_L10_next_and; } else { __pyx_t_1 = __pyx_t_10; goto __pyx_L9_bool_binop_done; } + __pyx_L10_next_and:; __pyx_t_10 = ((!(PyIndex_Check(__pyx_v_item) != 0)) != 0); __pyx_t_1 = __pyx_t_10; __pyx_L9_bool_binop_done:; @@ -11546,10 +11566,12 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { */ __pyx_t_10 = (__pyx_v_have_slices != 0); if (!__pyx_t_10) { + goto __pyx_L12_next_or; } else { __pyx_t_1 = __pyx_t_10; goto __pyx_L11_bool_binop_done; } + __pyx_L12_next_or:; __pyx_t_10 = PySlice_Check(__pyx_v_item); __pyx_t_2 = (__pyx_t_10 != 0); __pyx_t_1 = __pyx_t_2; @@ -11609,9 +11631,9 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __Pyx_GOTREF(__pyx_t_3); { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < __pyx_v_nslices; __pyx_temp++) { - __Pyx_INCREF(__pyx_slice__17); - PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__17); - __Pyx_GIVEREF(__pyx_slice__17); + __Pyx_INCREF(__pyx_slice__16); + PyList_SET_ITEM(__pyx_t_3, __pyx_temp, __pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); } } __pyx_t_9 = __Pyx_PyList_Extend(__pyx_v_result, __pyx_t_3); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -11629,6 +11651,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { */ __Pyx_XDECREF(__pyx_r); if (!__pyx_v_have_slices) { + goto __pyx_L15_next_or; } else { __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_v_have_slices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); @@ -11636,6 +11659,7 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { __pyx_t_4 = 0; goto __pyx_L14_bool_binop_done; } + __pyx_L15_next_or:; __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_nslices); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __pyx_t_4; @@ -11685,58 +11709,56 @@ static PyObject *_unellipsify(PyObject *__pyx_v_index, int __pyx_v_ndim) { * return have_slices or nslices, tuple(result) * * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + * cdef int i + * for i in range(ndim): */ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __pyx_v_ndim) { - Py_ssize_t __pyx_v_suboffset; + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t *__pyx_t_1; - Py_ssize_t *__pyx_t_2; - Py_ssize_t *__pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("assert_direct_dimensions", 0); - /* "View.MemoryView":657 - * + /* "View.MemoryView":658 * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: + * cdef int i + * for i in range(ndim): # <<<<<<<<<<<<<< + * if suboffsets[i] >= 0: * raise ValueError("Indirect dimensions not supported") */ - __pyx_t_2 = (__pyx_v_suboffsets + __pyx_v_ndim); - for (__pyx_t_3 = __pyx_v_suboffsets; __pyx_t_3 < __pyx_t_2; __pyx_t_3++) { - __pyx_t_1 = __pyx_t_3; - __pyx_v_suboffset = (__pyx_t_1[0]); + __pyx_t_1 = __pyx_v_ndim; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_v_i = __pyx_t_2; - /* "View.MemoryView":658 - * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< + /* "View.MemoryView":659 + * cdef int i + * for i in range(ndim): + * if suboffsets[i] >= 0: # <<<<<<<<<<<<<< * raise ValueError("Indirect dimensions not supported") * */ - __pyx_t_4 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_4) { + __pyx_t_3 = (((__pyx_v_suboffsets[__pyx_v_i]) >= 0) != 0); + if (__pyx_t_3) { - /* "View.MemoryView":659 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + /* "View.MemoryView":660 + * for i in range(ndim): + * if suboffsets[i] >= 0: * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< * * */ - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_Raise(__pyx_t_4, 0, 0, 0); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } @@ -11744,15 +11766,15 @@ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __ * return have_slices or nslices, tuple(result) * * cdef assert_direct_dimensions(Py_ssize_t *suboffsets, int ndim): # <<<<<<<<<<<<<< - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + * cdef int i + * for i in range(ndim): */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("View.MemoryView.assert_direct_dimensions", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; @@ -11761,7 +11783,7 @@ static PyObject *assert_direct_dimensions(Py_ssize_t *__pyx_v_suboffsets, int __ return __pyx_r; } -/* "View.MemoryView":666 +/* "View.MemoryView":667 * * @cname('__pyx_memview_slice') * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< @@ -11805,7 +11827,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("memview_slice", 0); - /* "View.MemoryView":667 + /* "View.MemoryView":668 * @cname('__pyx_memview_slice') * cdef memoryview memview_slice(memoryview memview, object indices): * cdef int new_ndim = 0, suboffset_dim = -1, dim # <<<<<<<<<<<<<< @@ -11815,7 +11837,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_v_new_ndim = 0; __pyx_v_suboffset_dim = -1; - /* "View.MemoryView":674 + /* "View.MemoryView":675 * * * memset(&dst, 0, sizeof(dst)) # <<<<<<<<<<<<<< @@ -11824,7 +11846,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ memset((&__pyx_v_dst), 0, (sizeof(__pyx_v_dst))); - /* "View.MemoryView":678 + /* "View.MemoryView":679 * cdef _memoryviewslice memviewsliceobj * * assert memview.view.ndim > 0 # <<<<<<<<<<<<<< @@ -11835,12 +11857,12 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ if (unlikely(!Py_OptimizeFlag)) { if (unlikely(!((__pyx_v_memview->view.ndim > 0) != 0))) { PyErr_SetNone(PyExc_AssertionError); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } #endif - /* "View.MemoryView":680 + /* "View.MemoryView":681 * assert memview.view.ndim > 0 * * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< @@ -11851,20 +11873,20 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "View.MemoryView":681 + /* "View.MemoryView":682 * * if isinstance(memview, _memoryviewslice): * memviewsliceobj = memview # <<<<<<<<<<<<<< * p_src = &memviewsliceobj.from_slice * else: */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 682; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = ((PyObject *)__pyx_v_memview); __Pyx_INCREF(__pyx_t_3); __pyx_v_memviewsliceobj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":682 + /* "View.MemoryView":683 * if isinstance(memview, _memoryviewslice): * memviewsliceobj = memview * p_src = &memviewsliceobj.from_slice # <<<<<<<<<<<<<< @@ -11876,7 +11898,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ } /*else*/ { - /* "View.MemoryView":684 + /* "View.MemoryView":685 * p_src = &memviewsliceobj.from_slice * else: * slice_copy(memview, &src) # <<<<<<<<<<<<<< @@ -11885,7 +11907,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_src)); - /* "View.MemoryView":685 + /* "View.MemoryView":686 * else: * slice_copy(memview, &src) * p_src = &src # <<<<<<<<<<<<<< @@ -11896,7 +11918,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ } __pyx_L3:; - /* "View.MemoryView":691 + /* "View.MemoryView":692 * * * dst.memview = p_src.memview # <<<<<<<<<<<<<< @@ -11906,7 +11928,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_4 = __pyx_v_p_src->memview; __pyx_v_dst.memview = __pyx_t_4; - /* "View.MemoryView":692 + /* "View.MemoryView":693 * * dst.memview = p_src.memview * dst.data = p_src.data # <<<<<<<<<<<<<< @@ -11916,7 +11938,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_5 = __pyx_v_p_src->data; __pyx_v_dst.data = __pyx_t_5; - /* "View.MemoryView":697 + /* "View.MemoryView":698 * * * cdef __Pyx_memviewslice *p_dst = &dst # <<<<<<<<<<<<<< @@ -11925,7 +11947,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ __pyx_v_p_dst = (&__pyx_v_dst); - /* "View.MemoryView":698 + /* "View.MemoryView":699 * * cdef __Pyx_memviewslice *p_dst = &dst * cdef int *p_suboffset_dim = &suboffset_dim # <<<<<<<<<<<<<< @@ -11934,7 +11956,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ __pyx_v_p_suboffset_dim = (&__pyx_v_suboffset_dim); - /* "View.MemoryView":702 + /* "View.MemoryView":703 * cdef bint have_start, have_stop, have_step * * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< @@ -11946,25 +11968,25 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_3 = __pyx_v_indices; __Pyx_INCREF(__pyx_t_3); __pyx_t_7 = 0; __pyx_t_8 = NULL; } else { - __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_indices); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } for (;;) { if (likely(!__pyx_t_8)) { if (likely(PyList_CheckExact(__pyx_t_3))) { if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_7); __Pyx_INCREF(__pyx_t_9); __pyx_t_7++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PySequence_ITEM(__pyx_t_3, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } } else { @@ -11973,7 +11995,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ 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[2]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -11984,7 +12006,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_v_dim = __pyx_t_6; __pyx_t_6 = (__pyx_t_6 + 1); - /* "View.MemoryView":703 + /* "View.MemoryView":704 * * for dim, index in enumerate(indices): * if PyIndex_Check(index): # <<<<<<<<<<<<<< @@ -11994,27 +12016,27 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_2 = (PyIndex_Check(__pyx_v_index) != 0); if (__pyx_t_2) { - /* "View.MemoryView":707 + /* "View.MemoryView":708 * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], * dim, new_ndim, p_suboffset_dim, * index, 0, 0, # start, stop, step # <<<<<<<<<<<<<< * 0, 0, 0, # have_{start,stop,step} * False) */ - __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_index); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "View.MemoryView":704 + /* "View.MemoryView":705 * for dim, index in enumerate(indices): * if PyIndex_Check(index): * slice_memviewslice( # <<<<<<<<<<<<<< * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], * dim, new_ndim, p_suboffset_dim, */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_t_10, 0, 0, 0, 0, 0, 0); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } - /* "View.MemoryView":710 + /* "View.MemoryView":711 * 0, 0, 0, # have_{start,stop,step} * False) * elif index is None: # <<<<<<<<<<<<<< @@ -12025,7 +12047,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_1 = (__pyx_t_2 != 0); if (__pyx_t_1) { - /* "View.MemoryView":711 + /* "View.MemoryView":712 * False) * elif index is None: * p_dst.shape[new_ndim] = 1 # <<<<<<<<<<<<<< @@ -12034,7 +12056,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ (__pyx_v_p_dst->shape[__pyx_v_new_ndim]) = 1; - /* "View.MemoryView":712 + /* "View.MemoryView":713 * elif index is None: * p_dst.shape[new_ndim] = 1 * p_dst.strides[new_ndim] = 0 # <<<<<<<<<<<<<< @@ -12043,7 +12065,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ (__pyx_v_p_dst->strides[__pyx_v_new_ndim]) = 0; - /* "View.MemoryView":713 + /* "View.MemoryView":714 * p_dst.shape[new_ndim] = 1 * p_dst.strides[new_ndim] = 0 * p_dst.suboffsets[new_ndim] = -1 # <<<<<<<<<<<<<< @@ -12052,7 +12074,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ (__pyx_v_p_dst->suboffsets[__pyx_v_new_ndim]) = -1; - /* "View.MemoryView":714 + /* "View.MemoryView":715 * p_dst.strides[new_ndim] = 0 * p_dst.suboffsets[new_ndim] = -1 * new_ndim += 1 # <<<<<<<<<<<<<< @@ -12064,121 +12086,127 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ } /*else*/ { - /* "View.MemoryView":716 + /* "View.MemoryView":717 * new_ndim += 1 * else: * start = index.start or 0 # <<<<<<<<<<<<<< * stop = index.stop or 0 * step = index.step or 0 */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L8_next_or; } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = __pyx_t_12; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_bool_binop_done; } + __pyx_L8_next_or:; __pyx_t_10 = 0; __pyx_L7_bool_binop_done:; __pyx_v_start = __pyx_t_10; - /* "View.MemoryView":717 + /* "View.MemoryView":718 * else: * start = index.start or 0 * stop = index.stop or 0 # <<<<<<<<<<<<<< * step = index.step or 0 * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L10_next_or; } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = __pyx_t_12; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L9_bool_binop_done; } + __pyx_L10_next_or:; __pyx_t_10 = 0; __pyx_L9_bool_binop_done:; __pyx_v_stop = __pyx_t_10; - /* "View.MemoryView":718 + /* "View.MemoryView":719 * start = index.start or 0 * stop = index.stop or 0 * step = index.step or 0 # <<<<<<<<<<<<<< * * have_start = index.start is not None */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (!__pyx_t_1) { __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L12_next_or; } else { - __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = __pyx_t_12; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L11_bool_binop_done; } + __pyx_L12_next_or:; __pyx_t_10 = 0; __pyx_L11_bool_binop_done:; __pyx_v_step = __pyx_t_10; - /* "View.MemoryView":720 + /* "View.MemoryView":721 * step = index.step or 0 * * have_start = index.start is not None # <<<<<<<<<<<<<< * have_stop = index.stop is not None * have_step = index.step is not None */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 720; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_t_9 != Py_None); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_have_start = __pyx_t_1; - /* "View.MemoryView":721 + /* "View.MemoryView":722 * * have_start = index.start is not None * have_stop = index.stop is not None # <<<<<<<<<<<<<< * have_step = index.step is not None * */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_stop); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_t_9 != Py_None); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_have_stop = __pyx_t_1; - /* "View.MemoryView":722 + /* "View.MemoryView":723 * have_start = index.start is not None * have_stop = index.stop is not None * have_step = index.step is not None # <<<<<<<<<<<<<< * * slice_memviewslice( */ - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 722; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_index, __pyx_n_s_step); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __pyx_t_1 = (__pyx_t_9 != Py_None); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_v_have_step = __pyx_t_1; - /* "View.MemoryView":724 + /* "View.MemoryView":725 * have_step = index.step is not None * * slice_memviewslice( # <<<<<<<<<<<<<< * p_dst, p_src.shape[dim], p_src.strides[dim], p_src.suboffsets[dim], * dim, new_ndim, p_suboffset_dim, */ - __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = __pyx_memoryview_slice_memviewslice(__pyx_v_p_dst, (__pyx_v_p_src->shape[__pyx_v_dim]), (__pyx_v_p_src->strides[__pyx_v_dim]), (__pyx_v_p_src->suboffsets[__pyx_v_dim]), __pyx_v_dim, __pyx_v_new_ndim, __pyx_v_p_suboffset_dim, __pyx_v_start, __pyx_v_stop, __pyx_v_step, __pyx_v_have_start, __pyx_v_have_stop, __pyx_v_have_step, 1); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "View.MemoryView":730 + /* "View.MemoryView":731 * have_start, have_stop, have_step, * True) * new_ndim += 1 # <<<<<<<<<<<<<< @@ -12189,7 +12217,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ } __pyx_L6:; - /* "View.MemoryView":702 + /* "View.MemoryView":703 * cdef bint have_start, have_stop, have_step * * for dim, index in enumerate(indices): # <<<<<<<<<<<<<< @@ -12199,7 +12227,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":732 + /* "View.MemoryView":733 * new_ndim += 1 * * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< @@ -12210,7 +12238,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "View.MemoryView":733 + /* "View.MemoryView":734 * * if isinstance(memview, _memoryviewslice): * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< @@ -12219,41 +12247,41 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - /* "View.MemoryView":734 + /* "View.MemoryView":735 * if isinstance(memview, _memoryviewslice): * return memoryview_fromslice(dst, new_ndim, * memviewsliceobj.to_object_func, # <<<<<<<<<<<<<< * memviewsliceobj.to_dtype_func, * memview.dtype_is_object) */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "View.MemoryView":735 + /* "View.MemoryView":736 * return memoryview_fromslice(dst, new_ndim, * memviewsliceobj.to_object_func, * memviewsliceobj.to_dtype_func, # <<<<<<<<<<<<<< * memview.dtype_is_object) * else: */ - if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 735; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_v_memviewsliceobj)) { __Pyx_RaiseUnboundLocalError("memviewsliceobj"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "View.MemoryView":733 + /* "View.MemoryView":734 * * if isinstance(memview, _memoryviewslice): * return memoryview_fromslice(dst, new_ndim, # <<<<<<<<<<<<<< * memviewsliceobj.to_object_func, * memviewsliceobj.to_dtype_func, */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, __pyx_v_memviewsliceobj->to_object_func, __pyx_v_memviewsliceobj->to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; } /*else*/ { - /* "View.MemoryView":738 + /* "View.MemoryView":739 * memview.dtype_is_object) * else: * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< @@ -12262,30 +12290,30 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - /* "View.MemoryView":739 + /* "View.MemoryView":740 * else: * return memoryview_fromslice(dst, new_ndim, NULL, NULL, * memview.dtype_is_object) # <<<<<<<<<<<<<< * * */ - __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_fromslice(__pyx_v_dst, __pyx_v_new_ndim, NULL, NULL, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - /* "View.MemoryView":738 + /* "View.MemoryView":739 * memview.dtype_is_object) * else: * return memoryview_fromslice(dst, new_ndim, NULL, NULL, # <<<<<<<<<<<<<< * memview.dtype_is_object) * */ - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_memoryview_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = ((struct __pyx_memoryview_obj *)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L0; } - /* "View.MemoryView":666 + /* "View.MemoryView":667 * * @cname('__pyx_memview_slice') * cdef memoryview memview_slice(memoryview memview, object indices): # <<<<<<<<<<<<<< @@ -12307,7 +12335,7 @@ static struct __pyx_memoryview_obj *__pyx_memview_slice(struct __pyx_memoryview_ return __pyx_r; } -/* "View.MemoryView":763 +/* "View.MemoryView":764 * * @cname('__pyx_memoryview_slice_memviewslice') * cdef int slice_memviewslice( # <<<<<<<<<<<<<< @@ -12326,7 +12354,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, const char *__pyx_filename = NULL; int __pyx_clineno = 0; - /* "View.MemoryView":783 + /* "View.MemoryView":784 * cdef bint negative_step * * if not is_slice: # <<<<<<<<<<<<<< @@ -12336,7 +12364,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_1 = ((!(__pyx_v_is_slice != 0)) != 0); if (__pyx_t_1) { - /* "View.MemoryView":785 + /* "View.MemoryView":786 * if not is_slice: * * if start < 0: # <<<<<<<<<<<<<< @@ -12346,7 +12374,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_1 = ((__pyx_v_start < 0) != 0); if (__pyx_t_1) { - /* "View.MemoryView":786 + /* "View.MemoryView":787 * * if start < 0: * start += shape # <<<<<<<<<<<<<< @@ -12358,7 +12386,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L4:; - /* "View.MemoryView":787 + /* "View.MemoryView":788 * if start < 0: * start += shape * if not 0 <= start < shape: # <<<<<<<<<<<<<< @@ -12372,14 +12400,14 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((!(__pyx_t_1 != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":788 + /* "View.MemoryView":789 * start += shape * if not 0 <= start < shape: * _err_dim(IndexError, "Index out of bounds (axis %d)", dim) # <<<<<<<<<<<<<< * else: * */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_Index_out_of_bounds_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_Index_out_of_bounds_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; @@ -12387,7 +12415,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":791 + /* "View.MemoryView":792 * else: * * negative_step = have_step != 0 and step < 0 # <<<<<<<<<<<<<< @@ -12396,16 +12424,18 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ __pyx_t_1 = ((__pyx_v_have_step != 0) != 0); if (__pyx_t_1) { + goto __pyx_L7_next_and; } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L6_bool_binop_done; } + __pyx_L7_next_and:; __pyx_t_1 = ((__pyx_v_step < 0) != 0); __pyx_t_2 = __pyx_t_1; __pyx_L6_bool_binop_done:; __pyx_v_negative_step = __pyx_t_2; - /* "View.MemoryView":793 + /* "View.MemoryView":794 * negative_step = have_step != 0 and step < 0 * * if have_step and step == 0: # <<<<<<<<<<<<<< @@ -12414,28 +12444,30 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ __pyx_t_1 = (__pyx_v_have_step != 0); if (__pyx_t_1) { + goto __pyx_L10_next_and; } else { __pyx_t_2 = __pyx_t_1; goto __pyx_L9_bool_binop_done; } + __pyx_L10_next_and:; __pyx_t_1 = ((__pyx_v_step == 0) != 0); __pyx_t_2 = __pyx_t_1; __pyx_L9_bool_binop_done:; if (__pyx_t_2) { - /* "View.MemoryView":794 + /* "View.MemoryView":795 * * if have_step and step == 0: * _err_dim(ValueError, "Step may not be zero (axis %d)", dim) # <<<<<<<<<<<<<< * * */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Step_may_not_be_zero_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Step_may_not_be_zero_axis_d, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; - /* "View.MemoryView":797 + /* "View.MemoryView":798 * * * if have_start: # <<<<<<<<<<<<<< @@ -12445,7 +12477,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (__pyx_v_have_start != 0); if (__pyx_t_2) { - /* "View.MemoryView":798 + /* "View.MemoryView":799 * * if have_start: * if start < 0: # <<<<<<<<<<<<<< @@ -12455,7 +12487,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_start < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":799 + /* "View.MemoryView":800 * if have_start: * if start < 0: * start += shape # <<<<<<<<<<<<<< @@ -12464,7 +12496,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ __pyx_v_start = (__pyx_v_start + __pyx_v_shape); - /* "View.MemoryView":800 + /* "View.MemoryView":801 * if start < 0: * start += shape * if start < 0: # <<<<<<<<<<<<<< @@ -12474,7 +12506,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_start < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":801 + /* "View.MemoryView":802 * start += shape * if start < 0: * start = 0 # <<<<<<<<<<<<<< @@ -12488,7 +12520,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, goto __pyx_L12; } - /* "View.MemoryView":802 + /* "View.MemoryView":803 * if start < 0: * start = 0 * elif start >= shape: # <<<<<<<<<<<<<< @@ -12498,7 +12530,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_start >= __pyx_v_shape) != 0); if (__pyx_t_2) { - /* "View.MemoryView":803 + /* "View.MemoryView":804 * start = 0 * elif start >= shape: * if negative_step: # <<<<<<<<<<<<<< @@ -12508,7 +12540,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (__pyx_v_negative_step != 0); if (__pyx_t_2) { - /* "View.MemoryView":804 + /* "View.MemoryView":805 * elif start >= shape: * if negative_step: * start = shape - 1 # <<<<<<<<<<<<<< @@ -12520,7 +12552,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":806 + /* "View.MemoryView":807 * start = shape - 1 * else: * start = shape # <<<<<<<<<<<<<< @@ -12537,7 +12569,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":808 + /* "View.MemoryView":809 * start = shape * else: * if negative_step: # <<<<<<<<<<<<<< @@ -12547,7 +12579,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (__pyx_v_negative_step != 0); if (__pyx_t_2) { - /* "View.MemoryView":809 + /* "View.MemoryView":810 * else: * if negative_step: * start = shape - 1 # <<<<<<<<<<<<<< @@ -12559,7 +12591,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":811 + /* "View.MemoryView":812 * start = shape - 1 * else: * start = 0 # <<<<<<<<<<<<<< @@ -12572,7 +12604,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L11:; - /* "View.MemoryView":813 + /* "View.MemoryView":814 * start = 0 * * if have_stop: # <<<<<<<<<<<<<< @@ -12582,7 +12614,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (__pyx_v_have_stop != 0); if (__pyx_t_2) { - /* "View.MemoryView":814 + /* "View.MemoryView":815 * * if have_stop: * if stop < 0: # <<<<<<<<<<<<<< @@ -12592,7 +12624,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_stop < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":815 + /* "View.MemoryView":816 * if have_stop: * if stop < 0: * stop += shape # <<<<<<<<<<<<<< @@ -12601,7 +12633,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ __pyx_v_stop = (__pyx_v_stop + __pyx_v_shape); - /* "View.MemoryView":816 + /* "View.MemoryView":817 * if stop < 0: * stop += shape * if stop < 0: # <<<<<<<<<<<<<< @@ -12611,7 +12643,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_stop < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":817 + /* "View.MemoryView":818 * stop += shape * if stop < 0: * stop = 0 # <<<<<<<<<<<<<< @@ -12625,7 +12657,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, goto __pyx_L17; } - /* "View.MemoryView":818 + /* "View.MemoryView":819 * if stop < 0: * stop = 0 * elif stop > shape: # <<<<<<<<<<<<<< @@ -12635,7 +12667,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_stop > __pyx_v_shape) != 0); if (__pyx_t_2) { - /* "View.MemoryView":819 + /* "View.MemoryView":820 * stop = 0 * elif stop > shape: * stop = shape # <<<<<<<<<<<<<< @@ -12650,7 +12682,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":821 + /* "View.MemoryView":822 * stop = shape * else: * if negative_step: # <<<<<<<<<<<<<< @@ -12660,7 +12692,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (__pyx_v_negative_step != 0); if (__pyx_t_2) { - /* "View.MemoryView":822 + /* "View.MemoryView":823 * else: * if negative_step: * stop = -1 # <<<<<<<<<<<<<< @@ -12672,7 +12704,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":824 + /* "View.MemoryView":825 * stop = -1 * else: * stop = shape # <<<<<<<<<<<<<< @@ -12685,7 +12717,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L16:; - /* "View.MemoryView":826 + /* "View.MemoryView":827 * stop = shape * * if not have_step: # <<<<<<<<<<<<<< @@ -12695,7 +12727,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((!(__pyx_v_have_step != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":827 + /* "View.MemoryView":828 * * if not have_step: * step = 1 # <<<<<<<<<<<<<< @@ -12707,7 +12739,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L20:; - /* "View.MemoryView":831 + /* "View.MemoryView":832 * * with cython.cdivision(True): * new_shape = (stop - start) // step # <<<<<<<<<<<<<< @@ -12716,7 +12748,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ __pyx_v_new_shape = ((__pyx_v_stop - __pyx_v_start) / __pyx_v_step); - /* "View.MemoryView":833 + /* "View.MemoryView":834 * new_shape = (stop - start) // step * * if (stop - start) - step * new_shape: # <<<<<<<<<<<<<< @@ -12726,7 +12758,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (((__pyx_v_stop - __pyx_v_start) - (__pyx_v_step * __pyx_v_new_shape)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":834 + /* "View.MemoryView":835 * * if (stop - start) - step * new_shape: * new_shape += 1 # <<<<<<<<<<<<<< @@ -12738,7 +12770,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L21:; - /* "View.MemoryView":836 + /* "View.MemoryView":837 * new_shape += 1 * * if new_shape < 0: # <<<<<<<<<<<<<< @@ -12748,7 +12780,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_new_shape < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":837 + /* "View.MemoryView":838 * * if new_shape < 0: * new_shape = 0 # <<<<<<<<<<<<<< @@ -12760,7 +12792,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L22:; - /* "View.MemoryView":840 + /* "View.MemoryView":841 * * * dst.strides[new_ndim] = stride * step # <<<<<<<<<<<<<< @@ -12769,7 +12801,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ (__pyx_v_dst->strides[__pyx_v_new_ndim]) = (__pyx_v_stride * __pyx_v_step); - /* "View.MemoryView":841 + /* "View.MemoryView":842 * * dst.strides[new_ndim] = stride * step * dst.shape[new_ndim] = new_shape # <<<<<<<<<<<<<< @@ -12778,7 +12810,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, */ (__pyx_v_dst->shape[__pyx_v_new_ndim]) = __pyx_v_new_shape; - /* "View.MemoryView":842 + /* "View.MemoryView":843 * dst.strides[new_ndim] = stride * step * dst.shape[new_ndim] = new_shape * dst.suboffsets[new_ndim] = suboffset # <<<<<<<<<<<<<< @@ -12789,7 +12821,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L3:; - /* "View.MemoryView":845 + /* "View.MemoryView":846 * * * if suboffset_dim[0] < 0: # <<<<<<<<<<<<<< @@ -12799,7 +12831,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = (((__pyx_v_suboffset_dim[0]) < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":846 + /* "View.MemoryView":847 * * if suboffset_dim[0] < 0: * dst.data += start * stride # <<<<<<<<<<<<<< @@ -12811,7 +12843,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":848 + /* "View.MemoryView":849 * dst.data += start * stride * else: * dst.suboffsets[suboffset_dim[0]] += start * stride # <<<<<<<<<<<<<< @@ -12823,7 +12855,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L23:; - /* "View.MemoryView":850 + /* "View.MemoryView":851 * dst.suboffsets[suboffset_dim[0]] += start * stride * * if suboffset >= 0: # <<<<<<<<<<<<<< @@ -12833,7 +12865,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":851 + /* "View.MemoryView":852 * * if suboffset >= 0: * if not is_slice: # <<<<<<<<<<<<<< @@ -12843,7 +12875,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((!(__pyx_v_is_slice != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":852 + /* "View.MemoryView":853 * if suboffset >= 0: * if not is_slice: * if new_ndim == 0: # <<<<<<<<<<<<<< @@ -12853,7 +12885,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_t_2 = ((__pyx_v_new_ndim == 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":853 + /* "View.MemoryView":854 * if not is_slice: * if new_ndim == 0: * dst.data = ( dst.data)[0] + suboffset # <<<<<<<<<<<<<< @@ -12865,21 +12897,21 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } /*else*/ { - /* "View.MemoryView":855 + /* "View.MemoryView":856 * dst.data = ( dst.data)[0] + suboffset * else: * _err_dim(IndexError, "All dimensions preceding dimension %d " # <<<<<<<<<<<<<< * "must be indexed and not sliced", dim) * else: */ - __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_All_dimensions_preceding_dimensi, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_err_dim(__pyx_builtin_IndexError, __pyx_k_All_dimensions_preceding_dimensi, __pyx_v_dim); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L26:; goto __pyx_L25; } /*else*/ { - /* "View.MemoryView":858 + /* "View.MemoryView":859 * "must be indexed and not sliced", dim) * else: * suboffset_dim[0] = new_ndim # <<<<<<<<<<<<<< @@ -12893,7 +12925,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, } __pyx_L24:; - /* "View.MemoryView":860 + /* "View.MemoryView":861 * suboffset_dim[0] = new_ndim * * return 0 # <<<<<<<<<<<<<< @@ -12903,7 +12935,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, __pyx_r = 0; goto __pyx_L0; - /* "View.MemoryView":763 + /* "View.MemoryView":764 * * @cname('__pyx_memoryview_slice_memviewslice') * cdef int slice_memviewslice( # <<<<<<<<<<<<<< @@ -12927,7 +12959,7 @@ static int __pyx_memoryview_slice_memviewslice(__Pyx_memviewslice *__pyx_v_dst, return __pyx_r; } -/* "View.MemoryView":866 +/* "View.MemoryView":867 * * @cname('__pyx_pybuffer_index') * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< @@ -12952,7 +12984,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P int __pyx_clineno = 0; __Pyx_RefNannySetupContext("pybuffer_index", 0); - /* "View.MemoryView":868 + /* "View.MemoryView":869 * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, * Py_ssize_t dim) except NULL: * cdef Py_ssize_t shape, stride, suboffset = -1 # <<<<<<<<<<<<<< @@ -12961,7 +12993,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P */ __pyx_v_suboffset = -1; - /* "View.MemoryView":869 + /* "View.MemoryView":870 * Py_ssize_t dim) except NULL: * cdef Py_ssize_t shape, stride, suboffset = -1 * cdef Py_ssize_t itemsize = view.itemsize # <<<<<<<<<<<<<< @@ -12971,7 +13003,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_1 = __pyx_v_view->itemsize; __pyx_v_itemsize = __pyx_t_1; - /* "View.MemoryView":872 + /* "View.MemoryView":873 * cdef char *resultp * * if view.ndim == 0: # <<<<<<<<<<<<<< @@ -12981,7 +13013,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_view->ndim == 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":873 + /* "View.MemoryView":874 * * if view.ndim == 0: * shape = view.len / itemsize # <<<<<<<<<<<<<< @@ -12996,7 +13028,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P #ifdef WITH_THREAD PyGILState_Release(__pyx_gilstate_save); #endif - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } else if (sizeof(Py_ssize_t) == sizeof(long) && unlikely(__pyx_v_itemsize == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_v_view->len))) { #ifdef WITH_THREAD @@ -13006,11 +13038,11 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P #ifdef WITH_THREAD PyGILState_Release(__pyx_gilstate_save); #endif - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_shape = __Pyx_div_Py_ssize_t(__pyx_v_view->len, __pyx_v_itemsize); - /* "View.MemoryView":874 + /* "View.MemoryView":875 * if view.ndim == 0: * shape = view.len / itemsize * stride = itemsize # <<<<<<<<<<<<<< @@ -13022,7 +13054,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P } /*else*/ { - /* "View.MemoryView":876 + /* "View.MemoryView":877 * stride = itemsize * else: * shape = view.shape[dim] # <<<<<<<<<<<<<< @@ -13031,7 +13063,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P */ __pyx_v_shape = (__pyx_v_view->shape[__pyx_v_dim]); - /* "View.MemoryView":877 + /* "View.MemoryView":878 * else: * shape = view.shape[dim] * stride = view.strides[dim] # <<<<<<<<<<<<<< @@ -13040,7 +13072,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P */ __pyx_v_stride = (__pyx_v_view->strides[__pyx_v_dim]); - /* "View.MemoryView":878 + /* "View.MemoryView":879 * shape = view.shape[dim] * stride = view.strides[dim] * if view.suboffsets != NULL: # <<<<<<<<<<<<<< @@ -13050,7 +13082,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_view->suboffsets != NULL) != 0); if (__pyx_t_2) { - /* "View.MemoryView":879 + /* "View.MemoryView":880 * stride = view.strides[dim] * if view.suboffsets != NULL: * suboffset = view.suboffsets[dim] # <<<<<<<<<<<<<< @@ -13064,7 +13096,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P } __pyx_L3:; - /* "View.MemoryView":881 + /* "View.MemoryView":882 * suboffset = view.suboffsets[dim] * * if index < 0: # <<<<<<<<<<<<<< @@ -13074,7 +13106,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_index < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":882 + /* "View.MemoryView":883 * * if index < 0: * index += view.shape[dim] # <<<<<<<<<<<<<< @@ -13083,7 +13115,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P */ __pyx_v_index = (__pyx_v_index + (__pyx_v_view->shape[__pyx_v_dim])); - /* "View.MemoryView":883 + /* "View.MemoryView":884 * if index < 0: * index += view.shape[dim] * if index < 0: # <<<<<<<<<<<<<< @@ -13093,35 +13125,35 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_index < 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":884 + /* "View.MemoryView":885 * index += view.shape[dim] * if index < 0: * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< * * if index >= shape: */ - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } goto __pyx_L5; } __pyx_L5:; - /* "View.MemoryView":886 + /* "View.MemoryView":887 * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * * if index >= shape: # <<<<<<<<<<<<<< @@ -13131,32 +13163,32 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_index >= __pyx_v_shape) != 0); if (__pyx_t_2) { - /* "View.MemoryView":887 + /* "View.MemoryView":888 * * if index >= shape: * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) # <<<<<<<<<<<<<< * * resultp = bufp + index * stride */ - __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromSsize_t(__pyx_v_dim); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Out_of_bounds_on_buffer_access_a, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_IndexError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "View.MemoryView":889 + /* "View.MemoryView":890 * raise IndexError("Out of bounds on buffer access (axis %d)" % dim) * * resultp = bufp + index * stride # <<<<<<<<<<<<<< @@ -13165,7 +13197,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P */ __pyx_v_resultp = (__pyx_v_bufp + (__pyx_v_index * __pyx_v_stride)); - /* "View.MemoryView":890 + /* "View.MemoryView":891 * * resultp = bufp + index * stride * if suboffset >= 0: # <<<<<<<<<<<<<< @@ -13175,7 +13207,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_t_2 = ((__pyx_v_suboffset >= 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":891 + /* "View.MemoryView":892 * resultp = bufp + index * stride * if suboffset >= 0: * resultp = ( resultp)[0] + suboffset # <<<<<<<<<<<<<< @@ -13187,7 +13219,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P } __pyx_L8:; - /* "View.MemoryView":893 + /* "View.MemoryView":894 * resultp = ( resultp)[0] + suboffset * * return resultp # <<<<<<<<<<<<<< @@ -13197,7 +13229,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P __pyx_r = __pyx_v_resultp; goto __pyx_L0; - /* "View.MemoryView":866 + /* "View.MemoryView":867 * * @cname('__pyx_pybuffer_index') * cdef char *pybuffer_index(Py_buffer *view, char *bufp, Py_ssize_t index, # <<<<<<<<<<<<<< @@ -13216,7 +13248,7 @@ static char *__pyx_pybuffer_index(Py_buffer *__pyx_v_view, char *__pyx_v_bufp, P return __pyx_r; } -/* "View.MemoryView":899 +/* "View.MemoryView":900 * * @cname('__pyx_memslice_transpose') * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< @@ -13243,7 +13275,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { const char *__pyx_filename = NULL; int __pyx_clineno = 0; - /* "View.MemoryView":900 + /* "View.MemoryView":901 * @cname('__pyx_memslice_transpose') * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: * cdef int ndim = memslice.memview.view.ndim # <<<<<<<<<<<<<< @@ -13253,7 +13285,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { __pyx_t_1 = __pyx_v_memslice->memview->view.ndim; __pyx_v_ndim = __pyx_t_1; - /* "View.MemoryView":902 + /* "View.MemoryView":903 * cdef int ndim = memslice.memview.view.ndim * * cdef Py_ssize_t *shape = memslice.shape # <<<<<<<<<<<<<< @@ -13263,7 +13295,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { __pyx_t_2 = __pyx_v_memslice->shape; __pyx_v_shape = __pyx_t_2; - /* "View.MemoryView":903 + /* "View.MemoryView":904 * * cdef Py_ssize_t *shape = memslice.shape * cdef Py_ssize_t *strides = memslice.strides # <<<<<<<<<<<<<< @@ -13273,7 +13305,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { __pyx_t_2 = __pyx_v_memslice->strides; __pyx_v_strides = __pyx_t_2; - /* "View.MemoryView":907 + /* "View.MemoryView":908 * * cdef int i, j * for i in range(ndim / 2): # <<<<<<<<<<<<<< @@ -13284,7 +13316,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_3; __pyx_t_1+=1) { __pyx_v_i = __pyx_t_1; - /* "View.MemoryView":908 + /* "View.MemoryView":909 * cdef int i, j * for i in range(ndim / 2): * j = ndim - 1 - i # <<<<<<<<<<<<<< @@ -13293,7 +13325,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { */ __pyx_v_j = ((__pyx_v_ndim - 1) - __pyx_v_i); - /* "View.MemoryView":909 + /* "View.MemoryView":910 * for i in range(ndim / 2): * j = ndim - 1 - i * strides[i], strides[j] = strides[j], strides[i] # <<<<<<<<<<<<<< @@ -13305,7 +13337,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { (__pyx_v_strides[__pyx_v_i]) = __pyx_t_4; (__pyx_v_strides[__pyx_v_j]) = __pyx_t_5; - /* "View.MemoryView":910 + /* "View.MemoryView":911 * j = ndim - 1 - i * strides[i], strides[j] = strides[j], strides[i] * shape[i], shape[j] = shape[j], shape[i] # <<<<<<<<<<<<<< @@ -13317,7 +13349,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { (__pyx_v_shape[__pyx_v_i]) = __pyx_t_5; (__pyx_v_shape[__pyx_v_j]) = __pyx_t_4; - /* "View.MemoryView":912 + /* "View.MemoryView":913 * shape[i], shape[j] = shape[j], shape[i] * * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: # <<<<<<<<<<<<<< @@ -13326,29 +13358,31 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { */ __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_i]) >= 0) != 0); if (!__pyx_t_7) { + goto __pyx_L7_next_or; } else { __pyx_t_6 = __pyx_t_7; goto __pyx_L6_bool_binop_done; } + __pyx_L7_next_or:; __pyx_t_7 = (((__pyx_v_memslice->suboffsets[__pyx_v_j]) >= 0) != 0); __pyx_t_6 = __pyx_t_7; __pyx_L6_bool_binop_done:; if (__pyx_t_6) { - /* "View.MemoryView":913 + /* "View.MemoryView":914 * * if memslice.suboffsets[i] >= 0 or memslice.suboffsets[j] >= 0: * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") # <<<<<<<<<<<<<< * * return 1 */ - __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, __pyx_k_Cannot_transpose_memoryview_with); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __pyx_memoryview_err(__pyx_builtin_ValueError, __pyx_k_Cannot_transpose_memoryview_with); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; } - /* "View.MemoryView":915 + /* "View.MemoryView":916 * _err(ValueError, "Cannot transpose memoryview with indirect dimensions") * * return 1 # <<<<<<<<<<<<<< @@ -13358,7 +13392,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { __pyx_r = 1; goto __pyx_L0; - /* "View.MemoryView":899 + /* "View.MemoryView":900 * * @cname('__pyx_memslice_transpose') * cdef int transpose_memslice(__Pyx_memviewslice *memslice) nogil except 0: # <<<<<<<<<<<<<< @@ -13382,7 +13416,7 @@ static int __pyx_memslice_transpose(__Pyx_memviewslice *__pyx_v_memslice) { return __pyx_r; } -/* "View.MemoryView":932 +/* "View.MemoryView":933 * cdef int (*to_dtype_func)(char *, object) except 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -13395,17 +13429,17 @@ static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_memoryviewslice___dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } -static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { +static void __pyx_memoryviewslice_MemoryView_16_memoryviewslice___dealloc__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "View.MemoryView":933 + /* "View.MemoryView":934 * * def __dealloc__(self): * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) # <<<<<<<<<<<<<< @@ -13414,7 +13448,7 @@ static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewsl */ __PYX_XDEC_MEMVIEW((&__pyx_v_self->from_slice), 1); - /* "View.MemoryView":932 + /* "View.MemoryView":933 * cdef int (*to_dtype_func)(char *, object) except 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -13426,7 +13460,7 @@ static void __pyx_memoryviewslice___pyx_pf_15View_dot_MemoryView_16_memoryviewsl __Pyx_RefNannyFinishContext(); } -/* "View.MemoryView":935 +/* "View.MemoryView":936 * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) * * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< @@ -13444,7 +13478,7 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor int __pyx_clineno = 0; __Pyx_RefNannySetupContext("convert_item_to_object", 0); - /* "View.MemoryView":936 + /* "View.MemoryView":937 * * cdef convert_item_to_object(self, char *itemp): * if self.to_object_func != NULL: # <<<<<<<<<<<<<< @@ -13454,7 +13488,7 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor __pyx_t_1 = ((__pyx_v_self->to_object_func != NULL) != 0); if (__pyx_t_1) { - /* "View.MemoryView":937 + /* "View.MemoryView":938 * cdef convert_item_to_object(self, char *itemp): * if self.to_object_func != NULL: * return self.to_object_func(itemp) # <<<<<<<<<<<<<< @@ -13462,7 +13496,7 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor * return memoryview.convert_item_to_object(self, itemp) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_v_self->to_object_func(__pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -13470,7 +13504,7 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor } /*else*/ { - /* "View.MemoryView":939 + /* "View.MemoryView":940 * return self.to_object_func(itemp) * else: * return memoryview.convert_item_to_object(self, itemp) # <<<<<<<<<<<<<< @@ -13478,14 +13512,14 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor * cdef assign_item_from_object(self, char *itemp, object value): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_memoryview_convert_item_to_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0; } - /* "View.MemoryView":935 + /* "View.MemoryView":936 * __PYX_XDEC_MEMVIEW(&self.from_slice, 1) * * cdef convert_item_to_object(self, char *itemp): # <<<<<<<<<<<<<< @@ -13504,7 +13538,7 @@ static PyObject *__pyx_memoryviewslice_convert_item_to_object(struct __pyx_memor return __pyx_r; } -/* "View.MemoryView":941 +/* "View.MemoryView":942 * return memoryview.convert_item_to_object(self, itemp) * * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< @@ -13523,7 +13557,7 @@ static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memo int __pyx_clineno = 0; __Pyx_RefNannySetupContext("assign_item_from_object", 0); - /* "View.MemoryView":942 + /* "View.MemoryView":943 * * cdef assign_item_from_object(self, char *itemp, object value): * if self.to_dtype_func != NULL: # <<<<<<<<<<<<<< @@ -13533,32 +13567,32 @@ static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memo __pyx_t_1 = ((__pyx_v_self->to_dtype_func != NULL) != 0); if (__pyx_t_1) { - /* "View.MemoryView":943 + /* "View.MemoryView":944 * cdef assign_item_from_object(self, char *itemp, object value): * if self.to_dtype_func != NULL: * self.to_dtype_func(itemp, value) # <<<<<<<<<<<<<< * else: * memoryview.assign_item_from_object(self, itemp, value) */ - __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_v_self->to_dtype_func(__pyx_v_itemp, __pyx_v_value); if (unlikely(__pyx_t_2 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } /*else*/ { - /* "View.MemoryView":945 + /* "View.MemoryView":946 * self.to_dtype_func(itemp, value) * else: * memoryview.assign_item_from_object(self, itemp, value) # <<<<<<<<<<<<<< * * property base: */ - __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_assign_item_from_object(((struct __pyx_memoryview_obj *)__pyx_v_self), __pyx_v_itemp, __pyx_v_value); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L3:; - /* "View.MemoryView":941 + /* "View.MemoryView":942 * return memoryview.convert_item_to_object(self, itemp) * * cdef assign_item_from_object(self, char *itemp, object value): # <<<<<<<<<<<<<< @@ -13579,7 +13613,7 @@ static PyObject *__pyx_memoryviewslice_assign_item_from_object(struct __pyx_memo return __pyx_r; } -/* "View.MemoryView":949 +/* "View.MemoryView":950 * property base: * @cname('__pyx_memoryviewslice__get__base') * def __get__(self): # <<<<<<<<<<<<<< @@ -13593,19 +13627,19 @@ static PyObject *__pyx_memoryviewslice__get__base(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); + __pyx_r = __pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(((struct __pyx_memoryviewslice_obj *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { +static PyObject *__pyx_memoryviewslice__get__base_MemoryView_16_memoryviewslice_4base___get__(struct __pyx_memoryviewslice_obj *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); - /* "View.MemoryView":950 + /* "View.MemoryView":951 * @cname('__pyx_memoryviewslice__get__base') * def __get__(self): * return self.from_object # <<<<<<<<<<<<<< @@ -13617,7 +13651,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__ __pyx_r = __pyx_v_self->from_object; goto __pyx_L0; - /* "View.MemoryView":949 + /* "View.MemoryView":950 * property base: * @cname('__pyx_memoryviewslice__get__base') * def __get__(self): # <<<<<<<<<<<<<< @@ -13632,7 +13666,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__ return __pyx_r; } -/* "View.MemoryView":956 +/* "View.MemoryView":957 * * @cname('__pyx_memoryview_fromslice') * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< @@ -13642,8 +13676,7 @@ static PyObject *__pyx_pf_15View_dot_MemoryView_16_memoryviewslice_4base___get__ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewslice, int __pyx_v_ndim, PyObject *(*__pyx_v_to_object_func)(char *), int (*__pyx_v_to_dtype_func)(char *, PyObject *), int __pyx_v_dtype_is_object) { struct __pyx_memoryviewslice_obj *__pyx_v_result = 0; - Py_ssize_t __pyx_v_suboffset; - PyObject *__pyx_v_length = NULL; + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -13651,17 +13684,16 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl PyObject *__pyx_t_3 = NULL; __Pyx_TypeInfo *__pyx_t_4; Py_buffer __pyx_t_5; - Py_ssize_t *__pyx_t_6; - Py_ssize_t *__pyx_t_7; - Py_ssize_t *__pyx_t_8; - Py_ssize_t __pyx_t_9; + Py_ssize_t __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("memoryview_fromslice", 0); - /* "View.MemoryView":964 - * cdef _memoryviewslice result + /* "View.MemoryView":966 + * cdef int i * * if memviewslice.memview == Py_None: # <<<<<<<<<<<<<< * return None @@ -13670,7 +13702,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_t_1 = ((((PyObject *)__pyx_v_memviewslice.memview) == Py_None) != 0); if (__pyx_t_1) { - /* "View.MemoryView":965 + /* "View.MemoryView":967 * * if memviewslice.memview == Py_None: * return None # <<<<<<<<<<<<<< @@ -13683,16 +13715,16 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl goto __pyx_L0; } - /* "View.MemoryView":970 + /* "View.MemoryView":972 * * * result = _memoryviewslice(None, 0, dtype_is_object) # <<<<<<<<<<<<<< * * result.from_slice = memviewslice */ - __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_dtype_is_object); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None); @@ -13703,13 +13735,13 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryviewslice_type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_memoryviewslice_type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_result = ((struct __pyx_memoryviewslice_obj *)__pyx_t_2); __pyx_t_2 = 0; - /* "View.MemoryView":972 + /* "View.MemoryView":974 * result = _memoryviewslice(None, 0, dtype_is_object) * * result.from_slice = memviewslice # <<<<<<<<<<<<<< @@ -13718,7 +13750,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->from_slice = __pyx_v_memviewslice; - /* "View.MemoryView":973 + /* "View.MemoryView":975 * * result.from_slice = memviewslice * __PYX_INC_MEMVIEW(&memviewslice, 1) # <<<<<<<<<<<<<< @@ -13727,14 +13759,14 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __PYX_INC_MEMVIEW((&__pyx_v_memviewslice), 1); - /* "View.MemoryView":975 + /* "View.MemoryView":977 * __PYX_INC_MEMVIEW(&memviewslice, 1) * * result.from_object = ( memviewslice.memview).base # <<<<<<<<<<<<<< * result.typeinfo = memviewslice.memview.typeinfo * */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_memviewslice.memview), __pyx_n_s_base); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_result->from_object); @@ -13742,7 +13774,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_v_result->from_object = __pyx_t_2; __pyx_t_2 = 0; - /* "View.MemoryView":976 + /* "View.MemoryView":978 * * result.from_object = ( memviewslice.memview).base * result.typeinfo = memviewslice.memview.typeinfo # <<<<<<<<<<<<<< @@ -13752,7 +13784,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_t_4 = __pyx_v_memviewslice.memview->typeinfo; __pyx_v_result->__pyx_base.typeinfo = __pyx_t_4; - /* "View.MemoryView":978 + /* "View.MemoryView":980 * result.typeinfo = memviewslice.memview.typeinfo * * result.view = memviewslice.memview.view # <<<<<<<<<<<<<< @@ -13762,7 +13794,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_t_5 = __pyx_v_memviewslice.memview->view; __pyx_v_result->__pyx_base.view = __pyx_t_5; - /* "View.MemoryView":979 + /* "View.MemoryView":981 * * result.view = memviewslice.memview.view * result.view.buf = memviewslice.data # <<<<<<<<<<<<<< @@ -13771,7 +13803,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->__pyx_base.view.buf = ((void *)__pyx_v_memviewslice.data); - /* "View.MemoryView":980 + /* "View.MemoryView":982 * result.view = memviewslice.memview.view * result.view.buf = memviewslice.data * result.view.ndim = ndim # <<<<<<<<<<<<<< @@ -13780,7 +13812,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->__pyx_base.view.ndim = __pyx_v_ndim; - /* "View.MemoryView":981 + /* "View.MemoryView":983 * result.view.buf = memviewslice.data * result.view.ndim = ndim * (<__pyx_buffer *> &result.view).obj = Py_None # <<<<<<<<<<<<<< @@ -13789,7 +13821,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ ((Py_buffer *)(&__pyx_v_result->__pyx_base.view))->obj = Py_None; - /* "View.MemoryView":982 + /* "View.MemoryView":984 * result.view.ndim = ndim * (<__pyx_buffer *> &result.view).obj = Py_None * Py_INCREF(Py_None) # <<<<<<<<<<<<<< @@ -13798,7 +13830,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ Py_INCREF(Py_None); - /* "View.MemoryView":984 + /* "View.MemoryView":986 * Py_INCREF(Py_None) * * result.flags = PyBUF_RECORDS # <<<<<<<<<<<<<< @@ -13807,120 +13839,66 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->__pyx_base.flags = PyBUF_RECORDS; - /* "View.MemoryView":986 + /* "View.MemoryView":988 * result.flags = PyBUF_RECORDS * * result.view.shape = result.from_slice.shape # <<<<<<<<<<<<<< * result.view.strides = result.from_slice.strides - * + * result.view.suboffsets = result.from_slice.suboffsets */ __pyx_v_result->__pyx_base.view.shape = ((Py_ssize_t *)__pyx_v_result->from_slice.shape); - /* "View.MemoryView":987 + /* "View.MemoryView":989 * * result.view.shape = result.from_slice.shape * result.view.strides = result.from_slice.strides # <<<<<<<<<<<<<< - * + * result.view.suboffsets = result.from_slice.suboffsets * */ __pyx_v_result->__pyx_base.view.strides = ((Py_ssize_t *)__pyx_v_result->from_slice.strides); /* "View.MemoryView":990 - * - * - * result.view.suboffsets = NULL # <<<<<<<<<<<<<< - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: - */ - __pyx_v_result->__pyx_base.view.suboffsets = NULL; - - /* "View.MemoryView":991 - * - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: # <<<<<<<<<<<<<< - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets - */ - __pyx_t_7 = (__pyx_v_result->from_slice.suboffsets + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->from_slice.suboffsets; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_v_suboffset = (__pyx_t_6[0]); - - /* "View.MemoryView":992 - * result.view.suboffsets = NULL - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: # <<<<<<<<<<<<<< - * result.view.suboffsets = result.from_slice.suboffsets - * break - */ - __pyx_t_1 = ((__pyx_v_suboffset >= 0) != 0); - if (__pyx_t_1) { - - /* "View.MemoryView":993 - * for suboffset in result.from_slice.suboffsets[:ndim]: - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< - * break - * - */ - __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); - - /* "View.MemoryView":994 - * if suboffset >= 0: - * result.view.suboffsets = result.from_slice.suboffsets - * break # <<<<<<<<<<<<<< + * result.view.shape = result.from_slice.shape + * result.view.strides = result.from_slice.strides + * result.view.suboffsets = result.from_slice.suboffsets # <<<<<<<<<<<<<< * * result.view.len = result.view.itemsize */ - goto __pyx_L5_break; - } - } - __pyx_L5_break:; + __pyx_v_result->__pyx_base.view.suboffsets = ((Py_ssize_t *)__pyx_v_result->from_slice.suboffsets); - /* "View.MemoryView":996 - * break + /* "View.MemoryView":992 + * result.view.suboffsets = result.from_slice.suboffsets * * result.view.len = result.view.itemsize # <<<<<<<<<<<<<< - * for length in result.view.shape[:ndim]: - * result.view.len *= length + * for i in range(ndim): + * result.view.len *= result.view.shape[i] */ - __pyx_t_9 = __pyx_v_result->__pyx_base.view.itemsize; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + __pyx_t_6 = __pyx_v_result->__pyx_base.view.itemsize; + __pyx_v_result->__pyx_base.view.len = __pyx_t_6; - /* "View.MemoryView":997 + /* "View.MemoryView":993 * * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: # <<<<<<<<<<<<<< - * result.view.len *= length + * for i in range(ndim): # <<<<<<<<<<<<<< + * result.view.len *= result.view.shape[i] * */ - __pyx_t_7 = (__pyx_v_result->__pyx_base.view.shape + __pyx_v_ndim); - for (__pyx_t_8 = __pyx_v_result->__pyx_base.view.shape; __pyx_t_8 < __pyx_t_7; __pyx_t_8++) { - __pyx_t_6 = __pyx_t_8; - __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_6[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_length, __pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_7 = __pyx_v_ndim; + for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) { + __pyx_v_i = __pyx_t_8; - /* "View.MemoryView":998 + /* "View.MemoryView":994 * result.view.len = result.view.itemsize - * for length in result.view.shape[:ndim]: - * result.view.len *= length # <<<<<<<<<<<<<< + * for i in range(ndim): + * result.view.len *= result.view.shape[i] # <<<<<<<<<<<<<< * * result.to_object_func = to_object_func */ - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_result->__pyx_base.view.len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_InPlaceMultiply(__pyx_t_2, __pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_3); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_result->__pyx_base.view.len = __pyx_t_9; + __pyx_v_result->__pyx_base.view.len = (__pyx_v_result->__pyx_base.view.len * (__pyx_v_result->__pyx_base.view.shape[__pyx_v_i])); } - /* "View.MemoryView":1000 - * result.view.len *= length + /* "View.MemoryView":996 + * result.view.len *= result.view.shape[i] * * result.to_object_func = to_object_func # <<<<<<<<<<<<<< * result.to_dtype_func = to_dtype_func @@ -13928,7 +13906,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->to_object_func = __pyx_v_to_object_func; - /* "View.MemoryView":1001 + /* "View.MemoryView":997 * * result.to_object_func = to_object_func * result.to_dtype_func = to_dtype_func # <<<<<<<<<<<<<< @@ -13937,7 +13915,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl */ __pyx_v_result->to_dtype_func = __pyx_v_to_dtype_func; - /* "View.MemoryView":1003 + /* "View.MemoryView":999 * result.to_dtype_func = to_dtype_func * * return result # <<<<<<<<<<<<<< @@ -13949,7 +13927,7 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_r = ((PyObject *)__pyx_v_result); goto __pyx_L0; - /* "View.MemoryView":956 + /* "View.MemoryView":957 * * @cname('__pyx_memoryview_fromslice') * cdef memoryview_fromslice(__Pyx_memviewslice memviewslice, # <<<<<<<<<<<<<< @@ -13965,13 +13943,12 @@ static PyObject *__pyx_memoryview_fromslice(__Pyx_memviewslice __pyx_v_memviewsl __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XDECREF(__pyx_v_length); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "View.MemoryView":1006 +/* "View.MemoryView":1002 * * @cname('__pyx_memoryview_get_slice_from_memoryview') * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< @@ -13991,7 +13968,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("get_slice_from_memview", 0); - /* "View.MemoryView":1009 + /* "View.MemoryView":1005 * __Pyx_memviewslice *mslice): * cdef _memoryviewslice obj * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< @@ -14002,20 +13979,20 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "View.MemoryView":1010 + /* "View.MemoryView":1006 * cdef _memoryviewslice obj * if isinstance(memview, _memoryviewslice): * obj = memview # <<<<<<<<<<<<<< * return &obj.from_slice * else: */ - if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((((PyObject *)__pyx_v_memview)) == Py_None) || likely(__Pyx_TypeTest(((PyObject *)__pyx_v_memview), __pyx_memoryviewslice_type))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_3 = ((PyObject *)__pyx_v_memview); __Pyx_INCREF(__pyx_t_3); __pyx_v_obj = ((struct __pyx_memoryviewslice_obj *)__pyx_t_3); __pyx_t_3 = 0; - /* "View.MemoryView":1011 + /* "View.MemoryView":1007 * if isinstance(memview, _memoryviewslice): * obj = memview * return &obj.from_slice # <<<<<<<<<<<<<< @@ -14027,7 +14004,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p } /*else*/ { - /* "View.MemoryView":1013 + /* "View.MemoryView":1009 * return &obj.from_slice * else: * slice_copy(memview, mslice) # <<<<<<<<<<<<<< @@ -14036,7 +14013,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p */ __pyx_memoryview_slice_copy(__pyx_v_memview, __pyx_v_mslice); - /* "View.MemoryView":1014 + /* "View.MemoryView":1010 * else: * slice_copy(memview, mslice) * return mslice # <<<<<<<<<<<<<< @@ -14047,7 +14024,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p goto __pyx_L0; } - /* "View.MemoryView":1006 + /* "View.MemoryView":1002 * * @cname('__pyx_memoryview_get_slice_from_memoryview') * cdef __Pyx_memviewslice *get_slice_from_memview(memoryview memview, # <<<<<<<<<<<<<< @@ -14066,7 +14043,7 @@ static __Pyx_memviewslice *__pyx_memoryview_get_slice_from_memoryview(struct __p return __pyx_r; } -/* "View.MemoryView":1017 +/* "View.MemoryView":1013 * * @cname('__pyx_memoryview_slice_copy') * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< @@ -14083,10 +14060,10 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem Py_ssize_t *__pyx_t_1; int __pyx_t_2; int __pyx_t_3; - Py_ssize_t __pyx_t_4; + int __pyx_t_4; __Pyx_RefNannySetupContext("slice_copy", 0); - /* "View.MemoryView":1021 + /* "View.MemoryView":1017 * cdef (Py_ssize_t*) shape, strides, suboffsets * * shape = memview.view.shape # <<<<<<<<<<<<<< @@ -14096,7 +14073,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem __pyx_t_1 = __pyx_v_memview->view.shape; __pyx_v_shape = __pyx_t_1; - /* "View.MemoryView":1022 + /* "View.MemoryView":1018 * * shape = memview.view.shape * strides = memview.view.strides # <<<<<<<<<<<<<< @@ -14106,7 +14083,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem __pyx_t_1 = __pyx_v_memview->view.strides; __pyx_v_strides = __pyx_t_1; - /* "View.MemoryView":1023 + /* "View.MemoryView":1019 * shape = memview.view.shape * strides = memview.view.strides * suboffsets = memview.view.suboffsets # <<<<<<<<<<<<<< @@ -14116,7 +14093,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem __pyx_t_1 = __pyx_v_memview->view.suboffsets; __pyx_v_suboffsets = __pyx_t_1; - /* "View.MemoryView":1025 + /* "View.MemoryView":1021 * suboffsets = memview.view.suboffsets * * dst.memview = <__pyx_memoryview *> memview # <<<<<<<<<<<<<< @@ -14125,7 +14102,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem */ __pyx_v_dst->memview = ((struct __pyx_memoryview_obj *)__pyx_v_memview); - /* "View.MemoryView":1026 + /* "View.MemoryView":1022 * * dst.memview = <__pyx_memoryview *> memview * dst.data = memview.view.buf # <<<<<<<<<<<<<< @@ -14134,7 +14111,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem */ __pyx_v_dst->data = ((char *)__pyx_v_memview->view.buf); - /* "View.MemoryView":1028 + /* "View.MemoryView":1024 * dst.data = memview.view.buf * * for dim in range(memview.view.ndim): # <<<<<<<<<<<<<< @@ -14145,40 +14122,59 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_dim = __pyx_t_3; - /* "View.MemoryView":1029 + /* "View.MemoryView":1025 * * for dim in range(memview.view.ndim): * dst.shape[dim] = shape[dim] # <<<<<<<<<<<<<< * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 + * if suboffsets == NULL: */ (__pyx_v_dst->shape[__pyx_v_dim]) = (__pyx_v_shape[__pyx_v_dim]); - /* "View.MemoryView":1030 + /* "View.MemoryView":1026 * for dim in range(memview.view.ndim): * dst.shape[dim] = shape[dim] * dst.strides[dim] = strides[dim] # <<<<<<<<<<<<<< - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 - * + * if suboffsets == NULL: + * dst.suboffsets[dim] = -1 */ (__pyx_v_dst->strides[__pyx_v_dim]) = (__pyx_v_strides[__pyx_v_dim]); - /* "View.MemoryView":1031 + /* "View.MemoryView":1027 * dst.shape[dim] = shape[dim] * dst.strides[dim] = strides[dim] - * dst.suboffsets[dim] = suboffsets[dim] if suboffsets else -1 # <<<<<<<<<<<<<< + * if suboffsets == NULL: # <<<<<<<<<<<<<< + * dst.suboffsets[dim] = -1 + * else: + */ + __pyx_t_4 = ((__pyx_v_suboffsets == NULL) != 0); + if (__pyx_t_4) { + + /* "View.MemoryView":1028 + * dst.strides[dim] = strides[dim] + * if suboffsets == NULL: + * dst.suboffsets[dim] = -1 # <<<<<<<<<<<<<< + * else: + * dst.suboffsets[dim] = suboffsets[dim] + */ + (__pyx_v_dst->suboffsets[__pyx_v_dim]) = -1; + goto __pyx_L5; + } + /*else*/ { + + /* "View.MemoryView":1030 + * dst.suboffsets[dim] = -1 + * else: + * dst.suboffsets[dim] = suboffsets[dim] # <<<<<<<<<<<<<< * * @cname('__pyx_memoryview_copy_object') */ - if ((__pyx_v_suboffsets != 0)) { - __pyx_t_4 = (__pyx_v_suboffsets[__pyx_v_dim]); - } else { - __pyx_t_4 = -1; + (__pyx_v_dst->suboffsets[__pyx_v_dim]) = (__pyx_v_suboffsets[__pyx_v_dim]); } - (__pyx_v_dst->suboffsets[__pyx_v_dim]) = __pyx_t_4; + __pyx_L5:; } - /* "View.MemoryView":1017 + /* "View.MemoryView":1013 * * @cname('__pyx_memoryview_slice_copy') * cdef void slice_copy(memoryview memview, __Pyx_memviewslice *dst): # <<<<<<<<<<<<<< @@ -14190,7 +14186,7 @@ static void __pyx_memoryview_slice_copy(struct __pyx_memoryview_obj *__pyx_v_mem __Pyx_RefNannyFinishContext(); } -/* "View.MemoryView":1034 +/* "View.MemoryView":1033 * * @cname('__pyx_memoryview_copy_object') * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< @@ -14208,7 +14204,7 @@ static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx int __pyx_clineno = 0; __Pyx_RefNannySetupContext("memoryview_copy", 0); - /* "View.MemoryView":1037 + /* "View.MemoryView":1036 * "Create a new memoryview object" * cdef __Pyx_memviewslice memviewslice * slice_copy(memview, &memviewslice) # <<<<<<<<<<<<<< @@ -14217,7 +14213,7 @@ static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx */ __pyx_memoryview_slice_copy(__pyx_v_memview, (&__pyx_v_memviewslice)); - /* "View.MemoryView":1038 + /* "View.MemoryView":1037 * cdef __Pyx_memviewslice memviewslice * slice_copy(memview, &memviewslice) * return memoryview_copy_from_slice(memview, &memviewslice) # <<<<<<<<<<<<<< @@ -14225,13 +14221,13 @@ static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx * @cname('__pyx_memoryview_copy_object_from_slice') */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __pyx_memoryview_copy_object_from_slice(__pyx_v_memview, (&__pyx_v_memviewslice)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "View.MemoryView":1034 + /* "View.MemoryView":1033 * * @cname('__pyx_memoryview_copy_object') * cdef memoryview_copy(memoryview memview): # <<<<<<<<<<<<<< @@ -14250,7 +14246,7 @@ static PyObject *__pyx_memoryview_copy_object(struct __pyx_memoryview_obj *__pyx return __pyx_r; } -/* "View.MemoryView":1041 +/* "View.MemoryView":1040 * * @cname('__pyx_memoryview_copy_object_from_slice') * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< @@ -14273,7 +14269,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview int __pyx_clineno = 0; __Pyx_RefNannySetupContext("memoryview_copy_from_slice", 0); - /* "View.MemoryView":1048 + /* "View.MemoryView":1047 * cdef int (*to_dtype_func)(char *, object) except 0 * * if isinstance(memview, _memoryviewslice): # <<<<<<<<<<<<<< @@ -14284,7 +14280,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview __pyx_t_2 = (__pyx_t_1 != 0); if (__pyx_t_2) { - /* "View.MemoryView":1049 + /* "View.MemoryView":1048 * * if isinstance(memview, _memoryviewslice): * to_object_func = (<_memoryviewslice> memview).to_object_func # <<<<<<<<<<<<<< @@ -14294,7 +14290,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview __pyx_t_3 = ((struct __pyx_memoryviewslice_obj *)__pyx_v_memview)->to_object_func; __pyx_v_to_object_func = __pyx_t_3; - /* "View.MemoryView":1050 + /* "View.MemoryView":1049 * if isinstance(memview, _memoryviewslice): * to_object_func = (<_memoryviewslice> memview).to_object_func * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func # <<<<<<<<<<<<<< @@ -14307,7 +14303,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview } /*else*/ { - /* "View.MemoryView":1052 + /* "View.MemoryView":1051 * to_dtype_func = (<_memoryviewslice> memview).to_dtype_func * else: * to_object_func = NULL # <<<<<<<<<<<<<< @@ -14316,7 +14312,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview */ __pyx_v_to_object_func = NULL; - /* "View.MemoryView":1053 + /* "View.MemoryView":1052 * else: * to_object_func = NULL * to_dtype_func = NULL # <<<<<<<<<<<<<< @@ -14327,7 +14323,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview } __pyx_L3:; - /* "View.MemoryView":1055 + /* "View.MemoryView":1054 * to_dtype_func = NULL * * return memoryview_fromslice(memviewslice[0], memview.view.ndim, # <<<<<<<<<<<<<< @@ -14336,20 +14332,20 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview */ __Pyx_XDECREF(__pyx_r); - /* "View.MemoryView":1057 + /* "View.MemoryView":1056 * return memoryview_fromslice(memviewslice[0], memview.view.ndim, * to_object_func, to_dtype_func, * memview.dtype_is_object) # <<<<<<<<<<<<<< * * */ - __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __pyx_memoryview_fromslice((__pyx_v_memviewslice[0]), __pyx_v_memview->view.ndim, __pyx_v_to_object_func, __pyx_v_to_dtype_func, __pyx_v_memview->dtype_is_object); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0; - /* "View.MemoryView":1041 + /* "View.MemoryView":1040 * * @cname('__pyx_memoryview_copy_object_from_slice') * cdef memoryview_copy_from_slice(memoryview memview, __Pyx_memviewslice *memviewslice): # <<<<<<<<<<<<<< @@ -14368,7 +14364,7 @@ static PyObject *__pyx_memoryview_copy_object_from_slice(struct __pyx_memoryview return __pyx_r; } -/* "View.MemoryView":1063 +/* "View.MemoryView":1062 * * * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< @@ -14380,7 +14376,7 @@ static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { Py_ssize_t __pyx_r; int __pyx_t_1; - /* "View.MemoryView":1064 + /* "View.MemoryView":1063 * * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: * if arg < 0: # <<<<<<<<<<<<<< @@ -14390,7 +14386,7 @@ static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { __pyx_t_1 = ((__pyx_v_arg < 0) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1065 + /* "View.MemoryView":1064 * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: * if arg < 0: * return -arg # <<<<<<<<<<<<<< @@ -14402,7 +14398,7 @@ static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { } /*else*/ { - /* "View.MemoryView":1067 + /* "View.MemoryView":1066 * return -arg * else: * return arg # <<<<<<<<<<<<<< @@ -14413,7 +14409,7 @@ static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { goto __pyx_L0; } - /* "View.MemoryView":1063 + /* "View.MemoryView":1062 * * * cdef Py_ssize_t abs_py_ssize_t(Py_ssize_t arg) nogil: # <<<<<<<<<<<<<< @@ -14426,7 +14422,7 @@ static Py_ssize_t abs_py_ssize_t(Py_ssize_t __pyx_v_arg) { return __pyx_r; } -/* "View.MemoryView":1070 +/* "View.MemoryView":1069 * * @cname('__pyx_get_best_slice_order') * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< @@ -14443,7 +14439,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ int __pyx_t_2; int __pyx_t_3; - /* "View.MemoryView":1075 + /* "View.MemoryView":1074 * """ * cdef int i * cdef Py_ssize_t c_stride = 0 # <<<<<<<<<<<<<< @@ -14452,7 +14448,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ */ __pyx_v_c_stride = 0; - /* "View.MemoryView":1076 + /* "View.MemoryView":1075 * cdef int i * cdef Py_ssize_t c_stride = 0 * cdef Py_ssize_t f_stride = 0 # <<<<<<<<<<<<<< @@ -14461,7 +14457,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ */ __pyx_v_f_stride = 0; - /* "View.MemoryView":1078 + /* "View.MemoryView":1077 * cdef Py_ssize_t f_stride = 0 * * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< @@ -14471,7 +14467,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1; - /* "View.MemoryView":1079 + /* "View.MemoryView":1078 * * for i in range(ndim - 1, -1, -1): * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< @@ -14481,7 +14477,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1080 + /* "View.MemoryView":1079 * for i in range(ndim - 1, -1, -1): * if mslice.shape[i] > 1: * c_stride = mslice.strides[i] # <<<<<<<<<<<<<< @@ -14490,7 +14486,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ */ __pyx_v_c_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - /* "View.MemoryView":1081 + /* "View.MemoryView":1080 * if mslice.shape[i] > 1: * c_stride = mslice.strides[i] * break # <<<<<<<<<<<<<< @@ -14502,7 +14498,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ } __pyx_L4_break:; - /* "View.MemoryView":1083 + /* "View.MemoryView":1082 * break * * for i in range(ndim): # <<<<<<<<<<<<<< @@ -14513,7 +14509,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_1; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1084 + /* "View.MemoryView":1083 * * for i in range(ndim): * if mslice.shape[i] > 1: # <<<<<<<<<<<<<< @@ -14523,7 +14519,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ __pyx_t_2 = (((__pyx_v_mslice->shape[__pyx_v_i]) > 1) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1085 + /* "View.MemoryView":1084 * for i in range(ndim): * if mslice.shape[i] > 1: * f_stride = mslice.strides[i] # <<<<<<<<<<<<<< @@ -14532,7 +14528,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ */ __pyx_v_f_stride = (__pyx_v_mslice->strides[__pyx_v_i]); - /* "View.MemoryView":1086 + /* "View.MemoryView":1085 * if mslice.shape[i] > 1: * f_stride = mslice.strides[i] * break # <<<<<<<<<<<<<< @@ -14544,7 +14540,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ } __pyx_L7_break:; - /* "View.MemoryView":1088 + /* "View.MemoryView":1087 * break * * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): # <<<<<<<<<<<<<< @@ -14554,7 +14550,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ __pyx_t_2 = ((abs_py_ssize_t(__pyx_v_c_stride) <= abs_py_ssize_t(__pyx_v_f_stride)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1089 + /* "View.MemoryView":1088 * * if abs_py_ssize_t(c_stride) <= abs_py_ssize_t(f_stride): * return 'C' # <<<<<<<<<<<<<< @@ -14566,7 +14562,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ } /*else*/ { - /* "View.MemoryView":1091 + /* "View.MemoryView":1090 * return 'C' * else: * return 'F' # <<<<<<<<<<<<<< @@ -14577,7 +14573,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ goto __pyx_L0; } - /* "View.MemoryView":1070 + /* "View.MemoryView":1069 * * @cname('__pyx_get_best_slice_order') * cdef char get_best_order(__Pyx_memviewslice *mslice, int ndim) nogil: # <<<<<<<<<<<<<< @@ -14590,7 +14586,7 @@ static char __pyx_get_best_slice_order(__Pyx_memviewslice *__pyx_v_mslice, int _ return __pyx_r; } -/* "View.MemoryView":1094 +/* "View.MemoryView":1093 * * @cython.cdivision(True) * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< @@ -14610,7 +14606,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v Py_ssize_t __pyx_t_4; Py_ssize_t __pyx_t_5; - /* "View.MemoryView":1101 + /* "View.MemoryView":1100 * * cdef Py_ssize_t i * cdef Py_ssize_t src_extent = src_shape[0] # <<<<<<<<<<<<<< @@ -14619,7 +14615,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_src_extent = (__pyx_v_src_shape[0]); - /* "View.MemoryView":1102 + /* "View.MemoryView":1101 * cdef Py_ssize_t i * cdef Py_ssize_t src_extent = src_shape[0] * cdef Py_ssize_t dst_extent = dst_shape[0] # <<<<<<<<<<<<<< @@ -14628,7 +14624,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_dst_extent = (__pyx_v_dst_shape[0]); - /* "View.MemoryView":1103 + /* "View.MemoryView":1102 * cdef Py_ssize_t src_extent = src_shape[0] * cdef Py_ssize_t dst_extent = dst_shape[0] * cdef Py_ssize_t src_stride = src_strides[0] # <<<<<<<<<<<<<< @@ -14637,7 +14633,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_src_stride = (__pyx_v_src_strides[0]); - /* "View.MemoryView":1104 + /* "View.MemoryView":1103 * cdef Py_ssize_t dst_extent = dst_shape[0] * cdef Py_ssize_t src_stride = src_strides[0] * cdef Py_ssize_t dst_stride = dst_strides[0] # <<<<<<<<<<<<<< @@ -14646,7 +14642,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_dst_stride = (__pyx_v_dst_strides[0]); - /* "View.MemoryView":1106 + /* "View.MemoryView":1105 * cdef Py_ssize_t dst_stride = dst_strides[0] * * if ndim == 1: # <<<<<<<<<<<<<< @@ -14656,7 +14652,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1107 + /* "View.MemoryView":1106 * * if ndim == 1: * if (src_stride > 0 and dst_stride > 0 and # <<<<<<<<<<<<<< @@ -14665,18 +14661,22 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_t_2 = ((__pyx_v_src_stride > 0) != 0); if (__pyx_t_2) { + goto __pyx_L6_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } + __pyx_L6_next_and:; __pyx_t_2 = ((__pyx_v_dst_stride > 0) != 0); if (__pyx_t_2) { + goto __pyx_L7_next_and; } else { __pyx_t_1 = __pyx_t_2; goto __pyx_L5_bool_binop_done; } + __pyx_L7_next_and:; - /* "View.MemoryView":1108 + /* "View.MemoryView":1107 * if ndim == 1: * if (src_stride > 0 and dst_stride > 0 and * src_stride == itemsize == dst_stride): # <<<<<<<<<<<<<< @@ -14692,7 +14692,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v __pyx_L5_bool_binop_done:; if (__pyx_t_1) { - /* "View.MemoryView":1109 + /* "View.MemoryView":1108 * if (src_stride > 0 and dst_stride > 0 and * src_stride == itemsize == dst_stride): * memcpy(dst_data, src_data, itemsize * dst_extent) # <<<<<<<<<<<<<< @@ -14704,7 +14704,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v } /*else*/ { - /* "View.MemoryView":1111 + /* "View.MemoryView":1110 * memcpy(dst_data, src_data, itemsize * dst_extent) * else: * for i in range(dst_extent): # <<<<<<<<<<<<<< @@ -14715,7 +14715,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "View.MemoryView":1112 + /* "View.MemoryView":1111 * else: * for i in range(dst_extent): * memcpy(dst_data, src_data, itemsize) # <<<<<<<<<<<<<< @@ -14724,7 +14724,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ memcpy(__pyx_v_dst_data, __pyx_v_src_data, __pyx_v_itemsize); - /* "View.MemoryView":1113 + /* "View.MemoryView":1112 * for i in range(dst_extent): * memcpy(dst_data, src_data, itemsize) * src_data += src_stride # <<<<<<<<<<<<<< @@ -14733,7 +14733,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); - /* "View.MemoryView":1114 + /* "View.MemoryView":1113 * memcpy(dst_data, src_data, itemsize) * src_data += src_stride * dst_data += dst_stride # <<<<<<<<<<<<<< @@ -14748,7 +14748,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v } /*else*/ { - /* "View.MemoryView":1116 + /* "View.MemoryView":1115 * dst_data += dst_stride * else: * for i in range(dst_extent): # <<<<<<<<<<<<<< @@ -14759,7 +14759,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "View.MemoryView":1117 + /* "View.MemoryView":1116 * else: * for i in range(dst_extent): * _copy_strided_to_strided(src_data, src_strides + 1, # <<<<<<<<<<<<<< @@ -14768,7 +14768,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ _copy_strided_to_strided(__pyx_v_src_data, (__pyx_v_src_strides + 1), __pyx_v_dst_data, (__pyx_v_dst_strides + 1), (__pyx_v_src_shape + 1), (__pyx_v_dst_shape + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize); - /* "View.MemoryView":1121 + /* "View.MemoryView":1120 * src_shape + 1, dst_shape + 1, * ndim - 1, itemsize) * src_data += src_stride # <<<<<<<<<<<<<< @@ -14777,7 +14777,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v */ __pyx_v_src_data = (__pyx_v_src_data + __pyx_v_src_stride); - /* "View.MemoryView":1122 + /* "View.MemoryView":1121 * ndim - 1, itemsize) * src_data += src_stride * dst_data += dst_stride # <<<<<<<<<<<<<< @@ -14789,7 +14789,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v } __pyx_L3:; - /* "View.MemoryView":1094 + /* "View.MemoryView":1093 * * @cython.cdivision(True) * cdef void _copy_strided_to_strided(char *src_data, Py_ssize_t *src_strides, # <<<<<<<<<<<<<< @@ -14800,7 +14800,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v /* function exit code */ } -/* "View.MemoryView":1124 +/* "View.MemoryView":1123 * dst_data += dst_stride * * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< @@ -14810,7 +14810,7 @@ static void _copy_strided_to_strided(char *__pyx_v_src_data, Py_ssize_t *__pyx_v static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize) { - /* "View.MemoryView":1127 + /* "View.MemoryView":1126 * __Pyx_memviewslice *dst, * int ndim, size_t itemsize) nogil: * _copy_strided_to_strided(src.data, src.strides, dst.data, dst.strides, # <<<<<<<<<<<<<< @@ -14819,7 +14819,7 @@ static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memvi */ _copy_strided_to_strided(__pyx_v_src->data, __pyx_v_src->strides, __pyx_v_dst->data, __pyx_v_dst->strides, __pyx_v_src->shape, __pyx_v_dst->shape, __pyx_v_ndim, __pyx_v_itemsize); - /* "View.MemoryView":1124 + /* "View.MemoryView":1123 * dst_data += dst_stride * * cdef void copy_strided_to_strided(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< @@ -14830,7 +14830,7 @@ static void copy_strided_to_strided(__Pyx_memviewslice *__pyx_v_src, __Pyx_memvi /* function exit code */ } -/* "View.MemoryView":1131 +/* "View.MemoryView":1130 * * @cname('__pyx_memoryview_slice_get_size') * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< @@ -14846,7 +14846,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr int __pyx_t_2; int __pyx_t_3; - /* "View.MemoryView":1134 + /* "View.MemoryView":1133 * "Return the size of the memory occupied by the slice in number of bytes" * cdef int i * cdef Py_ssize_t size = src.memview.view.itemsize # <<<<<<<<<<<<<< @@ -14856,7 +14856,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr __pyx_t_1 = __pyx_v_src->memview->view.itemsize; __pyx_v_size = __pyx_t_1; - /* "View.MemoryView":1136 + /* "View.MemoryView":1135 * cdef Py_ssize_t size = src.memview.view.itemsize * * for i in range(ndim): # <<<<<<<<<<<<<< @@ -14867,7 +14867,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1137 + /* "View.MemoryView":1136 * * for i in range(ndim): * size *= src.shape[i] # <<<<<<<<<<<<<< @@ -14877,7 +14877,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr __pyx_v_size = (__pyx_v_size * (__pyx_v_src->shape[__pyx_v_i])); } - /* "View.MemoryView":1139 + /* "View.MemoryView":1138 * size *= src.shape[i] * * return size # <<<<<<<<<<<<<< @@ -14887,7 +14887,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr __pyx_r = __pyx_v_size; goto __pyx_L0; - /* "View.MemoryView":1131 + /* "View.MemoryView":1130 * * @cname('__pyx_memoryview_slice_get_size') * cdef Py_ssize_t slice_get_size(__Pyx_memviewslice *src, int ndim) nogil: # <<<<<<<<<<<<<< @@ -14900,7 +14900,7 @@ static Py_ssize_t __pyx_memoryview_slice_get_size(__Pyx_memviewslice *__pyx_v_sr return __pyx_r; } -/* "View.MemoryView":1142 +/* "View.MemoryView":1141 * * @cname('__pyx_fill_contig_strides_array') * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< @@ -14915,7 +14915,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ int __pyx_t_2; int __pyx_t_3; - /* "View.MemoryView":1151 + /* "View.MemoryView":1150 * cdef int idx * * if order == 'F': # <<<<<<<<<<<<<< @@ -14925,7 +14925,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ __pyx_t_1 = ((__pyx_v_order == 'F') != 0); if (__pyx_t_1) { - /* "View.MemoryView":1152 + /* "View.MemoryView":1151 * * if order == 'F': * for idx in range(ndim): # <<<<<<<<<<<<<< @@ -14936,7 +14936,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_idx = __pyx_t_3; - /* "View.MemoryView":1153 + /* "View.MemoryView":1152 * if order == 'F': * for idx in range(ndim): * strides[idx] = stride # <<<<<<<<<<<<<< @@ -14945,7 +14945,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ */ (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; - /* "View.MemoryView":1154 + /* "View.MemoryView":1153 * for idx in range(ndim): * strides[idx] = stride * stride = stride * shape[idx] # <<<<<<<<<<<<<< @@ -14958,7 +14958,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ } /*else*/ { - /* "View.MemoryView":1156 + /* "View.MemoryView":1155 * stride = stride * shape[idx] * else: * for idx in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< @@ -14968,7 +14968,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ for (__pyx_t_2 = (__pyx_v_ndim - 1); __pyx_t_2 > -1; __pyx_t_2-=1) { __pyx_v_idx = __pyx_t_2; - /* "View.MemoryView":1157 + /* "View.MemoryView":1156 * else: * for idx in range(ndim - 1, -1, -1): * strides[idx] = stride # <<<<<<<<<<<<<< @@ -14977,7 +14977,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ */ (__pyx_v_strides[__pyx_v_idx]) = __pyx_v_stride; - /* "View.MemoryView":1158 + /* "View.MemoryView":1157 * for idx in range(ndim - 1, -1, -1): * strides[idx] = stride * stride = stride * shape[idx] # <<<<<<<<<<<<<< @@ -14989,7 +14989,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ } __pyx_L3:; - /* "View.MemoryView":1160 + /* "View.MemoryView":1159 * stride = stride * shape[idx] * * return stride # <<<<<<<<<<<<<< @@ -14999,7 +14999,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ __pyx_r = __pyx_v_stride; goto __pyx_L0; - /* "View.MemoryView":1142 + /* "View.MemoryView":1141 * * @cname('__pyx_fill_contig_strides_array') * cdef Py_ssize_t fill_contig_strides_array( # <<<<<<<<<<<<<< @@ -15012,7 +15012,7 @@ static Py_ssize_t __pyx_fill_contig_strides_array(Py_ssize_t *__pyx_v_shape, Py_ return __pyx_r; } -/* "View.MemoryView":1163 +/* "View.MemoryView":1162 * * @cname('__pyx_memoryview_copy_data_to_temp') * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< @@ -15035,7 +15035,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, const char *__pyx_filename = NULL; int __pyx_clineno = 0; - /* "View.MemoryView":1174 + /* "View.MemoryView":1173 * cdef void *result * * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< @@ -15045,7 +15045,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_t_1 = __pyx_v_src->memview->view.itemsize; __pyx_v_itemsize = __pyx_t_1; - /* "View.MemoryView":1175 + /* "View.MemoryView":1174 * * cdef size_t itemsize = src.memview.view.itemsize * cdef size_t size = slice_get_size(src, ndim) # <<<<<<<<<<<<<< @@ -15054,7 +15054,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, */ __pyx_v_size = __pyx_memoryview_slice_get_size(__pyx_v_src, __pyx_v_ndim); - /* "View.MemoryView":1177 + /* "View.MemoryView":1176 * cdef size_t size = slice_get_size(src, ndim) * * result = malloc(size) # <<<<<<<<<<<<<< @@ -15063,7 +15063,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, */ __pyx_v_result = malloc(__pyx_v_size); - /* "View.MemoryView":1178 + /* "View.MemoryView":1177 * * result = malloc(size) * if not result: # <<<<<<<<<<<<<< @@ -15073,19 +15073,19 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_t_2 = ((!(__pyx_v_result != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1179 + /* "View.MemoryView":1178 * result = malloc(size) * if not result: * _err(MemoryError, NULL) # <<<<<<<<<<<<<< * * */ - __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_memoryview_err(__pyx_builtin_MemoryError, NULL); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "View.MemoryView":1182 + /* "View.MemoryView":1181 * * * tmpslice.data = result # <<<<<<<<<<<<<< @@ -15094,7 +15094,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, */ __pyx_v_tmpslice->data = ((char *)__pyx_v_result); - /* "View.MemoryView":1183 + /* "View.MemoryView":1182 * * tmpslice.data = result * tmpslice.memview = src.memview # <<<<<<<<<<<<<< @@ -15104,7 +15104,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_t_4 = __pyx_v_src->memview; __pyx_v_tmpslice->memview = __pyx_t_4; - /* "View.MemoryView":1184 + /* "View.MemoryView":1183 * tmpslice.data = result * tmpslice.memview = src.memview * for i in range(ndim): # <<<<<<<<<<<<<< @@ -15115,7 +15115,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "View.MemoryView":1185 + /* "View.MemoryView":1184 * tmpslice.memview = src.memview * for i in range(ndim): * tmpslice.shape[i] = src.shape[i] # <<<<<<<<<<<<<< @@ -15124,7 +15124,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, */ (__pyx_v_tmpslice->shape[__pyx_v_i]) = (__pyx_v_src->shape[__pyx_v_i]); - /* "View.MemoryView":1186 + /* "View.MemoryView":1185 * for i in range(ndim): * tmpslice.shape[i] = src.shape[i] * tmpslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< @@ -15134,7 +15134,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, (__pyx_v_tmpslice->suboffsets[__pyx_v_i]) = -1; } - /* "View.MemoryView":1188 + /* "View.MemoryView":1187 * tmpslice.suboffsets[i] = -1 * * fill_contig_strides_array(&tmpslice.shape[0], &tmpslice.strides[0], itemsize, # <<<<<<<<<<<<<< @@ -15143,7 +15143,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, */ __pyx_fill_contig_strides_array((&(__pyx_v_tmpslice->shape[0])), (&(__pyx_v_tmpslice->strides[0])), __pyx_v_itemsize, __pyx_v_ndim, __pyx_v_order); - /* "View.MemoryView":1192 + /* "View.MemoryView":1191 * * * for i in range(ndim): # <<<<<<<<<<<<<< @@ -15154,7 +15154,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_3; __pyx_t_5+=1) { __pyx_v_i = __pyx_t_5; - /* "View.MemoryView":1193 + /* "View.MemoryView":1192 * * for i in range(ndim): * if tmpslice.shape[i] == 1: # <<<<<<<<<<<<<< @@ -15164,7 +15164,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_t_2 = (((__pyx_v_tmpslice->shape[__pyx_v_i]) == 1) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1194 + /* "View.MemoryView":1193 * for i in range(ndim): * if tmpslice.shape[i] == 1: * tmpslice.strides[i] = 0 # <<<<<<<<<<<<<< @@ -15177,7 +15177,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_L8:; } - /* "View.MemoryView":1196 + /* "View.MemoryView":1195 * tmpslice.strides[i] = 0 * * if slice_is_contig(src, order, ndim): # <<<<<<<<<<<<<< @@ -15187,7 +15187,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_t_2 = (__pyx_memviewslice_is_contig(__pyx_v_src, __pyx_v_order, __pyx_v_ndim) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1197 + /* "View.MemoryView":1196 * * if slice_is_contig(src, order, ndim): * memcpy(result, src.data, size) # <<<<<<<<<<<<<< @@ -15199,7 +15199,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, } /*else*/ { - /* "View.MemoryView":1199 + /* "View.MemoryView":1198 * memcpy(result, src.data, size) * else: * copy_strided_to_strided(src, tmpslice, ndim, itemsize) # <<<<<<<<<<<<<< @@ -15210,7 +15210,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, } __pyx_L9:; - /* "View.MemoryView":1201 + /* "View.MemoryView":1200 * copy_strided_to_strided(src, tmpslice, ndim, itemsize) * * return result # <<<<<<<<<<<<<< @@ -15220,7 +15220,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, __pyx_r = __pyx_v_result; goto __pyx_L0; - /* "View.MemoryView":1163 + /* "View.MemoryView":1162 * * @cname('__pyx_memoryview_copy_data_to_temp') * cdef void *copy_data_to_temp(__Pyx_memviewslice *src, # <<<<<<<<<<<<<< @@ -15244,7 +15244,7 @@ static void *__pyx_memoryview_copy_data_to_temp(__Pyx_memviewslice *__pyx_v_src, return __pyx_r; } -/* "View.MemoryView":1206 +/* "View.MemoryView":1205 * * @cname('__pyx_memoryview_err_extents') * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< @@ -15267,20 +15267,20 @@ static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent #endif __Pyx_RefNannySetupContext("_err_extents", 0); - /* "View.MemoryView":1209 + /* "View.MemoryView":1208 * Py_ssize_t extent2) except -1 with gil: * raise ValueError("got differing extents in dimension %d (got %d and %d)" % * (i, extent1, extent2)) # <<<<<<<<<<<<<< * * @cname('__pyx_memoryview_err_dim') */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_extent1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_extent2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __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); @@ -15292,29 +15292,29 @@ static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent __pyx_t_2 = 0; __pyx_t_3 = 0; - /* "View.MemoryView":1208 + /* "View.MemoryView":1207 * cdef int _err_extents(int i, Py_ssize_t extent1, * Py_ssize_t extent2) except -1 with gil: * raise ValueError("got differing extents in dimension %d (got %d and %d)" % # <<<<<<<<<<<<<< * (i, extent1, extent2)) * */ - __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "View.MemoryView":1206 + /* "View.MemoryView":1205 * * @cname('__pyx_memoryview_err_extents') * cdef int _err_extents(int i, Py_ssize_t extent1, # <<<<<<<<<<<<<< @@ -15337,7 +15337,7 @@ static int __pyx_memoryview_err_extents(int __pyx_v_i, Py_ssize_t __pyx_v_extent return __pyx_r; } -/* "View.MemoryView":1212 +/* "View.MemoryView":1211 * * @cname('__pyx_memoryview_err_dim') * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< @@ -15362,18 +15362,18 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, __Pyx_RefNannySetupContext("_err_dim", 0); __Pyx_INCREF(__pyx_v_error); - /* "View.MemoryView":1213 + /* "View.MemoryView":1212 * @cname('__pyx_memoryview_err_dim') * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: * raise error(msg.decode('ascii') % dim) # <<<<<<<<<<<<<< * * @cname('__pyx_memoryview_err') */ - __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_dim); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyUnicode_Format(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -15389,26 +15389,26 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, } } if (!__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_1); } else { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = NULL; PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "View.MemoryView":1212 + /* "View.MemoryView":1211 * * @cname('__pyx_memoryview_err_dim') * cdef int _err_dim(object error, char *msg, int dim) except -1 with gil: # <<<<<<<<<<<<<< @@ -15433,7 +15433,7 @@ static int __pyx_memoryview_err_dim(PyObject *__pyx_v_error, char *__pyx_v_msg, return __pyx_r; } -/* "View.MemoryView":1216 +/* "View.MemoryView":1215 * * @cname('__pyx_memoryview_err') * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< @@ -15459,7 +15459,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __Pyx_RefNannySetupContext("_err", 0); __Pyx_INCREF(__pyx_v_error); - /* "View.MemoryView":1217 + /* "View.MemoryView":1216 * @cname('__pyx_memoryview_err') * cdef int _err(object error, char *msg) except -1 with gil: * if msg != NULL: # <<<<<<<<<<<<<< @@ -15469,14 +15469,14 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { __pyx_t_1 = ((__pyx_v_msg != NULL) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1218 + /* "View.MemoryView":1217 * cdef int _err(object error, char *msg) except -1 with gil: * if msg != NULL: * raise error(msg.decode('ascii')) # <<<<<<<<<<<<<< * else: * raise error */ - __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_msg, 0, strlen(__pyx_v_msg), NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_error); __pyx_t_4 = __pyx_v_error; __pyx_t_5 = NULL; @@ -15490,28 +15490,28 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { } } if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_GOTREF(__pyx_t_2); } else { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); __pyx_t_5 = NULL; PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } /*else*/ { - /* "View.MemoryView":1220 + /* "View.MemoryView":1219 * raise error(msg.decode('ascii')) * else: * raise error # <<<<<<<<<<<<<< @@ -15519,10 +15519,10 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { * @cname('__pyx_memoryview_copy_contents') */ __Pyx_Raise(__pyx_v_error, 0, 0, 0); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1220; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - /* "View.MemoryView":1216 + /* "View.MemoryView":1215 * * @cname('__pyx_memoryview_err') * cdef int _err(object error, char *msg) except -1 with gil: # <<<<<<<<<<<<<< @@ -15547,7 +15547,7 @@ static int __pyx_memoryview_err(PyObject *__pyx_v_error, char *__pyx_v_msg) { return __pyx_r; } -/* "View.MemoryView":1223 +/* "View.MemoryView":1222 * * @cname('__pyx_memoryview_copy_contents') * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< @@ -15576,7 +15576,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ const char *__pyx_filename = NULL; int __pyx_clineno = 0; - /* "View.MemoryView":1231 + /* "View.MemoryView":1230 * Check for overlapping memory and verify the shapes. * """ * cdef void *tmpdata = NULL # <<<<<<<<<<<<<< @@ -15585,7 +15585,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_v_tmpdata = NULL; - /* "View.MemoryView":1232 + /* "View.MemoryView":1231 * """ * cdef void *tmpdata = NULL * cdef size_t itemsize = src.memview.view.itemsize # <<<<<<<<<<<<<< @@ -15595,7 +15595,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_1 = __pyx_v_src.memview->view.itemsize; __pyx_v_itemsize = __pyx_t_1; - /* "View.MemoryView":1234 + /* "View.MemoryView":1233 * cdef size_t itemsize = src.memview.view.itemsize * cdef int i * cdef char order = get_best_order(&src, src_ndim) # <<<<<<<<<<<<<< @@ -15604,7 +15604,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_v_order = __pyx_get_best_slice_order((&__pyx_v_src), __pyx_v_src_ndim); - /* "View.MemoryView":1235 + /* "View.MemoryView":1234 * cdef int i * cdef char order = get_best_order(&src, src_ndim) * cdef bint broadcasting = False # <<<<<<<<<<<<<< @@ -15613,7 +15613,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_v_broadcasting = 0; - /* "View.MemoryView":1236 + /* "View.MemoryView":1235 * cdef char order = get_best_order(&src, src_ndim) * cdef bint broadcasting = False * cdef bint direct_copy = False # <<<<<<<<<<<<<< @@ -15622,7 +15622,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_v_direct_copy = 0; - /* "View.MemoryView":1239 + /* "View.MemoryView":1238 * cdef __Pyx_memviewslice tmp * * if src_ndim < dst_ndim: # <<<<<<<<<<<<<< @@ -15632,7 +15632,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = ((__pyx_v_src_ndim < __pyx_v_dst_ndim) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1240 + /* "View.MemoryView":1239 * * if src_ndim < dst_ndim: * broadcast_leading(&src, src_ndim, dst_ndim) # <<<<<<<<<<<<<< @@ -15643,7 +15643,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ goto __pyx_L3; } - /* "View.MemoryView":1241 + /* "View.MemoryView":1240 * if src_ndim < dst_ndim: * broadcast_leading(&src, src_ndim, dst_ndim) * elif dst_ndim < src_ndim: # <<<<<<<<<<<<<< @@ -15653,7 +15653,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = ((__pyx_v_dst_ndim < __pyx_v_src_ndim) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1242 + /* "View.MemoryView":1241 * broadcast_leading(&src, src_ndim, dst_ndim) * elif dst_ndim < src_ndim: * broadcast_leading(&dst, dst_ndim, src_ndim) # <<<<<<<<<<<<<< @@ -15665,7 +15665,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_L3:; - /* "View.MemoryView":1244 + /* "View.MemoryView":1243 * broadcast_leading(&dst, dst_ndim, src_ndim) * * cdef int ndim = max(src_ndim, dst_ndim) # <<<<<<<<<<<<<< @@ -15681,7 +15681,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_v_ndim = __pyx_t_5; - /* "View.MemoryView":1246 + /* "View.MemoryView":1245 * cdef int ndim = max(src_ndim, dst_ndim) * * for i in range(ndim): # <<<<<<<<<<<<<< @@ -15692,7 +15692,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_5; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1247 + /* "View.MemoryView":1246 * * for i in range(ndim): * if src.shape[i] != dst.shape[i]: # <<<<<<<<<<<<<< @@ -15702,7 +15702,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) != (__pyx_v_dst.shape[__pyx_v_i])) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1248 + /* "View.MemoryView":1247 * for i in range(ndim): * if src.shape[i] != dst.shape[i]: * if src.shape[i] == 1: # <<<<<<<<<<<<<< @@ -15712,7 +15712,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (((__pyx_v_src.shape[__pyx_v_i]) == 1) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1249 + /* "View.MemoryView":1248 * if src.shape[i] != dst.shape[i]: * if src.shape[i] == 1: * broadcasting = True # <<<<<<<<<<<<<< @@ -15721,7 +15721,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_v_broadcasting = 1; - /* "View.MemoryView":1250 + /* "View.MemoryView":1249 * if src.shape[i] == 1: * broadcasting = True * src.strides[i] = 0 # <<<<<<<<<<<<<< @@ -15733,21 +15733,21 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } /*else*/ { - /* "View.MemoryView":1252 + /* "View.MemoryView":1251 * src.strides[i] = 0 * else: * _err_extents(i, dst.shape[i], src.shape[i]) # <<<<<<<<<<<<<< * * if src.suboffsets[i] >= 0: */ - __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __pyx_memoryview_err_extents(__pyx_v_i, (__pyx_v_dst.shape[__pyx_v_i]), (__pyx_v_src.shape[__pyx_v_i])); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L7:; goto __pyx_L6; } __pyx_L6:; - /* "View.MemoryView":1254 + /* "View.MemoryView":1253 * _err_extents(i, dst.shape[i], src.shape[i]) * * if src.suboffsets[i] >= 0: # <<<<<<<<<<<<<< @@ -15757,20 +15757,20 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (((__pyx_v_src.suboffsets[__pyx_v_i]) >= 0) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1255 + /* "View.MemoryView":1254 * * if src.suboffsets[i] >= 0: * _err_dim(ValueError, "Dimension %d is not direct", i) # <<<<<<<<<<<<<< * * if slices_overlap(&src, &dst, ndim, itemsize): */ - __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Dimension_d_is_not_direct, __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __pyx_memoryview_err_dim(__pyx_builtin_ValueError, __pyx_k_Dimension_d_is_not_direct, __pyx_v_i); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; } - /* "View.MemoryView":1257 + /* "View.MemoryView":1256 * _err_dim(ValueError, "Dimension %d is not direct", i) * * if slices_overlap(&src, &dst, ndim, itemsize): # <<<<<<<<<<<<<< @@ -15780,7 +15780,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (__pyx_slices_overlap((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1259 + /* "View.MemoryView":1258 * if slices_overlap(&src, &dst, ndim, itemsize): * * if not slice_is_contig(&src, order, ndim): # <<<<<<<<<<<<<< @@ -15790,7 +15790,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = ((!(__pyx_memviewslice_is_contig((&__pyx_v_src), __pyx_v_order, __pyx_v_ndim) != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1260 + /* "View.MemoryView":1259 * * if not slice_is_contig(&src, order, ndim): * order = get_best_order(&dst, ndim) # <<<<<<<<<<<<<< @@ -15802,17 +15802,17 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_L10:; - /* "View.MemoryView":1262 + /* "View.MemoryView":1261 * order = get_best_order(&dst, ndim) * * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) # <<<<<<<<<<<<<< * src = tmp * */ - __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __pyx_memoryview_copy_data_to_temp((&__pyx_v_src), (&__pyx_v_tmp), __pyx_v_order, __pyx_v_ndim); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1261; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_tmpdata = __pyx_t_6; - /* "View.MemoryView":1263 + /* "View.MemoryView":1262 * * tmpdata = copy_data_to_temp(&src, &tmp, order, ndim) * src = tmp # <<<<<<<<<<<<<< @@ -15824,7 +15824,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_L9:; - /* "View.MemoryView":1265 + /* "View.MemoryView":1264 * src = tmp * * if not broadcasting: # <<<<<<<<<<<<<< @@ -15834,7 +15834,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = ((!(__pyx_v_broadcasting != 0)) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1268 + /* "View.MemoryView":1267 * * * if slice_is_contig(&src, 'C', ndim): # <<<<<<<<<<<<<< @@ -15844,7 +15844,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'C', __pyx_v_ndim) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1269 + /* "View.MemoryView":1268 * * if slice_is_contig(&src, 'C', ndim): * direct_copy = slice_is_contig(&dst, 'C', ndim) # <<<<<<<<<<<<<< @@ -15855,7 +15855,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ goto __pyx_L12; } - /* "View.MemoryView":1270 + /* "View.MemoryView":1269 * if slice_is_contig(&src, 'C', ndim): * direct_copy = slice_is_contig(&dst, 'C', ndim) * elif slice_is_contig(&src, 'F', ndim): # <<<<<<<<<<<<<< @@ -15865,7 +15865,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (__pyx_memviewslice_is_contig((&__pyx_v_src), 'F', __pyx_v_ndim) != 0); if (__pyx_t_2) { - /* "View.MemoryView":1271 + /* "View.MemoryView":1270 * direct_copy = slice_is_contig(&dst, 'C', ndim) * elif slice_is_contig(&src, 'F', ndim): * direct_copy = slice_is_contig(&dst, 'F', ndim) # <<<<<<<<<<<<<< @@ -15877,7 +15877,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_L12:; - /* "View.MemoryView":1273 + /* "View.MemoryView":1272 * direct_copy = slice_is_contig(&dst, 'F', ndim) * * if direct_copy: # <<<<<<<<<<<<<< @@ -15887,7 +15887,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_2 = (__pyx_v_direct_copy != 0); if (__pyx_t_2) { - /* "View.MemoryView":1275 + /* "View.MemoryView":1274 * if direct_copy: * * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< @@ -15896,7 +15896,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - /* "View.MemoryView":1276 + /* "View.MemoryView":1275 * * refcount_copying(&dst, dtype_is_object, ndim, False) * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) # <<<<<<<<<<<<<< @@ -15905,7 +15905,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ memcpy(__pyx_v_dst.data, __pyx_v_src.data, __pyx_memoryview_slice_get_size((&__pyx_v_src), __pyx_v_ndim)); - /* "View.MemoryView":1277 + /* "View.MemoryView":1276 * refcount_copying(&dst, dtype_is_object, ndim, False) * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< @@ -15914,7 +15914,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - /* "View.MemoryView":1278 + /* "View.MemoryView":1277 * memcpy(dst.data, src.data, slice_get_size(&src, ndim)) * refcount_copying(&dst, dtype_is_object, ndim, True) * free(tmpdata) # <<<<<<<<<<<<<< @@ -15923,7 +15923,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ free(__pyx_v_tmpdata); - /* "View.MemoryView":1279 + /* "View.MemoryView":1278 * refcount_copying(&dst, dtype_is_object, ndim, True) * free(tmpdata) * return 0 # <<<<<<<<<<<<<< @@ -15937,7 +15937,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ } __pyx_L11:; - /* "View.MemoryView":1281 + /* "View.MemoryView":1280 * return 0 * * if order == 'F' == get_best_order(&dst, ndim): # <<<<<<<<<<<<<< @@ -15951,28 +15951,28 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_t_7 = (__pyx_t_2 != 0); if (__pyx_t_7) { - /* "View.MemoryView":1284 + /* "View.MemoryView":1283 * * * transpose_memslice(&src) # <<<<<<<<<<<<<< * transpose_memslice(&dst) * */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_src)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "View.MemoryView":1285 + /* "View.MemoryView":1284 * * transpose_memslice(&src) * transpose_memslice(&dst) # <<<<<<<<<<<<<< * * refcount_copying(&dst, dtype_is_object, ndim, False) */ - __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __pyx_memslice_transpose((&__pyx_v_dst)); if (unlikely(__pyx_t_5 == 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L14; } __pyx_L14:; - /* "View.MemoryView":1287 + /* "View.MemoryView":1286 * transpose_memslice(&dst) * * refcount_copying(&dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< @@ -15981,7 +15981,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - /* "View.MemoryView":1288 + /* "View.MemoryView":1287 * * refcount_copying(&dst, dtype_is_object, ndim, False) * copy_strided_to_strided(&src, &dst, ndim, itemsize) # <<<<<<<<<<<<<< @@ -15990,7 +15990,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ copy_strided_to_strided((&__pyx_v_src), (&__pyx_v_dst), __pyx_v_ndim, __pyx_v_itemsize); - /* "View.MemoryView":1289 + /* "View.MemoryView":1288 * refcount_copying(&dst, dtype_is_object, ndim, False) * copy_strided_to_strided(&src, &dst, ndim, itemsize) * refcount_copying(&dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< @@ -15999,7 +15999,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ __pyx_memoryview_refcount_copying((&__pyx_v_dst), __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - /* "View.MemoryView":1291 + /* "View.MemoryView":1290 * refcount_copying(&dst, dtype_is_object, ndim, True) * * free(tmpdata) # <<<<<<<<<<<<<< @@ -16008,7 +16008,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ */ free(__pyx_v_tmpdata); - /* "View.MemoryView":1292 + /* "View.MemoryView":1291 * * free(tmpdata) * return 0 # <<<<<<<<<<<<<< @@ -16018,7 +16018,7 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ __pyx_r = 0; goto __pyx_L0; - /* "View.MemoryView":1223 + /* "View.MemoryView":1222 * * @cname('__pyx_memoryview_copy_contents') * cdef int memoryview_copy_contents(__Pyx_memviewslice src, # <<<<<<<<<<<<<< @@ -16042,21 +16042,21 @@ static int __pyx_memoryview_copy_contents(__Pyx_memviewslice __pyx_v_src, __Pyx_ return __pyx_r; } -/* "View.MemoryView":1295 +/* "View.MemoryView":1294 * * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * cdef void broadcast_leading(__Pyx_memviewslice *slice, # <<<<<<<<<<<<<< * int ndim, * int ndim_other) nogil: */ -static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslice, int __pyx_v_ndim, int __pyx_v_ndim_other) { +static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_slice, int __pyx_v_ndim, int __pyx_v_ndim_other) { int __pyx_v_i; int __pyx_v_offset; int __pyx_t_1; int __pyx_t_2; - /* "View.MemoryView":1299 + /* "View.MemoryView":1298 * int ndim_other) nogil: * cdef int i * cdef int offset = ndim_other - ndim # <<<<<<<<<<<<<< @@ -16065,87 +16065,87 @@ static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslic */ __pyx_v_offset = (__pyx_v_ndim_other - __pyx_v_ndim); - /* "View.MemoryView":1301 + /* "View.MemoryView":1300 * cdef int offset = ndim_other - ndim * * for i in range(ndim - 1, -1, -1): # <<<<<<<<<<<<<< - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] + * slice.shape[i + offset] = slice.shape[i] + * slice.strides[i + offset] = slice.strides[i] */ for (__pyx_t_1 = (__pyx_v_ndim - 1); __pyx_t_1 > -1; __pyx_t_1-=1) { __pyx_v_i = __pyx_t_1; - /* "View.MemoryView":1302 + /* "View.MemoryView":1301 * * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] # <<<<<<<<<<<<<< - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + * slice.shape[i + offset] = slice.shape[i] # <<<<<<<<<<<<<< + * slice.strides[i + offset] = slice.strides[i] + * slice.suboffsets[i + offset] = slice.suboffsets[i] */ - (__pyx_v_mslice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->shape[__pyx_v_i]); + (__pyx_v_slice->shape[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->shape[__pyx_v_i]); + + /* "View.MemoryView":1302 + * for i in range(ndim - 1, -1, -1): + * slice.shape[i + offset] = slice.shape[i] + * slice.strides[i + offset] = slice.strides[i] # <<<<<<<<<<<<<< + * slice.suboffsets[i + offset] = slice.suboffsets[i] + * + */ + (__pyx_v_slice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->strides[__pyx_v_i]); /* "View.MemoryView":1303 - * for i in range(ndim - 1, -1, -1): - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] # <<<<<<<<<<<<<< - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] - * - */ - (__pyx_v_mslice->strides[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->strides[__pyx_v_i]); - - /* "View.MemoryView":1304 - * mslice.shape[i + offset] = mslice.shape[i] - * mslice.strides[i + offset] = mslice.strides[i] - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] # <<<<<<<<<<<<<< + * slice.shape[i + offset] = slice.shape[i] + * slice.strides[i + offset] = slice.strides[i] + * slice.suboffsets[i + offset] = slice.suboffsets[i] # <<<<<<<<<<<<<< * * for i in range(offset): */ - (__pyx_v_mslice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_mslice->suboffsets[__pyx_v_i]); + (__pyx_v_slice->suboffsets[(__pyx_v_i + __pyx_v_offset)]) = (__pyx_v_slice->suboffsets[__pyx_v_i]); } - /* "View.MemoryView":1306 - * mslice.suboffsets[i + offset] = mslice.suboffsets[i] + /* "View.MemoryView":1305 + * slice.suboffsets[i + offset] = slice.suboffsets[i] * * for i in range(offset): # <<<<<<<<<<<<<< - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] + * slice.shape[i] = 1 + * slice.strides[i] = slice.strides[0] */ __pyx_t_1 = __pyx_v_offset; for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "View.MemoryView":1307 + /* "View.MemoryView":1306 * * for i in range(offset): - * mslice.shape[i] = 1 # <<<<<<<<<<<<<< - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 + * slice.shape[i] = 1 # <<<<<<<<<<<<<< + * slice.strides[i] = slice.strides[0] + * slice.suboffsets[i] = -1 */ - (__pyx_v_mslice->shape[__pyx_v_i]) = 1; + (__pyx_v_slice->shape[__pyx_v_i]) = 1; + + /* "View.MemoryView":1307 + * for i in range(offset): + * slice.shape[i] = 1 + * slice.strides[i] = slice.strides[0] # <<<<<<<<<<<<<< + * slice.suboffsets[i] = -1 + * + */ + (__pyx_v_slice->strides[__pyx_v_i]) = (__pyx_v_slice->strides[0]); /* "View.MemoryView":1308 - * for i in range(offset): - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] # <<<<<<<<<<<<<< - * mslice.suboffsets[i] = -1 - * - */ - (__pyx_v_mslice->strides[__pyx_v_i]) = (__pyx_v_mslice->strides[0]); - - /* "View.MemoryView":1309 - * mslice.shape[i] = 1 - * mslice.strides[i] = mslice.strides[0] - * mslice.suboffsets[i] = -1 # <<<<<<<<<<<<<< + * slice.shape[i] = 1 + * slice.strides[i] = slice.strides[0] + * slice.suboffsets[i] = -1 # <<<<<<<<<<<<<< * * */ - (__pyx_v_mslice->suboffsets[__pyx_v_i]) = -1; + (__pyx_v_slice->suboffsets[__pyx_v_i]) = -1; } - /* "View.MemoryView":1295 + /* "View.MemoryView":1294 * * @cname('__pyx_memoryview_broadcast_leading') - * cdef void broadcast_leading(__Pyx_memviewslice *mslice, # <<<<<<<<<<<<<< + * cdef void broadcast_leading(__Pyx_memviewslice *slice, # <<<<<<<<<<<<<< * int ndim, * int ndim_other) nogil: */ @@ -16153,7 +16153,7 @@ static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslic /* function exit code */ } -/* "View.MemoryView":1317 +/* "View.MemoryView":1316 * * @cname('__pyx_memoryview_refcount_copying') * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< @@ -16164,7 +16164,7 @@ static void __pyx_memoryview_broadcast_leading(__Pyx_memviewslice *__pyx_v_mslic static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_dtype_is_object, int __pyx_v_ndim, int __pyx_v_inc) { int __pyx_t_1; - /* "View.MemoryView":1321 + /* "View.MemoryView":1320 * * * if dtype_is_object: # <<<<<<<<<<<<<< @@ -16174,7 +16174,7 @@ static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, i __pyx_t_1 = (__pyx_v_dtype_is_object != 0); if (__pyx_t_1) { - /* "View.MemoryView":1322 + /* "View.MemoryView":1321 * * if dtype_is_object: * refcount_objects_in_slice_with_gil(dst.data, dst.shape, # <<<<<<<<<<<<<< @@ -16186,7 +16186,7 @@ static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, i } __pyx_L3:; - /* "View.MemoryView":1317 + /* "View.MemoryView":1316 * * @cname('__pyx_memoryview_refcount_copying') * cdef void refcount_copying(__Pyx_memviewslice *dst, bint dtype_is_object, # <<<<<<<<<<<<<< @@ -16197,7 +16197,7 @@ static void __pyx_memoryview_refcount_copying(__Pyx_memviewslice *__pyx_v_dst, i /* function exit code */ } -/* "View.MemoryView":1326 +/* "View.MemoryView":1325 * * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -16212,7 +16212,7 @@ static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_da #endif __Pyx_RefNannySetupContext("refcount_objects_in_slice_with_gil", 0); - /* "View.MemoryView":1329 + /* "View.MemoryView":1328 * Py_ssize_t *strides, int ndim, * bint inc) with gil: * refcount_objects_in_slice(data, shape, strides, ndim, inc) # <<<<<<<<<<<<<< @@ -16221,7 +16221,7 @@ static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_da */ __pyx_memoryview_refcount_objects_in_slice(__pyx_v_data, __pyx_v_shape, __pyx_v_strides, __pyx_v_ndim, __pyx_v_inc); - /* "View.MemoryView":1326 + /* "View.MemoryView":1325 * * @cname('__pyx_memoryview_refcount_objects_in_slice_with_gil') * cdef void refcount_objects_in_slice_with_gil(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -16236,7 +16236,7 @@ static void __pyx_memoryview_refcount_objects_in_slice_with_gil(char *__pyx_v_da #endif } -/* "View.MemoryView":1332 +/* "View.MemoryView":1331 * * @cname('__pyx_memoryview_refcount_objects_in_slice') * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -16252,7 +16252,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss int __pyx_t_3; __Pyx_RefNannySetupContext("refcount_objects_in_slice", 0); - /* "View.MemoryView":1336 + /* "View.MemoryView":1335 * cdef Py_ssize_t i * * for i in range(shape[0]): # <<<<<<<<<<<<<< @@ -16263,7 +16263,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "View.MemoryView":1337 + /* "View.MemoryView":1336 * * for i in range(shape[0]): * if ndim == 1: # <<<<<<<<<<<<<< @@ -16273,7 +16273,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss __pyx_t_3 = ((__pyx_v_ndim == 1) != 0); if (__pyx_t_3) { - /* "View.MemoryView":1338 + /* "View.MemoryView":1337 * for i in range(shape[0]): * if ndim == 1: * if inc: # <<<<<<<<<<<<<< @@ -16283,7 +16283,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss __pyx_t_3 = (__pyx_v_inc != 0); if (__pyx_t_3) { - /* "View.MemoryView":1339 + /* "View.MemoryView":1338 * if ndim == 1: * if inc: * Py_INCREF(( data)[0]) # <<<<<<<<<<<<<< @@ -16295,7 +16295,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss } /*else*/ { - /* "View.MemoryView":1341 + /* "View.MemoryView":1340 * Py_INCREF(( data)[0]) * else: * Py_DECREF(( data)[0]) # <<<<<<<<<<<<<< @@ -16309,7 +16309,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss } /*else*/ { - /* "View.MemoryView":1343 + /* "View.MemoryView":1342 * Py_DECREF(( data)[0]) * else: * refcount_objects_in_slice(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< @@ -16320,7 +16320,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss } __pyx_L5:; - /* "View.MemoryView":1346 + /* "View.MemoryView":1345 * ndim - 1, inc) * * data += strides[0] # <<<<<<<<<<<<<< @@ -16330,7 +16330,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss __pyx_v_data = (__pyx_v_data + (__pyx_v_strides[0])); } - /* "View.MemoryView":1332 + /* "View.MemoryView":1331 * * @cname('__pyx_memoryview_refcount_objects_in_slice') * cdef void refcount_objects_in_slice(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -16342,7 +16342,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss __Pyx_RefNannyFinishContext(); } -/* "View.MemoryView":1352 +/* "View.MemoryView":1351 * * @cname('__pyx_memoryview_slice_assign_scalar') * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< @@ -16352,7 +16352,7 @@ static void __pyx_memoryview_refcount_objects_in_slice(char *__pyx_v_data, Py_ss static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst, int __pyx_v_ndim, size_t __pyx_v_itemsize, void *__pyx_v_item, int __pyx_v_dtype_is_object) { - /* "View.MemoryView":1355 + /* "View.MemoryView":1354 * size_t itemsize, void *item, * bint dtype_is_object) nogil: * refcount_copying(dst, dtype_is_object, ndim, False) # <<<<<<<<<<<<<< @@ -16361,7 +16361,7 @@ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst */ __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 0); - /* "View.MemoryView":1356 + /* "View.MemoryView":1355 * bint dtype_is_object) nogil: * refcount_copying(dst, dtype_is_object, ndim, False) * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, # <<<<<<<<<<<<<< @@ -16370,7 +16370,7 @@ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst */ __pyx_memoryview__slice_assign_scalar(__pyx_v_dst->data, __pyx_v_dst->shape, __pyx_v_dst->strides, __pyx_v_ndim, __pyx_v_itemsize, __pyx_v_item); - /* "View.MemoryView":1358 + /* "View.MemoryView":1357 * _slice_assign_scalar(dst.data, dst.shape, dst.strides, ndim, * itemsize, item) * refcount_copying(dst, dtype_is_object, ndim, True) # <<<<<<<<<<<<<< @@ -16379,7 +16379,7 @@ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst */ __pyx_memoryview_refcount_copying(__pyx_v_dst, __pyx_v_dtype_is_object, __pyx_v_ndim, 1); - /* "View.MemoryView":1352 + /* "View.MemoryView":1351 * * @cname('__pyx_memoryview_slice_assign_scalar') * cdef void slice_assign_scalar(__Pyx_memviewslice *dst, int ndim, # <<<<<<<<<<<<<< @@ -16390,7 +16390,7 @@ static void __pyx_memoryview_slice_assign_scalar(__Pyx_memviewslice *__pyx_v_dst /* function exit code */ } -/* "View.MemoryView":1362 +/* "View.MemoryView":1361 * * @cname('__pyx_memoryview__slice_assign_scalar') * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -16406,7 +16406,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t Py_ssize_t __pyx_t_2; Py_ssize_t __pyx_t_3; - /* "View.MemoryView":1366 + /* "View.MemoryView":1365 * size_t itemsize, void *item) nogil: * cdef Py_ssize_t i * cdef Py_ssize_t stride = strides[0] # <<<<<<<<<<<<<< @@ -16415,7 +16415,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t */ __pyx_v_stride = (__pyx_v_strides[0]); - /* "View.MemoryView":1367 + /* "View.MemoryView":1366 * cdef Py_ssize_t i * cdef Py_ssize_t stride = strides[0] * cdef Py_ssize_t extent = shape[0] # <<<<<<<<<<<<<< @@ -16424,7 +16424,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t */ __pyx_v_extent = (__pyx_v_shape[0]); - /* "View.MemoryView":1369 + /* "View.MemoryView":1368 * cdef Py_ssize_t extent = shape[0] * * if ndim == 1: # <<<<<<<<<<<<<< @@ -16434,7 +16434,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t __pyx_t_1 = ((__pyx_v_ndim == 1) != 0); if (__pyx_t_1) { - /* "View.MemoryView":1370 + /* "View.MemoryView":1369 * * if ndim == 1: * for i in range(extent): # <<<<<<<<<<<<<< @@ -16445,7 +16445,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1371 + /* "View.MemoryView":1370 * if ndim == 1: * for i in range(extent): * memcpy(data, item, itemsize) # <<<<<<<<<<<<<< @@ -16454,7 +16454,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t */ memcpy(__pyx_v_data, __pyx_v_item, __pyx_v_itemsize); - /* "View.MemoryView":1372 + /* "View.MemoryView":1371 * for i in range(extent): * memcpy(data, item, itemsize) * data += stride # <<<<<<<<<<<<<< @@ -16467,7 +16467,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t } /*else*/ { - /* "View.MemoryView":1374 + /* "View.MemoryView":1373 * data += stride * else: * for i in range(extent): # <<<<<<<<<<<<<< @@ -16478,7 +16478,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "View.MemoryView":1375 + /* "View.MemoryView":1374 * else: * for i in range(extent): * _slice_assign_scalar(data, shape + 1, strides + 1, # <<<<<<<<<<<<<< @@ -16487,7 +16487,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t */ __pyx_memoryview__slice_assign_scalar(__pyx_v_data, (__pyx_v_shape + 1), (__pyx_v_strides + 1), (__pyx_v_ndim - 1), __pyx_v_itemsize, __pyx_v_item); - /* "View.MemoryView":1377 + /* "View.MemoryView":1376 * _slice_assign_scalar(data, shape + 1, strides + 1, * ndim - 1, itemsize, item) * data += stride # <<<<<<<<<<<<<< @@ -16499,7 +16499,7 @@ static void __pyx_memoryview__slice_assign_scalar(char *__pyx_v_data, Py_ssize_t } __pyx_L3:; - /* "View.MemoryView":1362 + /* "View.MemoryView":1361 * * @cname('__pyx_memoryview__slice_assign_scalar') * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -17214,6 +17214,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, {&__pyx_kp_s_Unable_to_convert_item_to_object, __pyx_k_Unable_to_convert_item_to_object, sizeof(__pyx_k_Unable_to_convert_item_to_object), 0, 0, 1, 0}, + {&__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_allocate_buffer, __pyx_k_allocate_buffer, sizeof(__pyx_k_allocate_buffer), 0, 0, 1, 1}, {&__pyx_n_s_asarray, __pyx_k_asarray, sizeof(__pyx_k_asarray), 0, 0, 1, 1}, @@ -17242,7 +17243,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 0, 1, 1}, {&__pyx_n_u_fortran, __pyx_k_fortran, sizeof(__pyx_k_fortran), 0, 1, 0, 1}, {&__pyx_kp_s_got_differing_extents_in_dimensi, __pyx_k_got_differing_extents_in_dimensi, sizeof(__pyx_k_got_differing_extents_in_dimensi), 0, 0, 1, 0}, - {&__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_id, __pyx_k_id, sizeof(__pyx_k_id), 0, 0, 1, 1}, {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, @@ -17295,14 +17295,14 @@ static int __Pyx_InitCachedBuiltins(void) { #else __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __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 = 802; __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;} __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_n_s_enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_Ellipsis = __Pyx_GetBuiltinName(__pyx_n_s_Ellipsis); if (!__pyx_builtin_Ellipsis) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_id = __Pyx_GetBuiltinName(__pyx_n_s_id); if (!__pyx_builtin_id) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_IndexError = __Pyx_GetBuiltinName(__pyx_n_s_IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -17312,69 +17312,69 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":218 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":215 * if ((flags & pybuf.PyBUF_C_CONTIGUOUS == pybuf.PyBUF_C_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_C_CONTIGUOUS)): * raise ValueError(u"ndarray is not C contiguous") # <<<<<<<<<<<<<< * * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_C_contiguous); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":222 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":219 * if ((flags & pybuf.PyBUF_F_CONTIGUOUS == pybuf.PyBUF_F_CONTIGUOUS) * and not PyArray_CHKFLAGS(self, NPY_F_CONTIGUOUS)): * raise ValueError(u"ndarray is not Fortran contiguous") # <<<<<<<<<<<<<< * * info.buf = PyArray_DATA(self) */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_u_ndarray_is_not_Fortran_contiguou); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__2); __Pyx_GIVEREF(__pyx_tuple__2); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":260 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":257 * if ((descr.byteorder == c'>' and little_endian) or * (descr.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * if t == NPY_BYTE: f = "b" * elif t == NPY_UBYTE: f = "B" */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":802 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":799 * * if (end - f) - (new_offset - offset[0]) < 15: * raise RuntimeError(u"Format string allocated too short, see comment in numpy.pxd") # <<<<<<<<<<<<<< * * if ((child.byteorder == c'>' and little_endian) or */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__4); __Pyx_GIVEREF(__pyx_tuple__4); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":806 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":803 * if ((child.byteorder == c'>' and little_endian) or * (child.byteorder == c'<' and not little_endian)): * raise ValueError(u"Non-native byte order not supported") # <<<<<<<<<<<<<< * # One could encode it in the format string and have Cython * # complain instead, BUT: < and > in format strings also imply */ - __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__5 = PyTuple_Pack(1, __pyx_kp_u_Non_native_byte_order_not_suppor); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); - /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":826 + /* "../../../../anaconda/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd":823 * t = child.type_num * if end - f < 5: * raise RuntimeError(u"Format string allocated too short.") # <<<<<<<<<<<<<< * * # Until ticket #99 is fixed, use integers to avoid warnings */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_u_Format_string_allocated_too_shor_2); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 823; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__6); __Pyx_GIVEREF(__pyx_tuple__6); @@ -17449,26 +17449,12 @@ static int __Pyx_InitCachedConstants(void) { * * raise ValueError("Buffer view does not expose strides") # <<<<<<<<<<<<<< * - * return tuple([stride for stride in self.view.strides[:self.view.ndim]]) + * return tuple([self.view.strides[i] for i in xrange(self.view.ndim)]) */ __pyx_tuple__13 = PyTuple_Pack(1, __pyx_kp_s_Buffer_view_does_not_expose_stri); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); - /* "View.MemoryView":529 - * def __get__(self): - * if self.view.suboffsets == NULL: - * return (-1,) * self.view.ndim # <<<<<<<<<<<<<< - * - * return tuple([suboffset for suboffset in self.view.suboffsets[:self.view.ndim]]) - */ - __pyx_tuple__14 = PyTuple_New(1); if (unlikely(!__pyx_tuple__14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_INCREF(__pyx_int_neg_1); - PyTuple_SET_ITEM(__pyx_tuple__14, 0, __pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_int_neg_1); - __Pyx_GIVEREF(__pyx_tuple__14); - /* "View.MemoryView":638 * if item is Ellipsis: * if not seen_ellipsis: @@ -17476,9 +17462,9 @@ static int __Pyx_InitCachedConstants(void) { * seen_ellipsis = True * else: */ - __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_slice__15); - __Pyx_GIVEREF(__pyx_slice__15); + __pyx_slice__14 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__14); + __Pyx_GIVEREF(__pyx_slice__14); /* "View.MemoryView":641 * seen_ellipsis = True @@ -17487,9 +17473,9 @@ static int __Pyx_InitCachedConstants(void) { * have_slices = True * else: */ - __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_slice__16); - __Pyx_GIVEREF(__pyx_slice__16); + __pyx_slice__15 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__15)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__15); + __Pyx_GIVEREF(__pyx_slice__15); /* "View.MemoryView":652 * nslices = ndim - len(result) @@ -17498,20 +17484,20 @@ static int __Pyx_InitCachedConstants(void) { * * return have_slices or nslices, tuple(result) */ - __pyx_slice__17 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__17)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_slice__17); - __Pyx_GIVEREF(__pyx_slice__17); + __pyx_slice__16 = PySlice_New(Py_None, Py_None, Py_None); if (unlikely(!__pyx_slice__16)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_slice__16); + __Pyx_GIVEREF(__pyx_slice__16); - /* "View.MemoryView":659 - * for suboffset in suboffsets[:ndim]: - * if suboffset >= 0: + /* "View.MemoryView":660 + * for i in range(ndim): + * if suboffsets[i] >= 0: * raise ValueError("Indirect dimensions not supported") # <<<<<<<<<<<<<< * * */ - __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_Indirect_dimensions_not_supporte); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 660; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__17); + __Pyx_GIVEREF(__pyx_tuple__17); /* "GPy/util/choleskies_cython.pyx":12 * cimport scipy.linalg.cython_blas as cblas @@ -17520,10 +17506,10 @@ static int __Pyx_InitCachedConstants(void) { * """take a matrix N x D and return a D X M x M array where * */ - __pyx_tuple__19 = PyTuple_Pack(9, __pyx_n_s_flat, __pyx_n_s_M, __pyx_n_s_D, __pyx_n_s_N, __pyx_n_s_count, __pyx_n_s_ret, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__19); - __Pyx_GIVEREF(__pyx_tuple__19); - __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_flat_to_triang, 12, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__18 = PyTuple_Pack(9, __pyx_n_s_flat, __pyx_n_s_M, __pyx_n_s_D, __pyx_n_s_N, __pyx_n_s_count, __pyx_n_s_ret, __pyx_n_s_d, __pyx_n_s_m, __pyx_n_s_mm); if (unlikely(!__pyx_tuple__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__18); + __Pyx_GIVEREF(__pyx_tuple__18); + __pyx_codeobj__19 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__18, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_flat_to_triang, 12, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/util/choleskies_cython.pyx":33 * return ret @@ -17532,10 +17518,10 @@ static int __Pyx_InitCachedConstants(void) { * cdef int D = L.shape[0] * cdef int M = L.shape[1] */ - __pyx_tuple__21 = PyTuple_Pack(10, __pyx_n_s_L, __pyx_n_s_L, __pyx_n_s_D, __pyx_n_s_M, __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__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__21); - __Pyx_GIVEREF(__pyx_tuple__21); - __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_triang_to_flat, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__20 = PyTuple_Pack(10, __pyx_n_s_L, __pyx_n_s_L, __pyx_n_s_D, __pyx_n_s_M, __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__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__20); + __Pyx_GIVEREF(__pyx_tuple__20); + __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_triang_to_flat, 33, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/util/choleskies_cython.pyx":49 * return flat @@ -17544,10 +17530,10 @@ static int __Pyx_InitCachedConstants(void) { * cdef double[:, ::1] dL_dK = np.tril(dL) * cdef int N = L.shape[0] */ - __pyx_tuple__23 = 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__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__23); - __Pyx_GIVEREF(__pyx_tuple__23); - __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_backprop_gradient, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__22 = 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__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__22); + __Pyx_GIVEREF(__pyx_tuple__22); + __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_backprop_gradient, 49, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/util/choleskies_cython.pyx":65 * return dL_dK @@ -17556,10 +17542,10 @@ static int __Pyx_InitCachedConstants(void) { * cdef double[:,::1] dL_dK = np.tril(dL) * cdef int N = L.shape[0] */ - __pyx_tuple__25 = 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__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - __pyx_codeobj__26 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__25, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_backprop_gradient_par, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__24 = 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__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__24); + __Pyx_GIVEREF(__pyx_tuple__24); + __pyx_codeobj__25 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__24, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_backprop_gradient_par, 65, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "GPy/util/choleskies_cython.pyx":108 * dL[k, k] /= (2.0 * L[k, k]) @@ -17568,10 +17554,10 @@ static int __Pyx_InitCachedConstants(void) { * cdef double[:, ::1] dL_dK = np.tril(dL) # makes a copy, c-contig * cdef double[:, ::1] L_cont = np.ascontiguousarray(L) */ - __pyx_tuple__27 = PyTuple_Pack(5, __pyx_n_s_dL, __pyx_n_s_L, __pyx_n_s_dL_dK, __pyx_n_s_L_cont, __pyx_n_s_N); if (unlikely(!__pyx_tuple__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - __pyx_codeobj__28 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__27, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_james_work_GPy_GPy_util_ch, __pyx_n_s_backprop_gradient_par_c, 108, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__28)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_tuple__26 = PyTuple_Pack(5, __pyx_n_s_dL, __pyx_n_s_L, __pyx_n_s_dL_dK, __pyx_n_s_L_cont, __pyx_n_s_N); if (unlikely(!__pyx_tuple__26)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__26); + __Pyx_GIVEREF(__pyx_tuple__26); + __pyx_codeobj__27 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__26, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_Users_james_work_GPy_GPy_util_c, __pyx_n_s_backprop_gradient_par_c, 108, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__27)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "View.MemoryView":276 * return self.name @@ -17580,9 +17566,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); + __pyx_tuple__28 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct_or_indirect); if (unlikely(!__pyx_tuple__28)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__28); + __Pyx_GIVEREF(__pyx_tuple__28); /* "View.MemoryView":277 * @@ -17591,9 +17577,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect = Enum("") * */ - __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__30); - __Pyx_GIVEREF(__pyx_tuple__30); + __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_s_strided_and_direct); if (unlikely(!__pyx_tuple__29)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__29); + __Pyx_GIVEREF(__pyx_tuple__29); /* "View.MemoryView":278 * cdef generic = Enum("") @@ -17602,9 +17588,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); + __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_s_strided_and_indirect); if (unlikely(!__pyx_tuple__30)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__30); + __Pyx_GIVEREF(__pyx_tuple__30); /* "View.MemoryView":281 * @@ -17613,9 +17599,9 @@ static int __Pyx_InitCachedConstants(void) { * cdef indirect_contiguous = Enum("") * */ - __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__32); - __Pyx_GIVEREF(__pyx_tuple__32); + __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_direct); if (unlikely(!__pyx_tuple__31)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__31); + __Pyx_GIVEREF(__pyx_tuple__31); /* "View.MemoryView":282 * @@ -17624,9 +17610,9 @@ static int __Pyx_InitCachedConstants(void) { * * */ - __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__33)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_tuple__33); - __Pyx_GIVEREF(__pyx_tuple__33); + __pyx_tuple__32 = PyTuple_Pack(1, __pyx_kp_s_contiguous_and_indirect); if (unlikely(!__pyx_tuple__32)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_tuple__32); + __Pyx_GIVEREF(__pyx_tuple__32); __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -17760,9 +17746,9 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) __pyx_vtable__memoryviewslice.__pyx_base.convert_item_to_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *))__pyx_memoryviewslice_convert_item_to_object; __pyx_vtable__memoryviewslice.__pyx_base.assign_item_from_object = (PyObject *(*)(struct __pyx_memoryview_obj *, char *, PyObject *))__pyx_memoryviewslice_assign_item_from_object; __pyx_type___pyx_memoryviewslice.tp_base = __pyx_memoryview_type; - if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type___pyx_memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_type___pyx_memoryviewslice.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type___pyx_memoryviewslice.tp_dict, __pyx_vtabptr__memoryviewslice) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_memoryviewslice_type = &__pyx_type___pyx_memoryviewslice; /*--- Type import code ---*/ __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type", @@ -17773,10 +17759,10 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) #endif 0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_5numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_5numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5numpy_ufunc = __Pyx_ImportType("numpy", "ufunc", sizeof(PyUFuncObject), 0); if (unlikely(!__pyx_ptype_5numpy_ufunc)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("scipy.linalg.cython_blas"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -17888,7 +17874,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) * cdef strided = Enum("") # default * cdef indirect = Enum("") */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__28, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(generic); __Pyx_DECREF_SET(generic, __pyx_t_2); @@ -17902,7 +17888,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) * cdef indirect = Enum("") * */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(strided); __Pyx_DECREF_SET(strided, __pyx_t_2); @@ -17916,7 +17902,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) * * */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(indirect); __Pyx_DECREF_SET(indirect, __pyx_t_2); @@ -17930,7 +17916,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) * cdef indirect_contiguous = Enum("") * */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(contiguous); __Pyx_DECREF_SET(contiguous, __pyx_t_2); @@ -17944,7 +17930,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) * * */ - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)((PyObject *)__pyx_MemviewEnum_type)), __pyx_tuple__32, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_XGOTREF(indirect_contiguous); __Pyx_DECREF_SET(indirect_contiguous, __pyx_t_2); @@ -17964,20 +17950,20 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_memoryview_type); - /* "View.MemoryView":952 + /* "View.MemoryView":953 * return self.from_object * * __pyx_getbuffer = capsule( &__pyx_memoryview_getbuffer, "getbuffer(obj, view, flags)") # <<<<<<<<<<<<<< * * */ - __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_capsule_create(((void *)(&__pyx_memoryview_getbuffer)), __pyx_k_getbuffer_obj_view_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_memoryviewslice_type->tp_dict, __pyx_n_s_pyx_getbuffer, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyType_Modified(__pyx_memoryviewslice_type); - /* "View.MemoryView":1362 + /* "View.MemoryView":1361 * * @cname('__pyx_memoryview__slice_assign_scalar') * cdef void _slice_assign_scalar(char *data, Py_ssize_t *shape, # <<<<<<<<<<<<<< @@ -17994,6 +17980,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) if (__pyx_m) { if (__pyx_d) { __Pyx_AddTraceback("init GPy.util.choleskies_cython", __pyx_clineno, __pyx_lineno, __pyx_filename); + Py_DECREF(__pyx_d); __pyx_d = 0; } Py_DECREF(__pyx_m); __pyx_m = 0; } else if (!PyErr_Occurred()) { @@ -18008,7 +17995,7 @@ PyMODINIT_FUNC PyInit_choleskies_cython(void) #endif } -/* --- Runtime support code --- */ +/* Runtime support code */ #if CYTHON_REFNANNY static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) { PyObject *m = NULL, *p = NULL; @@ -19146,13 +19133,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } PyErr_SetObject(type, value); if (tb) { -#if CYTHON_COMPILING_IN_PYPY - PyObject *tmp_type, *tmp_value, *tmp_tb; - PyErr_Fetch(tmp_type, tmp_value, tmp_tb); - Py_INCREF(tb); - PyErr_Restore(tmp_type, tmp_value, tb); - Py_XDECREF(tmp_tb); -#else PyThreadState *tstate = PyThreadState_GET(); PyObject* tmp_tb = tstate->curexc_traceback; if (tb != tmp_tb) { @@ -19160,7 +19140,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject tstate->curexc_traceback = tb; Py_XDECREF(tmp_tb); } -#endif } bad: Py_XDECREF(owned_instance); diff --git a/GPy/util/cluster_with_offset.py b/GPy/util/cluster_with_offset.py new file mode 100644 index 00000000..d1e896f1 --- /dev/null +++ b/GPy/util/cluster_with_offset.py @@ -0,0 +1,184 @@ +# Copyright (c) 2016, Mike Smith +# Licensed under the BSD 3-clause license (see LICENSE.txt) + +import GPy +import numpy as np +import sys #so I can print dots + +def get_log_likelihood(inputs,data,clust): + """Get the LL of a combined set of clusters, ignoring time series offsets. + + Get the log likelihood of a cluster without worrying about the fact + different time series are offset. We're using it here really for those + cases in which we only have one cluster to get the loglikelihood of. + + arguments: + inputs -- the 'X's in a list, one item per cluster + data -- the 'Y's in a list, one item per cluster + clust -- list of clusters to use + + returns a tuple: + log likelihood and the offset (which is always zero for this model) + """ + + S = data[0].shape[0] #number of time series + + #build a new dataset from the clusters, by combining all clusters together + X = np.zeros([0,1]) + Y = np.zeros([0,S]) + + #for each person in the cluster, + #add their inputs and data to the new dataset + for p in clust: + X = np.vstack([X,inputs[p]]) + Y = np.vstack([Y,data[p].T]) + + #find the loglikelihood. We just add together the LL for each time series. + #ll=0 + #for s in range(S): + # m = GPy.models.GPRegression(X,Y[:,s][:,None]) + # m.optimize() + # ll+=m.log_likelihood() + + m = GPy.models.GPRegression(X,Y) + m.optimize() + ll=m.log_likelihood() + return ll,0 + +def get_log_likelihood_offset(inputs,data,clust): + """Get the log likelihood of a combined set of clusters, fitting the offsets + + arguments: + inputs -- the 'X's in a list, one item per cluster + data -- the 'Y's in a list, one item per cluster + clust -- list of clusters to use + + returns a tuple: + log likelihood and the offset + """ + + #if we've only got one cluster, the model has an error, so we want to just + #use normal GPRegression. + if len(clust)==1: + return get_log_likelihood(inputs,data,clust) + + S = data[0].shape[0] #number of time series + + X = np.zeros([0,2]) #notice the extra column, this is for the cluster index + Y = np.zeros([0,S]) + + #for each person in the cluster, add their inputs and data to the new + #dataset. Note we add an index identifying which person is which data point. + #This is for the offset model to use, to allow it to know which data points + #to shift. + for i,p in enumerate(clust): + idx = i*np.ones([inputs[p].shape[0],1]) + X = np.vstack([X,np.hstack([inputs[p],idx])]) + Y = np.vstack([Y,data[p].T]) + + m = GPy.models.GPOffsetRegression(X,Y) + #TODO: How to select a sensible prior? + m.offset.set_prior(GPy.priors.Gaussian(0,20)) + #TODO: Set a sensible start value for the length scale, + #make it long to help the offset fit. + + m.optimize() + + ll = m.log_likelihood() + offset = m.offset.values[0] + return ll,offset + +def cluster(data,inputs,verbose=False): + """Clusters data + + Using the new offset model, this method uses a greedy algorithm to cluster + the data. It starts with all the data points in separate clusters and tests + whether combining them increases the overall log-likelihood (LL). It then + iteratively joins pairs of clusters which cause the greatest increase in + the LL, until no join increases the LL. + + arguments: + inputs -- the 'X's in a list, one item per cluster + data -- the 'Y's in a list, one item per cluster + + returns a list of the clusters. + """ + N=len(data) + + + #Define a set of N active cluster + active = [] + for p in range(0,N): + active.append([p]) + + loglikes = np.zeros(len(active)) + loglikes[:] = None + + pairloglikes = np.zeros([len(active),len(active)]) + pairloglikes[:] = None + pairoffset = np.zeros([len(active),len(active)]) + + it = 0 + while True: + + if verbose: + it +=1 + print("Iteration %d" % it) + + #Compute the log-likelihood of each cluster (add them together) + for clusti in range(len(active)): + if verbose: + sys.stdout.write('.') + sys.stdout.flush() + if np.isnan(loglikes[clusti]): + loglikes[clusti], unused_offset = get_log_likelihood_offset(inputs,data,[clusti]) + + #try combining with each other cluster... + for clustj in range(clusti): #count from 0 to clustj-1 + temp = [clusti,clustj] + if np.isnan(pairloglikes[clusti,clustj]): + pairloglikes[clusti,clustj],pairoffset[clusti,clustj] = get_log_likelihood_offset(inputs,data,temp) + + seploglikes = np.repeat(loglikes[:,None].T,len(loglikes),0)+np.repeat(loglikes[:,None],len(loglikes),1) + loglikeimprovement = pairloglikes - seploglikes #how much likelihood improves with clustering + top = np.unravel_index(np.nanargmax(pairloglikes-seploglikes), pairloglikes.shape) + + #if loglikeimprovement.shape[0]<3: + # #no more clustering to do - this shouldn't happen really unless + # #we've set the threshold to apply clustering to less than 0 + # break + + #if theres further clustering to be done... + if loglikeimprovement[top[0],top[1]]>0: + active[top[0]].extend(active[top[1]]) + offset=pairoffset[top[0],top[1]] + inputs[top[0]] = np.vstack([inputs[top[0]],inputs[top[1]]-offset]) + data[top[0]] = np.hstack([data[top[0]],data[top[1]]]) + del inputs[top[1]] + del data[top[1]] + del active[top[1]] + + #None = message to say we need to recalculate + pairloglikes[:,top[0]] = None + pairloglikes[top[0],:] = None + pairloglikes = np.delete(pairloglikes,top[1],0) + pairloglikes = np.delete(pairloglikes,top[1],1) + loglikes[top[0]] = None + loglikes = np.delete(loglikes,top[1]) + else: + break + + #if loglikeimprovement[top[0],top[1]]>0: + # print "joined" + # print top + # print offset + # print offsets + # print offsets[top[1]]-offsets[top[0]] + + #TODO Add a way to return the offsets applied to all the time series + return active + +#starttime = time.time() +#active = cluster(data,inputs) +#endtime = time.time() +#print "TOTAL TIME %0.4f" % (endtime-starttime) diff --git a/GPy/util/config.py b/GPy/util/config.py index e47848a8..53675efe 100644 --- a/GPy/util/config.py +++ b/GPy/util/config.py @@ -12,7 +12,7 @@ except ImportError: import configparser config = configparser.ConfigParser() from configparser import NoOptionError - + # This is the default configuration file that always needs to be present. default_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'defaults.cfg')) @@ -23,7 +23,7 @@ local_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', 'in # This specifies configurations specific to the user (it is found in the user home directory) home = os.getenv('HOME') or os.getenv('USERPROFILE') -user_file = os.path.join(home,'.config','gpy', 'user.cfg') +user_file = os.path.join(home,'.config','GPy', 'user.cfg') # Read in the given files. config.readfp(open(default_file)) diff --git a/GPy/util/datasets.py b/GPy/util/datasets.py index b722ba45..af8912ac 100644 --- a/GPy/util/datasets.py +++ b/GPy/util/datasets.py @@ -11,6 +11,7 @@ import datetime import json import re import sys +from io import open from .config import * ipython_available=True @@ -54,12 +55,12 @@ on_rtd = os.environ.get('READTHEDOCS', None) == 'True' #Checks if RTD is scannin if not (on_rtd): path = os.path.join(os.path.dirname(__file__), 'data_resources.json') - json_data=open(path).read() + json_data = open(path, encoding='utf-8').read() data_resources = json.loads(json_data) if not (on_rtd): path = os.path.join(os.path.dirname(__file__), 'football_teams.json') - json_data=open(path).read() + json_data = open(path, encoding='utf-8').read() football_dict = json.loads(json_data) @@ -72,7 +73,7 @@ def prompt_user(prompt): try: print(prompt) - choice = raw_input().lower() + choice = input().lower() # would like to test for exception here, but not sure if we can do that without importing IPython except: print('Stdin is not implemented.') @@ -95,16 +96,16 @@ def prompt_user(prompt): def data_available(dataset_name=None): """Check if the data set is available on the local machine already.""" try: - from itertools import izip_longest + from itertools import zip_longest except ImportError: - from itertools import zip_longest as izip_longest + from itertools import izip_longest as zip_longest dr = data_resources[dataset_name] zip_urls = (dr['files'], ) if 'save_names' in dr: zip_urls += (dr['save_names'], ) else: zip_urls += ([],) - for file_list, save_list in izip_longest(*zip_urls, fillvalue=[]): - for f, s in izip_longest(file_list, save_list, fillvalue=None): + for file_list, save_list in zip_longest(*zip_urls, fillvalue=[]): + for f, s in zip_longest(file_list, save_list, fillvalue=None): if s is not None: f=s # If there is a save_name given, use that one if not os.path.exists(os.path.join(data_path, dataset_name, f)): return False @@ -137,7 +138,7 @@ def download_url(url, store_directory, save_name=None, messages=True, suffix='') raise ValueError('Tried url ' + url + suffix + ' and received server error ' + str(response.code)) with open(save_name, 'wb') as f: meta = response.info() - content_length_str = meta.getheaders("Content-Length") + content_length_str = meta.get("Content-Length") if content_length_str: file_size = int(content_length_str[0]) else: @@ -213,14 +214,14 @@ def download_data(dataset_name=None): zip_urls = (dr['urls'], dr['files']) - if dr.has_key('save_names'): zip_urls += (dr['save_names'], ) + if 'save_names' in dr: zip_urls += (dr['save_names'], ) else: zip_urls += ([],) - if dr.has_key('suffices'): zip_urls += (dr['suffices'], ) + if 'suffices' in dr: zip_urls += (dr['suffices'], ) else: zip_urls += ([],) - for url, files, save_names, suffices in itertools.izip_longest(*zip_urls, fillvalue=[]): - for f, save_name, suffix in itertools.izip_longest(files, save_names, suffices, fillvalue=None): + for url, files, save_names, suffices in itertools.zip_longest(*zip_urls, fillvalue=[]): + for f, save_name, suffix in itertools.zip_longest(files, save_names, suffices, fillvalue=None): download_url(os.path.join(url,f), dataset_name, save_name, suffix=suffix) return True @@ -360,7 +361,7 @@ def football_data(season='1314', data_set='football_data'): return league_dict[string] def football2num(string): - if football_dict.has_key(string): + if string in football_dict: return football_dict[string] else: football_dict[string] = len(football_dict)+1 @@ -1032,14 +1033,18 @@ def singlecell_rna_seq_deng(dataset='singlecell_deng'): data = inner.RPKM.to_frame() data.columns = [file_info.name[:-18]] gene_info = inner.Refseq_IDs.to_frame() - gene_info.columns = [file_info.name[:-18]] + gene_info.columns = ['NCBI Reference Sequence'] else: data[file_info.name[:-18]] = inner.RPKM - gene_info[file_info.name[:-18]] = inner.Refseq_IDs + #gene_info[file_info.name[:-18]] = inner.Refseq_IDs # Strip GSM number off data index rep = re.compile('GSM\d+_') - data.columns = data.columns.to_series().apply(lambda row: row[rep.match(row).end():]) + + from pandas import MultiIndex + columns = MultiIndex.from_tuples([row.split('_', 1) for row in data.columns]) + columns.names = ['GEO Accession', 'index'] + data.columns = columns data = data.T # make sure the same index gets used @@ -1482,5 +1487,3 @@ def cmu_mocap(subject, train_motions, test_motions=[], sample_every=4, data_set= if sample_every != 1: info += ' Data is sub-sampled to every ' + str(sample_every) + ' frames.' return data_details_return({'Y': Y, 'lbls' : lbls, 'Ytest': Ytest, 'lblstest' : lblstest, 'info': info, 'skel': skel}, data_set) - - diff --git a/GPy/util/normalizer.py b/GPy/util/normalizer.py index 854726c4..78ad945d 100644 --- a/GPy/util/normalizer.py +++ b/GPy/util/normalizer.py @@ -6,7 +6,7 @@ Created on Aug 27, 2014 import logging import numpy as np -class Norm(object): +class _Norm(object): def __init__(self): pass def scale_by(self, Y): @@ -18,7 +18,8 @@ class Norm(object): """ Project Y into normalized space """ - raise NotImplementedError + if not self.scaled(): + raise AttributeError("Norm object not initialized yet, try calling scale_by(data) first.") def inverse_mean(self, X): """ Project the normalized object X into space of Y @@ -31,15 +32,46 @@ class Norm(object): Whether this Norm object has been initialized. """ raise NotImplementedError -class MeanNorm(Norm): + +class Standardize(_Norm): def __init__(self): self.mean = None def scale_by(self, Y): Y = np.ma.masked_invalid(Y, copy=False) self.mean = Y.mean(0).view(np.ndarray) + self.std = Y.std(0).view(np.ndarray) def normalize(self, Y): - return Y-self.mean + super(Standardize, self).normalize(Y) + return (Y-self.mean)/self.std def inverse_mean(self, X): - return X+self.mean + return (X*self.std)+self.mean + def inverse_variance(self, var): + return (var*(self.std**2)) def scaled(self): return self.mean is not None + +# Inverse variance to be implemented, disabling for now +# If someone in the future want to implement this, +# we need to implement the inverse variance for +# normalization. This means, we need to know the factor +# for the variance to be multiplied to the variance in +# normalized space. This is easy to compute for standardization +# (see above) but gets tricky here. +# class Normalize(_Norm): +# def __init__(self): +# self.ymin = None +# self.ymax = None +# def scale_by(self, Y): +# Y = np.ma.masked_invalid(Y, copy=False) +# self.ymin = Y.min(0).view(np.ndarray) +# self.ymax = Y.max(0).view(np.ndarray) +# def normalize(self, Y): +# super(Normalize, self).normalize(Y) +# return (Y - self.ymin) / (self.ymax - self.ymin) - .5 +# def inverse_mean(self, X): +# return (X + .5) * (self.ymax - self.ymin) + self.ymin +# def inverse_variance(self, var): +# +# return (var*(self.std**2)) +# def scaled(self): +# return (self.ymin is not None) and (self.ymax is not None) \ No newline at end of file diff --git a/GPy/util/pca.py b/GPy/util/pca.py index edb8bb7d..3bfcacd9 100644 --- a/GPy/util/pca.py +++ b/GPy/util/pca.py @@ -131,7 +131,7 @@ class PCA(object): kwargs.update(dict(s=s)) plots = list() for i, l in enumerate(ulabels): - kwargs.update(dict(color=colors.next(), marker=marker[i % len(marker)])) + kwargs.update(dict(color=next(colors), marker=marker[i % len(marker)])) plots.append(ax.scatter(*X_[labels == l, :].T, label=str(l), **kwargs)) ax.set_xlabel(r"PC$_1$") ax.set_ylabel(r"PC$_2$") diff --git a/GPy/util/subarray_and_sorting.py b/GPy/util/subarray_and_sorting.py index 0966084c..645e7f1e 100644 --- a/GPy/util/subarray_and_sorting.py +++ b/GPy/util/subarray_and_sorting.py @@ -50,7 +50,7 @@ def common_subarrays(X, axis=0): cnt = count() def accumulate(x, s, c): t = tuple(x) - col = c.next() + col = next(c) iadd(s[t], [col]) return None if axis == 0: [accumulate(x, subarrays, cnt) for x in X] diff --git a/GPy/util/warping_functions.py b/GPy/util/warping_functions.py index 1617283c..3af28d43 100644 --- a/GPy/util/warping_functions.py +++ b/GPy/util/warping_functions.py @@ -4,6 +4,7 @@ import numpy as np from ..core.parameterization import Parameterized, Param from paramz.transformations import Logexp +import sys class WarpingFunction(Parameterized): @@ -14,6 +15,7 @@ class WarpingFunction(Parameterized): def __init__(self, name): super(WarpingFunction, self).__init__(name=name) + self.rate = 0.1 def f(self, y, psi): """function transformation @@ -29,15 +31,32 @@ class WarpingFunction(Parameterized): """gradient of f w.r.t to y""" raise NotImplementedError - def f_inv(self, z, psi): - """inverse function transformation""" - raise NotImplementedError + def f_inv(self, z, max_iterations=250, y=None): + """ + Calculate the numerical inverse of f. This should be + overwritten for specific warping functions where the + inverse can be found in closed form. - def _get_param_names(self): - raise NotImplementedError + :param max_iterations: maximum number of N.R. iterations + """ + + z = z.copy() + y = np.ones_like(z) + + it = 0 + update = np.inf + while np.abs(update).sum() > 1e-10 and it < max_iterations: + fy = self.f(y) + fgrady = self.fgrad_y(y) + update = (fy - z) / fgrady + y -= self.rate * update + it += 1 + #if it == max_iterations: + # print("WARNING!!! Maximum number of iterations reached in f_inv ") + # print("Sum of roots: %.4f" % np.sum(fy - z)) + return y def plot(self, xmin, xmax): - psi = self.psi y = np.arange(xmin, xmax, 0.01) f_y = self.f(y) from matplotlib import pyplot as plt @@ -49,183 +68,59 @@ class WarpingFunction(Parameterized): plt.show() -class TanhWarpingFunction(WarpingFunction): - - def __init__(self, n_terms=3): - """n_terms specifies the number of tanh terms to be used""" - self.n_terms = n_terms - self.num_parameters = 3 * self.n_terms - super(TanhWarpingFunction, self).__init__(name='warp_tanh') - - def f(self, y, psi): +class TanhFunction(WarpingFunction): + """ + This is the function proposed in Snelson et al.: + A sum of tanh functions with linear trends outside + the range. Notice the term 'd', which scales the + linear trend. + """ + def __init__(self, n_terms=3, initial_y=None): """ - transform y with f using parameter vector psi - psi = [[a,b,c]] - ::math::`f = \\sum_{terms} a * tanh(b*(y+c))` + n_terms specifies the number of tanh terms to be used """ - #1. check that number of params is consistent - assert psi.shape[0] == self.n_terms, 'inconsistent parameter dimensions' - assert psi.shape[1] == 3, 'inconsistent parameter dimensions' - - #2. exponentiate the a and b (positive!) - mpsi = psi.copy() - - #3. transform data - z = y.copy() - for i in range(len(mpsi)): - a,b,c = mpsi[i] - z += a*np.tanh(b*(y+c)) - return z - - def f_inv(self, y, psi, iterations=10): - """ - calculate the numerical inverse of f - :param iterations: number of N.R. iterations - """ - - y = y.copy() - z = np.ones_like(y) - for i in range(iterations): - z -= (self.f(z, psi) - y)/self.fgrad_y(z,psi) - return z - - def fgrad_y(self, y, psi, return_precalc=False): - """ - gradient of f w.r.t to y ([N x 1]) - returns: Nx1 vector of derivatives, unless return_precalc is true, - then it also returns the precomputed stuff - """ - - mpsi = psi.copy() - - # vectorized version - - # S = (mpsi[:,1]*(y + mpsi[:,2])).T - S = (mpsi[:,1]*(y[:,:,None] + mpsi[:,2])).T - R = np.tanh(S) - D = 1-R**2 - - # GRAD = (1+(mpsi[:,0:1]*mpsi[:,1:2]*D).sum(axis=0))[:,np.newaxis] - GRAD = (1+(mpsi[:,0:1][:,:,None]*mpsi[:,1:2][:,:,None]*D).sum(axis=0)).T - - if return_precalc: - # return GRAD,S.sum(axis=1),R.sum(axis=1),D.sum(axis=1) - return GRAD, S, R, D - - return GRAD - - def fgrad_y_psi(self, y, psi, return_covar_chain=False): - """ - gradient of f w.r.t to y and psi - returns: NxIx3 tensor of partial derivatives - """ - - # 1. exponentiate the a and b (positive!) - mpsi = psi.copy() - w, s, r, d = self.fgrad_y(y, psi, return_precalc = True) - - gradients = np.zeros((y.shape[0], y.shape[1], len(mpsi), 3)) - for i in range(len(mpsi)): - a,b,c = mpsi[i] - gradients[:,:,i,0] = (b*(1.0/np.cosh(s[i]))**2).T - gradients[:,:,i,1] = a*(d[i] - 2.0*s[i]*r[i]*(1.0/np.cosh(s[i]))**2).T - gradients[:,:,i,2] = (-2.0*a*(b**2)*r[i]*((1.0/np.cosh(s[i]))**2)).T - - if return_covar_chain: - covar_grad_chain = np.zeros((y.shape[0], y.shape[1], len(mpsi), 3)) - - for i in range(len(mpsi)): - a,b,c = mpsi[i] - covar_grad_chain[:, :, i, 0] = (r[i]).T - covar_grad_chain[:, :, i, 1] = (a*(y + c) * ((1.0/np.cosh(s[i]))**2).T) - covar_grad_chain[:, :, i, 2] = a*b*((1.0/np.cosh(s[i]))**2).T - - return gradients, covar_grad_chain - - return gradients - - def _get_param_names(self): - variables = ['a', 'b', 'c'] - names = sum([['warp_tanh_%s_t%i' % (variables[n],q) for n in range(3)] for q in range(self.n_terms)],[]) - return names - - -class TanhWarpingFunction_d(WarpingFunction): - - def __init__(self, n_terms=3): - """n_terms specifies the number of tanh terms to be used""" self.n_terms = n_terms self.num_parameters = 3 * self.n_terms + 1 self.psi = np.ones((self.n_terms, 3)) - - super(TanhWarpingFunction_d, self).__init__(name='warp_tanh') + super(TanhFunction, self).__init__(name='warp_tanh') self.psi = Param('psi', self.psi) self.psi[:, :2].constrain_positive() - self.d = Param('%s' % ('d'), 1.0, Logexp()) self.link_parameter(self.psi) self.link_parameter(self.d) + self.initial_y = initial_y def f(self, y): """ Transform y with f using parameter vector psi psi = [[a,b,c]] - :math:`f = \\sum_{terms} a * tanh(b*(y+c))` + :math:`f = (y * d) + \\sum_{terms} a * tanh(b *(y + c))` """ - #1. check that number of params is consistent - # assert psi.shape[0] == self.n_terms, 'inconsistent parameter dimensions' - # assert psi.shape[1] == 4, 'inconsistent parameter dimensions' - d = self.d mpsi = self.psi - - #3. transform data - z = d*y.copy() + z = d * y.copy() for i in range(len(mpsi)): - a,b,c = mpsi[i] - z += a*np.tanh(b*(y+c)) + a, b, c = mpsi[i] + z += a * np.tanh(b * (y + c)) return z - def f_inv(self, z, max_iterations=1000, y=None): - """ - calculate the numerical inverse of f - - :param max_iterations: maximum number of N.R. iterations - """ - - z = z.copy() - if y is None: - y = np.ones_like(z) - - it = 0 - update = np.inf - - while it == 0 or (np.abs(update).sum() > 1e-10 and it < max_iterations): - fy = self.f(y) - fgrady = self.fgrad_y(y) - update = (fy - z)/fgrady - y -= update - it += 1 - if it == max_iterations: - print("WARNING!!! Maximum number of iterations reached in f_inv ") - return y - def fgrad_y(self, y, return_precalc=False): """ gradient of f w.r.t to y ([N x 1]) - :returns: Nx1 vector of derivatives, unless return_precalc is true, then it also returns the precomputed stuff + :returns: Nx1 vector of derivatives, unless return_precalc is true, + then it also returns the precomputed stuff """ d = self.d mpsi = self.psi # vectorized version - S = (mpsi[:,1]*(y[:,:,None] + mpsi[:,2])).T + S = (mpsi[:,1] * (y[:,:,None] + mpsi[:,2])).T R = np.tanh(S) - D = 1-R**2 + D = 1 - (R ** 2) - GRAD = (d + (mpsi[:,0:1][:,:,None]*mpsi[:,1:2][:,:,None]*D).sum(axis=0)).T + GRAD = (d + (mpsi[:,0:1][:,:,None] * mpsi[:,1:2][:,:,None] * D).sum(axis=0)).T if return_precalc: return GRAD, S, R, D @@ -244,45 +139,79 @@ class TanhWarpingFunction_d(WarpingFunction): gradients = np.zeros((y.shape[0], y.shape[1], len(mpsi), 4)) for i in range(len(mpsi)): a,b,c = mpsi[i] - gradients[:,:,i,0] = (b*(1.0/np.cosh(s[i]))**2).T - gradients[:,:,i,1] = a*(d[i] - 2.0*s[i]*r[i]*(1.0/np.cosh(s[i]))**2).T - gradients[:,:,i,2] = (-2.0*a*(b**2)*r[i]*((1.0/np.cosh(s[i]))**2)).T - gradients[:,:,0,3] = 1.0 + gradients[:, :, i, 0] = (b * (1.0/np.cosh(s[i])) ** 2).T + gradients[:, :, i, 1] = a * (d[i] - 2.0 * s[i] * r[i] * (1.0/np.cosh(s[i])) ** 2).T + gradients[:, :, i, 2] = (-2.0 * a * (b ** 2) * r[i] * ((1.0 / np.cosh(s[i])) ** 2)).T + gradients[:, :, 0, 3] = 1.0 if return_covar_chain: covar_grad_chain = np.zeros((y.shape[0], y.shape[1], len(mpsi), 4)) - for i in range(len(mpsi)): a,b,c = mpsi[i] covar_grad_chain[:, :, i, 0] = (r[i]).T - covar_grad_chain[:, :, i, 1] = (a*(y + c) * ((1.0/np.cosh(s[i]))**2).T) - covar_grad_chain[:, :, i, 2] = a*b*((1.0/np.cosh(s[i]))**2).T + covar_grad_chain[:, :, i, 1] = (a * (y + c) * ((1.0 / np.cosh(s[i])) ** 2).T) + covar_grad_chain[:, :, i, 2] = a * b * ((1.0 / np.cosh(s[i])) ** 2).T covar_grad_chain[:, :, 0, 3] = y - return gradients, covar_grad_chain return gradients - def _get_param_names(self): - variables = ['a', 'b', 'c', 'd'] - names = sum([['warp_tanh_%s_t%i' % (variables[n],q) for n in range(3)] for q in range(self.n_terms)],[]) - names.append('warp_tanh_d') - return names + def update_grads(self, Y_untransformed, Kiy): + grad_y = self.fgrad_y(Y_untransformed) + grad_y_psi, grad_psi = self.fgrad_y_psi(Y_untransformed, + return_covar_chain=True) + djac_dpsi = ((1.0 / grad_y[:, :, None, None]) * grad_y_psi).sum(axis=0).sum(axis=0) + dquad_dpsi = (Kiy[:, None, None, None] * grad_psi).sum(axis=0).sum(axis=0) + + warping_grads = -dquad_dpsi + djac_dpsi + + self.psi.gradient[:] = warping_grads[:, :-1] + self.d.gradient[:] = warping_grads[0, -1] + + +class LogFunction(WarpingFunction): + """ + Easy wrapper for applying a fixed log warping function to + positive-only values. + The closed_inverse flag should only be set to False for + debugging and testing purposes. + """ + def __init__(self, closed_inverse=True): + self.num_parameters = 0 + super(LogFunction, self).__init__(name='log') + if closed_inverse: + self.f_inv = self._f_inv + + def f(self, y): + return np.log(y) + + def fgrad_y(self, y): + return 1. / y + + def update_grads(self, Y_untransformed, Kiy): + pass + + def fgrad_y_psi(self, y, return_covar_chain=False): + if return_covar_chain: + return 0, 0 + return 0 + + def _f_inv(self, z, y=None): + return np.exp(z) class IdentityFunction(WarpingFunction): """ Identity warping function. This is for testing and sanity check purposes and should not be used in practice. + The closed_inverse flag should only be set to False for + debugging and testing purposes. """ - def __init__(self): - self.num_parameters = 4 - self.psi = Param('psi', np.zeros((1,3))) - self.d = Param('%s' % ('d'), 1.0, Logexp()) + def __init__(self, closed_inverse=True): + self.num_parameters = 0 super(IdentityFunction, self).__init__(name='identity') - self.link_parameter(self.psi) - self.link_parameter(self.d) - + if closed_inverse: + self.f_inv = self._f_inv def f(self, y): return y @@ -290,11 +219,14 @@ class IdentityFunction(WarpingFunction): def fgrad_y(self, y): return np.ones(y.shape) + def update_grads(self, Y_untransformed, Kiy): + pass + def fgrad_y_psi(self, y, return_covar_chain=False): - gradients = np.zeros((y.shape[0], y.shape[1], len(self.psi), 4)) if return_covar_chain: - return gradients, gradients - return gradients + return 0, 0 + return 0 - def f_inv(self, z, y=None): + def _f_inv(self, z, y=None): return z + diff --git a/MANIFEST.in b/MANIFEST.in index be80e974..8e665256 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include doc/source/index.rst include doc/source/tuto*.rst include README.md include README.rst +include AUTHORS.txt # Data and config recursive-include GPy *.json @@ -16,5 +17,5 @@ recursive-include GPy *.h recursive-include GPy *.pyx # Testing -include GPy/testing/baseline/*.png +#include GPy/testing/baseline/*.png #include GPy/testing/pickle_test.pickle diff --git a/README.md b/README.md index e415d58f..9efab041 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,36 @@ The Gaussian processes framework in Python. * GPy [homepage](http://sheffieldml.github.io/GPy/) * Tutorial [notebooks](http://nbviewer.ipython.org/github/SheffieldML/notebook/blob/master/GPy/index.ipynb) * User [mailing-list](https://lists.shef.ac.uk/sympa/subscribe/gpy-users) -* Developer [documentation](http://gpy.readthedocs.org/en/devel/) +* Developer [documentation](http://pythonhosted.org/GPy/) * Travis-CI [unit-tests](https://travis-ci.org/SheffieldML/GPy) -* [![licence](https://img.shields.io/badge/licence-BSD-blue.svg)](http://opensource.org/licenses/BSD-3-Clause) +* [![licence](https://img.shields.io/badge/licence-BSD-blue.svg)](http://opensource.org/licenses/BSD-3-Clause) + +[![deploystat](https://travis-ci.org/SheffieldML/GPy.svg?branch=deploy)](https://travis-ci.org/SheffieldML/GPy) [![appveyor](https://ci.appveyor.com/api/projects/status/662o6tha09m2jix3/branch/deploy?svg=true)](https://ci.appveyor.com/project/mzwiessele/gpy/branch/deploy) [![coverallsdevel](https://coveralls.io/repos/github/SheffieldML/GPy/badge.svg?branch=devel)](https://coveralls.io/github/SheffieldML/GPy?branch=devel) [![covdevel](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) [![Research software impact](http://depsy.org/api/package/pypi/GPy/badge.svg)](http://depsy.org/package/python/GPy) [![Code Health](https://landscape.io/github/SheffieldML/GPy/devel/landscape.svg?style=flat)](https://landscape.io/github/SheffieldML/GPy/devel) + +## Contributing to GPy + +We welcome any contributions to GPy, after all it is an open source project. We use the GitHub feature of pull requests for contributions. + +For an in depth description of pull requests, please visit https://help.github.com/articles/using-pull-requests/ . + +Steps to a successfull contribution: + +1. Fork GPy: https://help.github.com/articles/fork-a-repo/ +2. Make your changes to the source in your fork. +3. Set up tests to test your code. We are using unttests in the testing subfolder of GPy. There is a good chance that there already a framework set up to test your new model in model_tests.py. have a look at the source and you might be able to just add your model as an additional test. There is also a framework for testing the other bits and pieces, just head over to the testing folder and have alook. +4. Create a pull request to the devel branch in GPy, see above. +5. The tests will be running on your pull request and with the comments we will be able to discuss the changes and help you with any problems. +6. The pull request gets accepted and your awsome new feature will be in the next release :) + +For any further questions/suggestions head over to the issues section in GPy. + +## Support and questions to the community + +We have set up a meailing list for any questions you might have or problems you feel others have encountered: + +gpy-users@lists.shef.ac.uk + +Feel free to join the discussions on the issues section, too. ## Updated Structure @@ -27,39 +54,32 @@ A warning: This usually works, but sometimes `distutils/setuptools` opens a whole can of worms here, specially when compiled extensions are involved. If that is the case, it is best to clean the repo and reinstall. -## Continuous integration - -| | Travis-CI | Codecov | RTFD | -| ---: | :--: | :---: | :---: | -| **master:** | [![masterstat](https://travis-ci.org/SheffieldML/GPy.svg?branch=master)](https://travis-ci.org/SheffieldML/GPy) | [![covmaster](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=master)](http://codecov.io/github/SheffieldML/GPy?branch=master) | [![docmaster](https://readthedocs.org/projects/gpy/badge/?version=master)](http://gpy.readthedocs.org/en/master/) | -| **devel:** | [![develstat](https://travis-ci.org/SheffieldML/GPy.svg?branch=devel)](https://travis-ci.org/SheffieldML/GPy) | [![covdevel](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) | [![docdevel](https://readthedocs.org/projects/gpy/badge/?version=devel)](http://gpy.readthedocs.org/en/devel/) | - ## Supported Platforms: [](https://www.python.org/) [](http://www.microsoft.com/en-gb/windows) -[](http://www.apple.com/osx/) +[](http://www.apple.com/osx/) [](https://en.wikipedia.org/wiki/List_of_Linux_distributions) -Python 2.7, 3.3 and higher +Python 2.7, 3.4 and higher ## Citation @Misc{gpy2014, - author = {{The GPy authors}}, + author = {{GPy}}, title = {{GPy}: A Gaussian process framework in python}, howpublished = {\url{http://github.com/SheffieldML/GPy}}, - year = {2012--2015} + year = {since 2012} } -### Pronounciation: +### Pronounciation: We like to pronounce it 'g-pie'. -## Getting started: installing with pip +## Getting started: installing with pip -We are now requiring the newest version (0.16) of -[scipy](http://www.scipy.org/) and thus, we strongly recommend using +We are now requiring the newest version (0.16) of +[scipy](http://www.scipy.org/) and thus, we strongly recommend using the [anaconda python distribution](http://continuum.io/downloads). With anaconda you can install GPy by the following: @@ -89,6 +109,36 @@ If you're having trouble installing GPy via `pip install GPy` here is a probable [![Windows](https://img.shields.io/badge/download-windows-orange.svg)](https://pypi.python.org/pypi/GPy) [![MacOSX](https://img.shields.io/badge/download-macosx-blue.svg)](https://pypi.python.org/pypi/GPy) +# Saving models in a consistent way across versions: + +As pickle is inconsistent across python versions and heavily dependent on class structure, it behaves inconsistent across versions. +Pickling as meant to serialize models within the same environment, and not to store models on disk to be used later on. + +To save a model it is best to save the m.param_array of it to disk (using numpy’s np.save). +Additionally, you save the script, which creates the model. +In this script you can create the model using initialize=False as a keyword argument and with the data loaded as normal. +You then set the model parameters by setting m.param_array[:] = loaded_params as the previously saved parameters. +Then you initialize the model by m.initialize_parameter(), which will make the model usable. +Be aware that up to this point the model is in an inconsistent state and cannot be used to produce any results. + +```python +# let X, Y be data loaded above +# Model creation: +m = GPy.models.GPRegression(X, Y) +m.optimize() +# 1: Saving a model: +np.save('model_save.npy', m.param_array) +# 2: loading a model +# Model creation, without initialization: +m_load = GPy.models.GPRegression(X, Y, initialize=False) +m_load.update_model(False) # do not call the underlying expensive algebra on load +m_load.initialize_parameter() # Initialize the parameters (connect the parameters up) +m_load[:] = np.load('model_save.npy') # Load the parameters +m_load.update_model(True) # Call the algebra only once +print(m_load) +``` + + ## Running unit tests: Ensure nose is installed via pip: @@ -106,7 +156,7 @@ or from within IPython or using setuptools python setup.py test - + ## Ubuntu hackers > Note: Right now the Ubuntu package index does not include scipy 0.16.0, and thus, cannot @@ -147,7 +197,7 @@ The HTML files are then stored in doc/build/html ## Funding Acknowledgements -Current support for the GPy software is coming through the following projects. +Current support for the GPy software is coming through the following projects. * [EU FP7-HEALTH Project Ref 305626](http://radiant-project.eu) "RADIANT: Rapid Development and Distribution of Statistical Tools for High-Throughput Sequencing Data" diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..ed0ec0d6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,92 @@ +environment: + pip_access: + secure: 8/ZjXFwtd1S7ixd7PJOpptupKKEDhm2da/q3unabJ00= + COVERALLS_REPO_TOKEN: + secure: d3Luic/ESkGaWnZrvWZTKrzO+xaVwJWaRCEP0F+K/9DQGPSRZsJ/Du5g3s4XF+tS + gpy_version: 1.4.0 + matrix: + - PYTHON_VERSION: 2.7 + MINICONDA: C:\Miniconda-x64 + - PYTHON_VERSION: 3.5 + MINICONDA: C:\Miniconda35-x64 + +#configuration: +# - Debug +# - Release + +install: + - "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%" + - conda config --set always_yes yes --set changeps1 no + - conda update -q conda + - conda info -a + - "conda create -q -n build-environment python=%PYTHON_VERSION% numpy scipy matplotlib" + - activate build-environment + # We need wheel installed to build wheels + - python -m pip install wheel + # GPy needs paramz + - python -m pip install paramz + - python -m pip install nose-show-skipped + - python -m pip install coverage + - python -m pip install coveralls + - python -m pip install codecov + - python -m pip install twine + - "python setup.py develop" + +build: off + +test_script: + # Put your test command here. + # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, + # you can remove "build.cmd" from the front of the command, as it's + # only needed to support those cases. + # Note that you must use the environment variable %PYTHON% to refer to + # the interpreter you're using - Appveyor does not do anything special + # to put the Python evrsion you want to use on PATH. + #- "build.cmd %PYTHON%\\python.exe setup.py test" + - "coverage run travis_tests.py" + +after_test: + # This step builds your wheels. + - "python setup.py bdist_wheel bdist_wininst" + - codecov + +artifacts: + # bdist_wheel puts your built wheel in the dist directory + - path: dist\* + + +deploy_script: +- echo [distutils] > %USERPROFILE%\\.pypirc +- echo index-servers = >> %USERPROFILE%\\.pypirc +- echo pypi >> %USERPROFILE%\\.pypirc +- echo test >> %USERPROFILE%\\.pypirc +- echo[ +- echo [pypi] >> %USERPROFILE%\\.pypirc +- echo username:maxz >> %USERPROFILE%\\.pypirc +- echo password:%pip_access% >> %USERPROFILE%\\.pypirc +- echo[ +- echo [test] >> %USERPROFILE%\\.pypirc +- echo repository:https://testpypi.python.org/pypi >> %USERPROFILE%\\.pypirc +- echo username:maxz >> %USERPROFILE%\\.pypirc +- echo password:%pip_access% >> %USERPROFILE%\\.pypirc +- ps: >- + if ($env:APPVEYOR_REPO_BRANCH -eq 'devel') { + twine upload --skip-existing -r test dist/* + } + elseif ($env:APPVEYOR_REPO_BRANCH -eq 'deploy') { + twine upload --skip-existing dist/* + } + else { + echo not deploying on other branches + } + +# deploy: +# - provider: GitHub +# release: GPy-v$(gpy_version) +# description: 'GPy windows install' +# artifact: dist/*.exe # upload wininst to GitHub +# draft: false +# prerelease: false +# on: +# branch: deploy # release from deploy branch only +# appveyor_repo_tag: true # deploy on tag push only \ No newline at end of file diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..a8a1ba08 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,24 @@ +codecov: + branch: devel + +coverage: + precision: 2 + round: down + range: "40...100" + + status: + project: + default: + target: auto + if_no_uploads: error + + patch: + default: + if_no_uploads: error + + changes: true + + +comment: + layout: "header, diff, changes, suggestions" + behavior: default \ No newline at end of file diff --git a/doc/source/GPy.core.parameterization.rst b/doc/source/GPy.core.parameterization.rst deleted file mode 100644 index 788e3af8..00000000 --- a/doc/source/GPy.core.parameterization.rst +++ /dev/null @@ -1,118 +0,0 @@ -GPy.core.parameterization package -================================= - -Submodules ----------- - -GPy.core.parameterization.domains module ----------------------------------------- - -.. automodule:: GPy.core.parameterization.domains - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.index_operations module -------------------------------------------------- - -.. automodule:: GPy.core.parameterization.index_operations - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.lists_and_dicts module ------------------------------------------------- - -.. automodule:: GPy.core.parameterization.lists_and_dicts - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.observable module -------------------------------------------- - -.. automodule:: GPy.core.parameterization.observable - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.observable_array module -------------------------------------------------- - -.. automodule:: GPy.core.parameterization.observable_array - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.param module --------------------------------------- - -.. automodule:: GPy.core.parameterization.param - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.parameter_core module ------------------------------------------------ - -.. automodule:: GPy.core.parameterization.parameter_core - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.parameterized module ----------------------------------------------- - -.. automodule:: GPy.core.parameterization.parameterized - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.priors module ---------------------------------------- - -.. automodule:: GPy.core.parameterization.priors - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.ties_and_remappings module ----------------------------------------------------- - -.. automodule:: GPy.core.parameterization.ties_and_remappings - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.transformations module ------------------------------------------------- - -.. automodule:: GPy.core.parameterization.transformations - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.updateable module -------------------------------------------- - -.. automodule:: GPy.core.parameterization.updateable - :members: - :undoc-members: - :show-inheritance: - -GPy.core.parameterization.variational module --------------------------------------------- - -.. automodule:: GPy.core.parameterization.variational - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.core.parameterization - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.core.rst b/doc/source/GPy.core.rst deleted file mode 100644 index 66878101..00000000 --- a/doc/source/GPy.core.rst +++ /dev/null @@ -1,85 +0,0 @@ -GPy.core package -================ - -Subpackages ------------ - -.. toctree:: - - GPy.core.parameterization - -Submodules ----------- - -GPy.core.gp module ------------------- - -.. automodule:: GPy.core.gp - :members: - :undoc-members: - :show-inheritance: - -GPy.core.mapping module ------------------------ - -.. automodule:: GPy.core.mapping - :members: - :undoc-members: - :show-inheritance: - -GPy.core.model module ---------------------- - -.. automodule:: GPy.core.model - :members: - :undoc-members: - :show-inheritance: - -GPy.core.sparse_gp module -------------------------- - -.. automodule:: GPy.core.sparse_gp - :members: - :undoc-members: - :show-inheritance: - -GPy.core.sparse_gp_mpi module ------------------------------ - -.. automodule:: GPy.core.sparse_gp_mpi - :members: - :undoc-members: - :show-inheritance: - -GPy.core.svgp module --------------------- - -.. automodule:: GPy.core.svgp - :members: - :undoc-members: - :show-inheritance: - -GPy.core.symbolic module ------------------------- - -.. automodule:: GPy.core.symbolic - :members: - :undoc-members: - :show-inheritance: - -GPy.core.verbose_optimization module ------------------------------------- - -.. automodule:: GPy.core.verbose_optimization - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.core - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.examples.rst b/doc/source/GPy.examples.rst deleted file mode 100644 index a2919eab..00000000 --- a/doc/source/GPy.examples.rst +++ /dev/null @@ -1,54 +0,0 @@ -GPy.examples package -==================== - -Submodules ----------- - -GPy.examples.classification module ----------------------------------- - -.. automodule:: GPy.examples.classification - :members: - :undoc-members: - :show-inheritance: - -GPy.examples.coreg_example module ---------------------------------- - -.. automodule:: GPy.examples.coreg_example - :members: - :undoc-members: - :show-inheritance: - -GPy.examples.dimensionality_reduction module --------------------------------------------- - -.. automodule:: GPy.examples.dimensionality_reduction - :members: - :undoc-members: - :show-inheritance: - -GPy.examples.non_gaussian module --------------------------------- - -.. automodule:: GPy.examples.non_gaussian - :members: - :undoc-members: - :show-inheritance: - -GPy.examples.regression module ------------------------------- - -.. automodule:: GPy.examples.regression - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.examples - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.inference.latent_function_inference.rst b/doc/source/GPy.inference.latent_function_inference.rst deleted file mode 100644 index c374e73b..00000000 --- a/doc/source/GPy.inference.latent_function_inference.rst +++ /dev/null @@ -1,102 +0,0 @@ -GPy.inference.latent_function_inference package -=============================================== - -Submodules ----------- - -GPy.inference.latent_function_inference.dtc module --------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.dtc - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.exact_gaussian_inference module ------------------------------------------------------------------------ - -.. automodule:: GPy.inference.latent_function_inference.exact_gaussian_inference - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.expectation_propagation module ----------------------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.expectation_propagation - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.fitc module ---------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.fitc - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.inferenceX module ---------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.inferenceX - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.laplace module ------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.laplace - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.posterior module --------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.posterior - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.svgp module ---------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.svgp - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.var_dtc module ------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.var_dtc - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.var_dtc_parallel module ---------------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.var_dtc_parallel - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.latent_function_inference.var_gauss module --------------------------------------------------------- - -.. automodule:: GPy.inference.latent_function_inference.var_gauss - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.inference.latent_function_inference - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.inference.mcmc.rst b/doc/source/GPy.inference.mcmc.rst deleted file mode 100644 index 273658b7..00000000 --- a/doc/source/GPy.inference.mcmc.rst +++ /dev/null @@ -1,30 +0,0 @@ -GPy.inference.mcmc package -========================== - -Submodules ----------- - -GPy.inference.mcmc.hmc module ------------------------------ - -.. automodule:: GPy.inference.mcmc.hmc - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.mcmc.samplers module ----------------------------------- - -.. automodule:: GPy.inference.mcmc.samplers - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.inference.mcmc - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.inference.optimization.rst b/doc/source/GPy.inference.optimization.rst deleted file mode 100644 index f5f2a930..00000000 --- a/doc/source/GPy.inference.optimization.rst +++ /dev/null @@ -1,54 +0,0 @@ -GPy.inference.optimization package -================================== - -Submodules ----------- - -GPy.inference.optimization.conjugate_gradient_descent module ------------------------------------------------------------- - -.. automodule:: GPy.inference.optimization.conjugate_gradient_descent - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.optimization.gradient_descent_update_rules module ---------------------------------------------------------------- - -.. automodule:: GPy.inference.optimization.gradient_descent_update_rules - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.optimization.optimization module ----------------------------------------------- - -.. automodule:: GPy.inference.optimization.optimization - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.optimization.scg module -------------------------------------- - -.. automodule:: GPy.inference.optimization.scg - :members: - :undoc-members: - :show-inheritance: - -GPy.inference.optimization.stochastics module ---------------------------------------------- - -.. automodule:: GPy.inference.optimization.stochastics - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.inference.optimization - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.inference.rst b/doc/source/GPy.inference.rst deleted file mode 100644 index 235f804b..00000000 --- a/doc/source/GPy.inference.rst +++ /dev/null @@ -1,19 +0,0 @@ -GPy.inference package -===================== - -Subpackages ------------ - -.. toctree:: - - GPy.inference.latent_function_inference - GPy.inference.mcmc - GPy.inference.optimization - -Module contents ---------------- - -.. automodule:: GPy.inference - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.kern.rst b/doc/source/GPy.kern.rst deleted file mode 100644 index bb61443b..00000000 --- a/doc/source/GPy.kern.rst +++ /dev/null @@ -1,17 +0,0 @@ -GPy.kern package -================ - -Subpackages ------------ - -.. toctree:: - - GPy.kern.src - -Module contents ---------------- - -.. automodule:: GPy.kern - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.kern.src.psi_comp.rst b/doc/source/GPy.kern.src.psi_comp.rst deleted file mode 100644 index dfa3c270..00000000 --- a/doc/source/GPy.kern.src.psi_comp.rst +++ /dev/null @@ -1,70 +0,0 @@ -GPy.kern.src.psi_comp package -============================= - -Submodules ----------- - -GPy.kern.src.psi_comp.gaussherm module --------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.gaussherm - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.linear_psi_comp module --------------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.linear_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.rbf_psi_comp module ------------------------------------------ - -.. automodule:: GPy.kern.src.psi_comp.rbf_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.rbf_psi_gpucomp module --------------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.rbf_psi_gpucomp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.sslinear_psi_comp module ----------------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.sslinear_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.ssrbf_psi_comp module -------------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.ssrbf_psi_comp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.psi_comp.ssrbf_psi_gpucomp module ----------------------------------------------- - -.. automodule:: GPy.kern.src.psi_comp.ssrbf_psi_gpucomp - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.kern.src.psi_comp - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.kern.src.rst b/doc/source/GPy.kern.src.rst deleted file mode 100644 index ccbc3f99..00000000 --- a/doc/source/GPy.kern.src.rst +++ /dev/null @@ -1,237 +0,0 @@ -GPy.kern.src package -==================== - -Subpackages ------------ - -.. toctree:: - - GPy.kern.src.psi_comp - -Submodules ----------- - -GPy.kern.src.ODE_UY module --------------------------- - -.. automodule:: GPy.kern.src.ODE_UY - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.ODE_UYC module ---------------------------- - -.. automodule:: GPy.kern.src.ODE_UYC - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.ODE_st module --------------------------- - -.. automodule:: GPy.kern.src.ODE_st - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.ODE_t module -------------------------- - -.. automodule:: GPy.kern.src.ODE_t - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.add module ------------------------ - -.. automodule:: GPy.kern.src.add - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.basis_funcs module -------------------------------- - -.. automodule:: GPy.kern.src.basis_funcs - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.brownian module ----------------------------- - -.. automodule:: GPy.kern.src.brownian - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.coregionalize module ---------------------------------- - -.. automodule:: GPy.kern.src.coregionalize - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.coregionalize_cython module ----------------------------------------- - -.. automodule:: GPy.kern.src.coregionalize_cython - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.eq_ode2 module ---------------------------- - -.. automodule:: GPy.kern.src.eq_ode2 - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.independent_outputs module ---------------------------------------- - -.. automodule:: GPy.kern.src.independent_outputs - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.kern module ------------------------- - -.. automodule:: GPy.kern.src.kern - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.kernel_slice_operations module -------------------------------------------- - -.. automodule:: GPy.kern.src.kernel_slice_operations - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.linear module --------------------------- - -.. automodule:: GPy.kern.src.linear - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.mlp module ------------------------ - -.. automodule:: GPy.kern.src.mlp - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.periodic module ----------------------------- - -.. automodule:: GPy.kern.src.periodic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.poly module ------------------------- - -.. automodule:: GPy.kern.src.poly - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.prod module ------------------------- - -.. automodule:: GPy.kern.src.prod - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.rbf module ------------------------ - -.. automodule:: GPy.kern.src.rbf - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.spline module --------------------------- - -.. automodule:: GPy.kern.src.spline - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.splitKern module ------------------------------ - -.. automodule:: GPy.kern.src.splitKern - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.standard_periodic module -------------------------------------- - -.. automodule:: GPy.kern.src.standard_periodic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.static module --------------------------- - -.. automodule:: GPy.kern.src.static - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.stationary module ------------------------------- - -.. automodule:: GPy.kern.src.stationary - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.stationary_cython module -------------------------------------- - -.. automodule:: GPy.kern.src.stationary_cython - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.symbolic module ----------------------------- - -.. automodule:: GPy.kern.src.symbolic - :members: - :undoc-members: - :show-inheritance: - -GPy.kern.src.trunclinear module -------------------------------- - -.. automodule:: GPy.kern.src.trunclinear - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.kern.src - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.likelihoods.rst b/doc/source/GPy.likelihoods.rst deleted file mode 100644 index 15d1952b..00000000 --- a/doc/source/GPy.likelihoods.rst +++ /dev/null @@ -1,94 +0,0 @@ -GPy.likelihoods package -======================= - -Submodules ----------- - -GPy.likelihoods.bernoulli module --------------------------------- - -.. automodule:: GPy.likelihoods.bernoulli - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.binomial module -------------------------------- - -.. automodule:: GPy.likelihoods.binomial - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.exponential module ----------------------------------- - -.. automodule:: GPy.likelihoods.exponential - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.gamma module ----------------------------- - -.. automodule:: GPy.likelihoods.gamma - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.gaussian module -------------------------------- - -.. automodule:: GPy.likelihoods.gaussian - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.likelihood module ---------------------------------- - -.. automodule:: GPy.likelihoods.likelihood - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.link_functions module -------------------------------------- - -.. automodule:: GPy.likelihoods.link_functions - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.mixed_noise module ----------------------------------- - -.. automodule:: GPy.likelihoods.mixed_noise - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.poisson module ------------------------------- - -.. automodule:: GPy.likelihoods.poisson - :members: - :undoc-members: - :show-inheritance: - -GPy.likelihoods.student_t module --------------------------------- - -.. automodule:: GPy.likelihoods.student_t - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.likelihoods - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.mappings.rst b/doc/source/GPy.mappings.rst deleted file mode 100644 index dad16d34..00000000 --- a/doc/source/GPy.mappings.rst +++ /dev/null @@ -1,78 +0,0 @@ -GPy.mappings package -==================== - -Submodules ----------- - -GPy.mappings.additive module ----------------------------- - -.. automodule:: GPy.mappings.additive - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.compound module ----------------------------- - -.. automodule:: GPy.mappings.compound - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.constant module ----------------------------- - -.. automodule:: GPy.mappings.constant - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.identity module ----------------------------- - -.. automodule:: GPy.mappings.identity - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.kernel module --------------------------- - -.. automodule:: GPy.mappings.kernel - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.linear module --------------------------- - -.. automodule:: GPy.mappings.linear - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.mlp module ------------------------ - -.. automodule:: GPy.mappings.mlp - :members: - :undoc-members: - :show-inheritance: - -GPy.mappings.piecewise_linear module ------------------------------------- - -.. automodule:: GPy.mappings.piecewise_linear - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.mappings - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.models.rst b/doc/source/GPy.models.rst deleted file mode 100644 index e65b4fb0..00000000 --- a/doc/source/GPy.models.rst +++ /dev/null @@ -1,198 +0,0 @@ -GPy.models package -================== - -Submodules ----------- - -GPy.models.bayesian_gplvm module --------------------------------- - -.. automodule:: GPy.models.bayesian_gplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.bayesian_gplvm_minibatch module ------------------------------------------- - -.. automodule:: GPy.models.bayesian_gplvm_minibatch - :members: - :undoc-members: - :show-inheritance: - -GPy.models.bcgplvm module -------------------------- - -.. automodule:: GPy.models.bcgplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.dpgplvm module -------------------------- - -.. automodule:: GPy.models.dpgplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_classification module ------------------------------------ - -.. automodule:: GPy.models.gp_classification - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_coregionalized_regression module ----------------------------------------------- - -.. automodule:: GPy.models.gp_coregionalized_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_heteroscedastic_regression module ------------------------------------------------ - -.. automodule:: GPy.models.gp_heteroscedastic_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_kronecker_gaussian_regression module --------------------------------------------------- - -.. automodule:: GPy.models.gp_kronecker_gaussian_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_regression module -------------------------------- - -.. automodule:: GPy.models.gp_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gp_var_gauss module ------------------------------- - -.. automodule:: GPy.models.gp_var_gauss - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gplvm module ------------------------ - -.. automodule:: GPy.models.gplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.gradient_checker module ----------------------------------- - -.. automodule:: GPy.models.gradient_checker - :members: - :undoc-members: - :show-inheritance: - -GPy.models.mrd module ---------------------- - -.. automodule:: GPy.models.mrd - :members: - :undoc-members: - :show-inheritance: - -GPy.models.one_vs_all_classification module -------------------------------------------- - -.. automodule:: GPy.models.one_vs_all_classification - :members: - :undoc-members: - :show-inheritance: - -GPy.models.one_vs_all_sparse_classification module --------------------------------------------------- - -.. automodule:: GPy.models.one_vs_all_sparse_classification - :members: - :undoc-members: - :show-inheritance: - -GPy.models.sparse_gp_classification module ------------------------------------------- - -.. automodule:: GPy.models.sparse_gp_classification - :members: - :undoc-members: - :show-inheritance: - -GPy.models.sparse_gp_coregionalized_regression module ------------------------------------------------------ - -.. automodule:: GPy.models.sparse_gp_coregionalized_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.sparse_gp_minibatch module -------------------------------------- - -.. automodule:: GPy.models.sparse_gp_minibatch - :members: - :undoc-members: - :show-inheritance: - -GPy.models.sparse_gp_regression module --------------------------------------- - -.. automodule:: GPy.models.sparse_gp_regression - :members: - :undoc-members: - :show-inheritance: - -GPy.models.sparse_gplvm module ------------------------------- - -.. automodule:: GPy.models.sparse_gplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.ss_gplvm module --------------------------- - -.. automodule:: GPy.models.ss_gplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.models.ss_mrd module ------------------------- - -.. automodule:: GPy.models.ss_mrd - :members: - :undoc-members: - :show-inheritance: - -GPy.models.warped_gp module ---------------------------- - -.. automodule:: GPy.models.warped_gp - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.models - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.plotting.gpy_plot.rst b/doc/source/GPy.plotting.gpy_plot.rst deleted file mode 100644 index 8391cd3a..00000000 --- a/doc/source/GPy.plotting.gpy_plot.rst +++ /dev/null @@ -1,62 +0,0 @@ -GPy.plotting.gpy_plot package -============================= - -Submodules ----------- - -GPy.plotting.gpy_plot.data_plots module ---------------------------------------- - -.. automodule:: GPy.plotting.gpy_plot.data_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.gpy_plot.gp_plots module -------------------------------------- - -.. automodule:: GPy.plotting.gpy_plot.gp_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.gpy_plot.inference_plots module --------------------------------------------- - -.. automodule:: GPy.plotting.gpy_plot.inference_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.gpy_plot.kernel_plots module ------------------------------------------ - -.. automodule:: GPy.plotting.gpy_plot.kernel_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.gpy_plot.latent_plots module ------------------------------------------ - -.. automodule:: GPy.plotting.gpy_plot.latent_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.gpy_plot.plot_util module --------------------------------------- - -.. automodule:: GPy.plotting.gpy_plot.plot_util - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.plotting.gpy_plot - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.plotting.matplot_dep.controllers.rst b/doc/source/GPy.plotting.matplot_dep.controllers.rst deleted file mode 100644 index 239f8e79..00000000 --- a/doc/source/GPy.plotting.matplot_dep.controllers.rst +++ /dev/null @@ -1,30 +0,0 @@ -GPy.plotting.matplot_dep.controllers package -============================================ - -Submodules ----------- - -GPy.plotting.matplot_dep.controllers.axis_event_controller module ------------------------------------------------------------------ - -.. automodule:: GPy.plotting.matplot_dep.controllers.axis_event_controller - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.controllers.imshow_controller module -------------------------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.controllers.imshow_controller - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.plotting.matplot_dep.controllers - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.plotting.matplot_dep.rst b/doc/source/GPy.plotting.matplot_dep.rst deleted file mode 100644 index 9521d9e6..00000000 --- a/doc/source/GPy.plotting.matplot_dep.rst +++ /dev/null @@ -1,117 +0,0 @@ -GPy.plotting.matplot_dep package -================================ - -Subpackages ------------ - -.. toctree:: - - GPy.plotting.matplot_dep.controllers - -Submodules ----------- - -GPy.plotting.matplot_dep.defaults module ----------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.defaults - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.img_plots module ------------------------------------------ - -.. automodule:: GPy.plotting.matplot_dep.img_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.kernel_plots module --------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.kernel_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.mapping_plots module ---------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.mapping_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.maps module ------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.maps - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.plot_definitions module ------------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.plot_definitions - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.priors_plots module --------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.priors_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.ssgplvm module ---------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.ssgplvm - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.svig_plots module ------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.svig_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.util module ------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.util - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.variational_plots module -------------------------------------------------- - -.. automodule:: GPy.plotting.matplot_dep.variational_plots - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.matplot_dep.visualize module ------------------------------------------ - -.. automodule:: GPy.plotting.matplot_dep.visualize - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.plotting.matplot_dep - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.plotting.plotly_dep.rst b/doc/source/GPy.plotting.plotly_dep.rst deleted file mode 100644 index 52642e49..00000000 --- a/doc/source/GPy.plotting.plotly_dep.rst +++ /dev/null @@ -1,30 +0,0 @@ -GPy.plotting.plotly_dep package -=============================== - -Submodules ----------- - -GPy.plotting.plotly_dep.defaults module ---------------------------------------- - -.. automodule:: GPy.plotting.plotly_dep.defaults - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.plotly_dep.plot_definitions module ------------------------------------------------ - -.. automodule:: GPy.plotting.plotly_dep.plot_definitions - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.plotting.plotly_dep - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.plotting.rst b/doc/source/GPy.plotting.rst deleted file mode 100644 index 33c39c93..00000000 --- a/doc/source/GPy.plotting.rst +++ /dev/null @@ -1,39 +0,0 @@ -GPy.plotting package -==================== - -Subpackages ------------ - -.. toctree:: - - GPy.plotting.gpy_plot - GPy.plotting.matplot_dep - GPy.plotting.plotly_dep - -Submodules ----------- - -GPy.plotting.Tango module -------------------------- - -.. automodule:: GPy.plotting.Tango - :members: - :undoc-members: - :show-inheritance: - -GPy.plotting.abstract_plotting_library module ---------------------------------------------- - -.. automodule:: GPy.plotting.abstract_plotting_library - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.plotting - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.rst b/doc/source/GPy.rst deleted file mode 100644 index 9be6dbec..00000000 --- a/doc/source/GPy.rst +++ /dev/null @@ -1,26 +0,0 @@ -GPy package -=========== - -Subpackages ------------ - -.. toctree:: - - GPy.core - GPy.examples - GPy.inference - GPy.kern - GPy.likelihoods - GPy.mappings - GPy.models - GPy.plotting - GPy.testing - GPy.util - -Module contents ---------------- - -.. automodule:: GPy - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.testing.rst b/doc/source/GPy.testing.rst deleted file mode 100644 index a10c3d18..00000000 --- a/doc/source/GPy.testing.rst +++ /dev/null @@ -1,206 +0,0 @@ -GPy.testing package -=================== - -Submodules ----------- - -GPy.testing.bgplvm_minibatch_tests module ------------------------------------------ - -.. automodule:: GPy.testing.bgplvm_minibatch_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.cacher_tests module -------------------------------- - -.. automodule:: GPy.testing.cacher_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.cython_tests module -------------------------------- - -.. automodule:: GPy.testing.cython_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.examples_tests module ---------------------------------- - -.. automodule:: GPy.testing.examples_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.fitc module ------------------------ - -.. automodule:: GPy.testing.fitc - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.gp_tests module ---------------------------- - -.. automodule:: GPy.testing.gp_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.index_operations_tests module ------------------------------------------ - -.. automodule:: GPy.testing.index_operations_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.inference_tests module ----------------------------------- - -.. automodule:: GPy.testing.inference_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.kernel_tests module -------------------------------- - -.. automodule:: GPy.testing.kernel_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.likelihood_tests module ------------------------------------ - -.. automodule:: GPy.testing.likelihood_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.linalg_test module ------------------------------- - -.. automodule:: GPy.testing.linalg_test - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.link_function_tests module --------------------------------------- - -.. automodule:: GPy.testing.link_function_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.mapping_tests module --------------------------------- - -.. automodule:: GPy.testing.mapping_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.meanfunc_tests module ---------------------------------- - -.. automodule:: GPy.testing.meanfunc_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.misc_tests module ------------------------------ - -.. automodule:: GPy.testing.misc_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.model_tests module ------------------------------- - -.. automodule:: GPy.testing.model_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.mpi_tests module ----------------------------- - -.. automodule:: GPy.testing.mpi_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.observable_tests module ------------------------------------ - -.. automodule:: GPy.testing.observable_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.parameterized_tests module --------------------------------------- - -.. automodule:: GPy.testing.parameterized_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.pickle_tests module -------------------------------- - -.. automodule:: GPy.testing.pickle_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.plotting_tests module ---------------------------------- - -.. automodule:: GPy.testing.plotting_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.prior_tests module ------------------------------- - -.. automodule:: GPy.testing.prior_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.rv_transformation_tests module ------------------------------------------- - -.. automodule:: GPy.testing.rv_transformation_tests - :members: - :undoc-members: - :show-inheritance: - -GPy.testing.svgp_tests module ------------------------------ - -.. automodule:: GPy.testing.svgp_tests - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.testing - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/GPy.util.rst b/doc/source/GPy.util.rst deleted file mode 100644 index 354a3cce..00000000 --- a/doc/source/GPy.util.rst +++ /dev/null @@ -1,238 +0,0 @@ -GPy.util package -================ - -Submodules ----------- - -GPy.util.block_matrices module ------------------------------- - -.. automodule:: GPy.util.block_matrices - :members: - :undoc-members: - :show-inheritance: - -GPy.util.caching module ------------------------ - -.. automodule:: GPy.util.caching - :members: - :undoc-members: - :show-inheritance: - -GPy.util.choleskies module --------------------------- - -.. automodule:: GPy.util.choleskies - :members: - :undoc-members: - :show-inheritance: - -GPy.util.choleskies_cython module ---------------------------------- - -.. automodule:: GPy.util.choleskies_cython - :members: - :undoc-members: - :show-inheritance: - -GPy.util.classification module ------------------------------- - -.. automodule:: GPy.util.classification - :members: - :undoc-members: - :show-inheritance: - -GPy.util.config module ----------------------- - -.. automodule:: GPy.util.config - :members: - :undoc-members: - :show-inheritance: - -GPy.util.datasets module ------------------------- - -.. automodule:: GPy.util.datasets - :members: - :undoc-members: - :show-inheritance: - -GPy.util.debug module ---------------------- - -.. automodule:: GPy.util.debug - :members: - :undoc-members: - :show-inheritance: - -GPy.util.decorators module --------------------------- - -.. automodule:: GPy.util.decorators - :members: - :undoc-members: - :show-inheritance: - -GPy.util.diag module --------------------- - -.. automodule:: GPy.util.diag - :members: - :undoc-members: - :show-inheritance: - -GPy.util.functions module -------------------------- - -.. automodule:: GPy.util.functions - :members: - :undoc-members: - :show-inheritance: - -GPy.util.gpu_init module ------------------------- - -.. automodule:: GPy.util.gpu_init - :members: - :undoc-members: - :show-inheritance: - -GPy.util.initialization module ------------------------------- - -.. automodule:: GPy.util.initialization - :members: - :undoc-members: - :show-inheritance: - -GPy.util.linalg module ----------------------- - -.. automodule:: GPy.util.linalg - :members: - :undoc-members: - :show-inheritance: - -GPy.util.linalg_cython module ------------------------------ - -.. automodule:: GPy.util.linalg_cython - :members: - :undoc-members: - :show-inheritance: - -GPy.util.linalg_gpu module --------------------------- - -.. automodule:: GPy.util.linalg_gpu - :members: - :undoc-members: - :show-inheritance: - -GPy.util.ln_diff_erfs module ----------------------------- - -.. automodule:: GPy.util.ln_diff_erfs - :members: - :undoc-members: - :show-inheritance: - -GPy.util.misc module --------------------- - -.. automodule:: GPy.util.misc - :members: - :undoc-members: - :show-inheritance: - -GPy.util.mocap module ---------------------- - -.. automodule:: GPy.util.mocap - :members: - :undoc-members: - :show-inheritance: - -GPy.util.multioutput module ---------------------------- - -.. automodule:: GPy.util.multioutput - :members: - :undoc-members: - :show-inheritance: - -GPy.util.netpbmfile module --------------------------- - -.. automodule:: GPy.util.netpbmfile - :members: - :undoc-members: - :show-inheritance: - -GPy.util.normalizer module --------------------------- - -.. automodule:: GPy.util.normalizer - :members: - :undoc-members: - :show-inheritance: - -GPy.util.parallel module ------------------------- - -.. automodule:: GPy.util.parallel - :members: - :undoc-members: - :show-inheritance: - -GPy.util.pca module -------------------- - -.. automodule:: GPy.util.pca - :members: - :undoc-members: - :show-inheritance: - -GPy.util.squashers module -------------------------- - -.. automodule:: GPy.util.squashers - :members: - :undoc-members: - :show-inheritance: - -GPy.util.subarray_and_sorting module ------------------------------------- - -.. automodule:: GPy.util.subarray_and_sorting - :members: - :undoc-members: - :show-inheritance: - -GPy.util.univariate_Gaussian module ------------------------------------ - -.. automodule:: GPy.util.univariate_Gaussian - :members: - :undoc-members: - :show-inheritance: - -GPy.util.warping_functions module ---------------------------------- - -.. automodule:: GPy.util.warping_functions - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: GPy.util - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/source/conf.py b/doc/source/conf.py index 0885c380..1f9c98b6 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -22,7 +22,7 @@ import shlex #for p in os.walk('../../GPy'): # sys.path.append(p[0]) sys.path.insert(0, os.path.abspath('../../')) -sys.path.insert(0, os.path.abspath('../../GPy/')) +#sys.path.insert(0, os.path.abspath('../../GPy/')) on_rtd = os.environ.get('READTHEDOCS', None) == 'True' @@ -82,7 +82,8 @@ MOCK_MODULES = ['scipy.linalg.blas', 'blas', 'scipy.optimize', 'scipy.optimize.l 'sympy', 'sympy.utilities.iterables', 'sympy.utilities.lambdify', 'sympy.utilities', 'sympy.utilities.codegen', 'sympy.core.cache', 'sympy.core', 'sympy.parsing', 'sympy.parsing.sympy_parser', - 'nose', 'nose.tools'] + 'nose', 'nose.tools' + ] autodoc_mock_imports = MOCK_MODULES # diff --git a/doc/source/requirements.txt b/doc/source/requirements.txt index d5f47c6b..dd3ba36f 100644 --- a/doc/source/requirements.txt +++ b/doc/source/requirements.txt @@ -1 +1 @@ -paramz +paramz \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 188a6bab..9546c53a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,15 @@ [bumpversion] -current_version = 0.9.7 -tag = True +current_version = 1.4.0 +tag = False commit = True [bumpversion:file:GPy/__version__.py] -[bdist_wheel] -universal = 1 +[bumpversion:file:appveyor.yml] [upload_docs] upload-dir = doc/build/html +[medatdata] +description-file = README.rst + diff --git a/setup.py b/setup.py index fee4a10d..43e70815 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,11 @@ def read_to_rst(fname): except ImportError: return read(fname) -desc = read_to_rst('README.md') +desc = """ + +Please refer to the github homepage for detailed instructions on installation and usage. + +""" version_dummy = {} exec(read('GPy/__version__.py'), version_dummy) @@ -94,6 +98,10 @@ ext_mods = [Extension(name='GPy.kern.src.stationary_cython', Extension(name='GPy.kern.src.coregionalize_cython', sources=['GPy/kern/src/coregionalize_cython.c'], include_dirs=[np.get_include(),'.'], + extra_compile_args=compile_flags), + Extension(name='GPy.models.state_space_cython', + sources=['GPy/models/state_space_cython.c'], + include_dirs=[np.get_include(),'.'], extra_compile_args=compile_flags)] setup(name = 'GPy', @@ -101,6 +109,7 @@ setup(name = 'GPy', author = read_to_rst('AUTHORS.txt'), author_email = "gpy.authors@gmail.com", description = ("The Gaussian Process Toolbox"), + long_description = desc, license = "BSD 3-clause", keywords = "machine-learning gaussian-processes kernels", url = "http://sheffieldml.github.com/GPy/", @@ -139,8 +148,7 @@ setup(name = 'GPy', include_package_data = True, py_modules = ['GPy.__init__'], test_suite = 'GPy.testing', - long_description=desc, - install_requires=['numpy>=1.7', 'scipy>=0.16', 'six', 'paramz'], + install_requires = ['numpy>=1.7', 'scipy>=0.16', 'six', 'paramz>=0.6.8'], extras_require = {'docs':['sphinx'], 'optional':['mpi4py', 'ipython>=4.0.0', @@ -172,21 +180,26 @@ home = os.getenv('HOME') or os.getenv('USERPROFILE') user_file = os.path.join(home,'.config', 'GPy', 'user.cfg') print("") -if not os.path.exists(user_file): - # Does an old config exist? - old_user_file = os.path.join(home,'.gpy_user.cfg') - if os.path.exists(old_user_file): - # Move it to new location: - print("GPy: Found old config file, moving to new location {}".format(user_file)) - os.rename(old_user_file, user_file) +try: + if not os.path.exists(user_file): + # Does an old config exist? + old_user_file = os.path.join(home,'.gpy_user.cfg') + if os.path.exists(old_user_file): + # Move it to new location: + print("GPy: Found old config file, moving to new location {}".format(user_file)) + if not os.path.exists(os.path.dirname(user_file)): + os.makedirs(os.path.dirname(user_file)) + os.rename(old_user_file, user_file) + else: + # No config file exists, save informative stub to user config folder: + print("GPy: Saving user configuration file to {}".format(user_file)) + if not os.path.exists(os.path.dirname(user_file)): + os.makedirs(os.path.dirname(user_file)) + with open(user_file, 'w') as f: + with open(local_file, 'r') as l: + tmp = l.read() + f.write(tmp) else: - # No config file exists, save informative stub to user config folder: - print("GPy: Saving user configuration file to {}".format(user_file)) - if not os.path.exists(os.path.dirname(user_file)): - os.makedirs(os.path.dirname(user_file)) - with open(user_file, 'w') as f: - with open(local_file, 'r') as l: - tmp = l.read() - f.write(tmp) -else: - print("GPy: User configuration file at location {}".format(user_file)) + print("GPy: User configuration file at location {}".format(user_file)) +except: + print("GPy: Could not write user configuration file {}".format(user_file)) diff --git a/travis_tests.py b/travis_tests.py index 79a75f54..16713962 100644 --- a/travis_tests.py +++ b/travis_tests.py @@ -33,6 +33,8 @@ import matplotlib matplotlib.use('agg') -import nose -nose.main('GPy', defaultTest='GPy/testing/') +import nose, warnings +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + nose.main('GPy', defaultTest='GPy/testing', argv=['', '--show-skipped'])