mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-01 15:52:39 +02:00
indentation...
This commit is contained in:
parent
16555aa11d
commit
56d749ded8
1 changed files with 18 additions and 18 deletions
|
|
@ -78,24 +78,24 @@ def force_F_ordered(A):
|
||||||
# return jitchol(A+np.eye(A.shape[0])*jitter, maxtries-1)
|
# return jitchol(A+np.eye(A.shape[0])*jitter, maxtries-1)
|
||||||
|
|
||||||
def jitchol(A, maxtries=5):
|
def jitchol(A, maxtries=5):
|
||||||
A = np.ascontiguousarray(A)
|
A = np.ascontiguousarray(A)
|
||||||
L, info = lapack.dpotrf(A, lower=1)
|
L, info = lapack.dpotrf(A, lower=1)
|
||||||
if info == 0:
|
if info == 0:
|
||||||
return L
|
return L
|
||||||
else:
|
else:
|
||||||
diagA = np.diag(A)
|
diagA = np.diag(A)
|
||||||
if np.any(diagA <= 0.):
|
if np.any(diagA <= 0.):
|
||||||
raise linalg.LinAlgError, "not pd: non-positive diagonal elements"
|
raise linalg.LinAlgError, "not pd: non-positive diagonal elements"
|
||||||
jitter = diagA.mean() * 1e-6
|
jitter = diagA.mean() * 1e-6
|
||||||
while maxtries > 0 and np.isfinite(jitter):
|
while maxtries > 0 and np.isfinite(jitter):
|
||||||
print 'Warning: adding jitter of {:.10e}'.format(jitter)
|
print 'Warning: adding jitter of {:.10e}'.format(jitter)
|
||||||
try:
|
try:
|
||||||
return linalg.cholesky(A + np.eye(A.shape[0]).T * jitter, lower=True)
|
return linalg.cholesky(A + np.eye(A.shape[0]).T * jitter, lower=True)
|
||||||
except:
|
except:
|
||||||
jitter *= 10
|
jitter *= 10
|
||||||
finally:
|
finally:
|
||||||
maxtries -= 1
|
maxtries -= 1
|
||||||
raise linalg.LinAlgError, "not positive definite, even with jitter."
|
raise linalg.LinAlgError, "not positive definite, even with jitter."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue