mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-02 00:02:38 +02:00
svgp working with reordered chols
This commit is contained in:
parent
2249ec06a5
commit
77093a304c
4 changed files with 51 additions and 59 deletions
|
|
@ -8,14 +8,14 @@ import numpy as np
|
|||
cimport numpy as np
|
||||
|
||||
def flat_to_triang(np.ndarray[double, ndim=2] flat, int M):
|
||||
"""take a matrix D x N and return a D X M x M array where
|
||||
"""take a matrix N x D and return a D X M x M array where
|
||||
|
||||
N = M(M+1)/2
|
||||
|
||||
the lower triangluar portion of the d'th slice of the result is filled by the d'th column of flat.
|
||||
"""
|
||||
cdef int D = flat.shape[0]
|
||||
cdef int N = flat.shape[1]
|
||||
cdef int D = flat.shape[1]
|
||||
cdef int N = flat.shape[0]
|
||||
cdef int count = 0
|
||||
cdef np.ndarray[double, ndim=3] ret = np.zeros((D, M, M))
|
||||
cdef int d, m, mm
|
||||
|
|
@ -23,7 +23,7 @@ def flat_to_triang(np.ndarray[double, ndim=2] flat, int M):
|
|||
count = 0
|
||||
for m in range(M):
|
||||
for mm in range(m+1):
|
||||
ret[d, m, mm] = flat[d,count]
|
||||
ret[d, m, mm] = flat[count,d]
|
||||
count += 1
|
||||
return ret
|
||||
|
||||
|
|
@ -32,13 +32,13 @@ def triang_to_flat(np.ndarray[double, ndim=3] L):
|
|||
cdef int M = L.shape[1]
|
||||
cdef int N = M*(M+1)/2
|
||||
cdef int count = 0
|
||||
cdef np.ndarray[double, ndim=2] flat = np.empty((D, N))
|
||||
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):
|
||||
for mm in range(m+1):
|
||||
flat[d,count] = L[d, m, mm]
|
||||
flat[count,d] = L[d, m, mm]
|
||||
count += 1
|
||||
return flat
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue