# Path: vampyre/solver/base.py
# class Solver(object):
#     """
#     Base class for solver
#     
#     :param hist_list:  String list of variables to save the history of.  
#        These will be saved in the :code:`hist_dict` dictionary
#     """    
#     def __init__(self, hist_list):
#         self.hist_list = hist_list
#         self.init_hist()
#         
#     def init_hist(self):
#         """
#         Initializes the history dictionary.
#         
#         This should be called any time :code:`hist_list` has been changed
#         """        
#         # Initialize the dictionary with an empty list for each item
#         self.hist_dict = {}
#         for attr in self.hist_list:
#             self.hist_dict[attr] = []
#             
#             
#     def save_hist(self):
#         """
#         Save the items in the history dictionary
#         
#         For each item :code:`attr` in :code:`self.hist_list`, the method
#         will make a copy of :code:`self.attr` and append it to the list,
#         :code:`self.hist_list['attr']`.  If :code:`self.attr` implements
#         a :code:`copy()` method, it will run that method to perform a deep
#         copy.  Otherwise, it will simply perform a shallow copy.
#         """
#         for attr in self.hist_list:
#             val = getattr(self,attr)
#             if hasattr(val,'copy'):
#                 if callable(val.copy):
#                     val = val.copy()                    
#             self.hist_dict[attr].append(val)


import numpy as np
import time
import vampyre.estim as estim
import vampyre.trans as trans
import vampyre.common as common
from vampyre.solver.base import Solver
# Import other subpackages

# Import methods and classes from the same vampyre sub-package


class Gamp(Solver):
    """
    Gamp solver
    
    The GAMP solver performs estimation on a penalty function of the form:
    
    :code:`f(z) = f0(z0) + f1(z1) s.t. z1=A.dot(z0)`
    
    where :math:`f0(z)` and :math:`f1(z)` are two penalty functions
    
    :param est0:  Estimator corresonding to :math:`f0(z)`
    :param est1:  Estimator corresonding to :math:`f1(z)`
    :param A:  Linear transform
    :param hist_list:  List of attributes to save the history of during the
       course of the iterations.
    :param nit:  Maximum number of iterations          
    :param comp_cost:  Compute cost
    :param prt_period:  Period for printing progress (value of 0 indicates
        no printing)
    :param step_adapt:  Enable adaptive step size
    :param step:  Initial step size
    """
    def __init__(self, est0, est1, A, hist_list=[], nit=10,\
        comp_cost=True, prt_period=0, is_complex=False, map_est=False,\
        step_adapt=False,step=0.95,step_min=1e-6):

# Path: vampyre/solver/base.py
# class Solver(object):
#     """
#     Base class for solver
#     
#     :param hist_list:  String list of variables to save the history of.  
#        These will be saved in the :code:`hist_dict` dictionary
#     """    
#     def __init__(self, hist_list):
#         self.hist_list = hist_list
#         self.init_hist()
#         
#     def init_hist(self):
#         """
#         Initializes the history dictionary.
#         
#         This should be called any time :code:`hist_list` has been changed
#         """        
#         # Initialize the dictionary with an empty list for each item
#         self.hist_dict = {}
#         for attr in self.hist_list:
#             self.hist_dict[attr] = []
#             
#             
#     def save_hist(self):
#         """
#         Save the items in the history dictionary
#         
#         For each item :code:`attr` in :code:`self.hist_list`, the method
#         will make a copy of :code:`self.attr` and append it to the list,
#         :code:`self.hist_list['attr']`.  If :code:`self.attr` implements
#         a :code:`copy()` method, it will run that method to perform a deep
#         copy.  Otherwise, it will simply perform a shallow copy.
#         """
#         for attr in self.hist_list:
#             val = getattr(self,attr)
#             if hasattr(val,'copy'):
#                 if callable(val.copy):
#                     val = val.copy()                    
#             self.hist_dict[attr].append(val)


# Path: vampyre/solver/gamp.py
import numpy as np
import time
import vampyre.estim as estim
import vampyre.trans as trans
import vampyre.common as common
from vampyre.solver.base import Solver

# Import other subpackages

# Import methods and classes from the same vampyre sub-package


class Gamp(Solver):
    """
    Gamp solver
    
    The GAMP solver performs estimation on a penalty function of the form:
    
    :code:`f(z) = f0(z0) + f1(z1) s.t. z1=A.dot(z0)`
    
    where :math:`f0(z)` and :math:`f1(z)` are two penalty functions
    
    :param est0:  Estimator corresonding to :math:`f0(z)`
    :param est1:  Estimator corresonding to :math:`f1(z)`
    :param A:  Linear transform
    :param hist_list:  List of attributes to save the history of during the
       course of the iterations.
    :param nit:  Maximum number of iterations          
    :param comp_cost:  Compute cost
    :param prt_period:  Period for printing progress (value of 0 indicates
        no printing)
    :param step_adapt:  Enable adaptive step size
    :param step:  Initial step size
    """
    def __init__(self, est0, est1, A, hist_list=[], nit=10,\
        comp_cost=True, prt_period=0, is_complex=False, map_est=False,\
        step_adapt=False,step=0.95,step_min=1e-6):

        Solver.__init__(self,hist_list)