# Path: reggie/utils/linalg.py
# def add_diagonal(A, d, copy=True):
# def cholesky(A, maxtries=5):
# def cholesky_update(L, B, C, x=None, c=None):
# def cholesky_inverse(A):
# def solve_triangular(A, B, trans=False):
# def solve_cholesky(A, B):
#         A = A.copy()
#     D = as_strided(A, shape, strides)
#     B = solve_triangular(L, B.T).T
#     C = cholesky(C - np.dot(B, B.T))
#     L = np.r_[np.c_[L, np.zeros_like(B.T)], np.c_[B, C]]
#     X, _ = lapack.dpotrs(A, B, lower=1)


import numpy as np
import scipy.optimize as spop
import warnings
from collections import namedtuple
from itertools import izip
from ...utils import linalg as la
"""
Inference for GP regression.
"""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function




__all__ = ['exact', 'laplace', 'fitc']


# create a named tuple which functions as storage for the posterior sufficient
# statistics.
Statistics = namedtuple('Statistics', 'L, a, w, lZ, dlZ, C')
Statistics.__new__.__defaults__ = (None, )


def exact(like, kern, mean, X, Y):
    K = kern.get_kernel(X)

# Path: reggie/utils/linalg.py
# def add_diagonal(A, d, copy=True):
# def cholesky(A, maxtries=5):
# def cholesky_update(L, B, C, x=None, c=None):
# def cholesky_inverse(A):
# def solve_triangular(A, B, trans=False):
# def solve_cholesky(A, B):
#         A = A.copy()
#     D = as_strided(A, shape, strides)
#     B = solve_triangular(L, B.T).T
#     C = cholesky(C - np.dot(B, B.T))
#     L = np.r_[np.c_[L, np.zeros_like(B.T)], np.c_[B, C]]
#     X, _ = lapack.dpotrs(A, B, lower=1)


# Path: reggie/models/gp/inference.py
import numpy as np
import scipy.optimize as spop
import warnings
from collections import namedtuple
from itertools import izip
from ...utils import linalg as la

"""
Inference for GP regression.
"""

from __future__ import division
from __future__ import absolute_import
from __future__ import print_function




__all__ = ['exact', 'laplace', 'fitc']


# create a named tuple which functions as storage for the posterior sufficient
# statistics.
Statistics = namedtuple('Statistics', 'L, a, w, lZ, dlZ, C')
Statistics.__new__.__defaults__ = (None, )


def exact(like, kern, mean, X, Y):
    K = kern.get_kernel(X)

    K = la.add_diagonal(K, like.get_variance())