def _logdetA(self,K,w,nargout):
        '''
        Compute the log determinant ldA and the inverse iA of a square nxn matrix
        A = eye(n) + K*diag(w) from its LU decomposition; for negative definite A, we
        return ldA = Inf. We also return mwiA = -diag(w)*inv(A).
        [ldA,iA,mwiA] = _logdetA(K,w)'''
        n = K.shape[0]
        assert(K.shape[0] == K.shape[1])
        A = np.eye(n) + K*np.tile(w.T,(n,1))
        [L,U,P] = np.linalg.lu(A)    # compute LU decomposition, A = P'*L*U
        u = np.diag(U)
        signU = np.prod(np.sign(u))  # sign of U
        detP = 1                     # compute sign (and det) of the permutation matrix P
        p = np.dot(P,np.array(list(range(n))).T)
        for ii in range(n):
            if ii != p[ii]:
                detP = -detP
                j= [jj for jj,val in enumerate(p) if val == ii]
                p[ii,j[0]] = p[j[0],ii]
        if signU != detP:            # log becomes complex for negative values, encoded by infinity
            ldA = np.inf
        else:                        # det(L) = 1 and U triangular => det(A) = det(P)*prod(diag(U))
            ldA = np.log(np.abs(u)).sum()
        if 1 > nargout:
            iA = inv(U)*inv(L)*P;
            if nargout>2:
                mwiA = -np.tile(w,(1,n))*iA
                return ldA,iA,mwiA
            else:
                return ldA,iA
        else:
            return ldA
dataset/ETHPy150Open marionmari/pyGPs/pyGPs/Core/inf.py/Inference._logdetA/swapped operands of `>`