# Pymanopt is licensed under the BSD 3-Clause "New" or "Revised" License
# Online license link: https://github.com/pymanopt/pymanopt/blob/master/LICENSE

from __future__ import print_function, division

import time
from copy import deepcopy

import numpy as np

from pymanopt.solvers.linesearch import LineSearchAdaptive
from pymanopt.solvers.solver import Solver
from pymanopt import tools

BetaTypes = tools.make_enum(
    "BetaTypes",
    "FletcherReeves PolakRibiere HestenesStiefel HagerZhang".split())


class ConjugateGradientMS(Solver):
    """
    Module containing conjugate gradient algorithm based on
    conjugategradient.m from the manopt MATLAB package.
    """
    def __init__(self,
                 beta_type=BetaTypes.HestenesStiefel,
                 orth_value=np.inf,
                 linesearch=None,
                 *args,
                 **kwargs):
        """Instantiate gradient solver class.
from __future__ import print_function, division

import time
from copy import deepcopy

import numpy as np

from pymanopt.solvers.linesearch import LineSearchAdaptive
from pymanopt.solvers.solver import Solver
from pymanopt import tools


BetaTypes = tools.make_enum("BetaTypes", "FletcherReeves PolakRibiere HestenesStiefel HagerZhang".split())


class ConjugateGradient(Solver):
    """
    Module containing conjugate gradient algorithm based on
    conjugategradient.m from the manopt MATLAB package.
    """

    def __init__(self, beta_type=BetaTypes.HestenesStiefel, orth_value=np.inf, linesearch=None, *args, **kwargs):
        """
        Instantiate gradient solver class.
        Variable attributes (defaults in brackets):
            - beta_type (BetaTypes.HestenesStiefel)
                Conjugate gradient beta rule used to construct the new search
                direction
            - orth_value (numpy.inf)
                Parameter for Powell's restart strategy. An infinite
                value disables this strategy. See in code formula for
import time
from copy import deepcopy

import numpy as np

from pymanopt import tools
from pymanopt.solvers.solver import Solver

# BetaTypes of the conjugate gradient method in pymanopt was changed.
BetaTypes = tools.make_enum("BetaTypes",
                            "FR DY PR HS HZ Hybrid1 Hybrid2".split())


class ConjugateGradient(Solver):
    """
    Module containing conjugate gradient algorithm based on
    conjugategradient.m from the manopt MATLAB package.
    """
    def __init__(self,
                 beta_type=BetaTypes.DY,
                 orth_value=np.inf,
                 linesearch=None,
                 *args,
                 **kwargs):
        """
        Instantiate gradient solver class.
        Variable attributes (defaults in brackets):
            - beta_type (BetaTypes.HestenesStiefel)
                Conjugate gradient beta rule used to construct the new search
                direction
            - orth_value (numpy.inf)
import time
from copy import deepcopy

import numpy as np

from pymanopt import tools
from pymanopt.solvers.solver import Solver

# BetaTypes of the conjugate gradient method in pymanopt was changed.
BetaTypes = tools.make_enum("BetaTypes",
                            "DaiYuan PolakRibiere Hybrid1 Hybrid2".split())


class ConjugateGradient(Solver):
    """
    Module containing conjugate gradient algorithm based on
    conjugategradient.m from the manopt MATLAB package.
    """
    def __init__(self,
                 beta_type=BetaTypes.DaiYuan,
                 orth_value=np.inf,
                 linesearch=None,
                 *args,
                 **kwargs):
        """
        Instantiate gradient solver class.
        Variable attributes (defaults in brackets):
            - beta_type (BetaTypes.HestenesStiefel)
                Conjugate gradient beta rule used to construct the new search
                direction
            - orth_value (numpy.inf)