# 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/utils/misc.py
# def rstate(rng=None):
#     """
#     Return a RandomState object. This is just a simple wrapper such that if rng
#     is already an instance of RandomState it will be passed through, otherwise
#     it will create a RandomState object using rng as its seed.
#     """
#     if not isinstance(rng, np.random.RandomState):
#         rng = np.random.RandomState(rng)
#     return rng


import numpy as np
from ...utils import linalg as la
from ...utils.misc import rstate
"""
Approximate finite-dimensional samples from a GP.
"""

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




class FourierSample(object):
    """
    Encapsulation of a continuous function sampled from a Gaussian process
    where this infinitely-parameterized object is approximated using a weighted
    sum of finitely many Fourier samples.
    """
    def __init__(self, like, kern, mean, X, Y, n, rng=None):

# 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/utils/misc.py
# def rstate(rng=None):
#     """
#     Return a RandomState object. This is just a simple wrapper such that if rng
#     is already an instance of RandomState it will be passed through, otherwise
#     it will create a RandomState object using rng as its seed.
#     """
#     if not isinstance(rng, np.random.RandomState):
#         rng = np.random.RandomState(rng)
#     return rng


# Path: reggie/models/gp/fourier.py
import numpy as np
from ...utils import linalg as la
from ...utils.misc import rstate

"""
Approximate finite-dimensional samples from a GP.
"""

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




class FourierSample(object):
    """
    Encapsulation of a continuous function sampled from a Gaussian process
    where this infinitely-parameterized object is approximated using a weighted
    sum of finitely many Fourier samples.
    """
    def __init__(self, like, kern, mean, X, Y, n, rng=None):

        rng = rstate(rng)