def getDerMatrix(self,x=None,z=None,mode=None,der=None):
        self.checkInputGetDerMatrix(x,z,mode,der)
        if not x is None:
            n, D = x.shape
        if not z is None:
            nn, D = z.shape
        ell = old_div(1.,np.exp(self.hyp[0:D]))    # characteristic length scale
        sf2 = np.exp(2.*self.hyp[D])      # signal variance
        alpha = np.exp(self.hyp[D+1])
        if mode == 'self_test':           # self covariances for the test cases
            nn,D = z.shape
            D2 = np.zeros((nn,1))
        elif mode == 'train':             # compute covariance matix for dataset x
            tmp = np.dot(np.diag(ell),x.T).T
            D2 = spdist.cdist(tmp, tmp, 'sqeuclidean')
        elif mode == 'cross':             # compute covariance between data sets x and z
            D2 = spdist.cdist(np.dot(np.diag(ell),x.T).T, np.dot(np.diag(ell),z.T).T, 'sqeuclidean')
        if der < D:
            if mode == 'self_test':
                A = D2*0
            elif mode == 'train':
                tmp = old_div(np.atleast_2d(x[:,der]),ell[der])
                A = sf2 * ( 1.0 + 0.5*D2/alpha )**(-alpha-1) * spdist.cdist(tmp, tmp, 'sqeuclidean')
            elif mode == 'cross':
                A = sf2 * ( 1.0 + 0.5*D2/alpha )**(-alpha-1) * spdist.cdist(old_div(np.atleast_2d(x[:,der]).T,ell[der]), old_div(np.atleast_2d(z[:,der]).T,ell[der]), 'sqeuclidean')
        elif der==D:                # compute derivative matrix wrt magnitude parameter
            A = 2. * sf2 * ( ( 1.0 + 0.5*D2/alpha )**(-alpha) )
        elif der==(D+1):            # compute derivative matrix wrt magnitude parameter
            K = ( 1.0 + 0.5*D2/alpha )
            A = sf2 * K**(-alpha) * ( 0.5*D2/K - alpha*np.log(K) )
        else:
            raise Exception("Wrong derivative index in covRQard")
        return A
dataset/ETHPy150Open marionmari/pyGPs/pyGPs/Core/cov.py/RQard.getDerMatrix/original