better cython compiler directives for choleskies

This commit is contained in:
James Hensman 2015-04-30 13:47:38 +01:00
parent e9ff315a19
commit 3c3af7f3fe
3 changed files with 211 additions and 625 deletions

View file

@ -13,7 +13,12 @@ class SVGP(LatentFunctionInference):
#expand cholesky representation
L = choleskies.flat_to_triang(q_u_chol)
S = np.einsum('ijk,ljk->ilk', L, L) #L.dot(L.T)
S_ein = np.einsum('ijk,ljk->ilk', L, L) #L.dot(L.T)
S = np.empty((num_outputs, num_inducing, num_inducing))
[np.dot(L[:,:,i], L[:,:,i].T, S[i,:,:]) for i in range(num_outputs)]
S = S.swapaxes(0,2)
#Si,_ = linalg.dpotri(np.asfortranarray(L), lower=1)
Si = choleskies.multiple_dpotri(L)
logdetS = np.array([2.*np.sum(np.log(np.abs(np.diag(L[:,:,i])))) for i in range(L.shape[-1])])

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,8 @@
#cython: wraparaound=False
#cython: boundscheck=False
#cython: nonecheck=False
# Copyright James Hensman and Alan Saul 2015
#cython: wraparaound(False)
#cython: boundscheck(False)
#cython: nonecheck(False)
import numpy as np
cimport numpy as np
@ -17,6 +18,7 @@ def flat_to_triang(np.ndarray[double, ndim=2] flat, int M):
cdef int D = flat.shape[1]
cdef int count = 0
cdef np.ndarray[double, ndim=3] ret = np.zeros((M, M, D))
cdef int d, m, mm
for d in range(D):
count = 0
for m in range(M):
@ -31,6 +33,7 @@ def triang_to_flat(np.ndarray[double, ndim=3] L):
cdef int N = M*(M+1)/2
cdef int count = 0
cdef np.ndarray[double, ndim=2] flat = np.empty((N, D))
cdef int d, m, mm
for d in range(D):
count = 0
for m in range(M):