# Path: nlp/tools/norms.py
# def norm1(x):
# def norm2(x):
# def normp(x, p):
# def norm_infty(x):
# def normest(A, tol=1.0e-6, maxits=100):
#         A = np.random.randn(n, m)
#         A = np.random.rand(n, n)
#         A = .5 * (A.T + A)
# 
# Path: nlp/tools/timing.py
# def cputime():
#     """Return the user CPU time since the start of the process."""
#     return resource.getrusage(resource.RUSAGE_SELF)[0]


from pysparse.sparse import spmatrix
    from hsl.solvers.pyma57 import PyMa57Solver as LBLContext
    from hsl.solvers.pyma27 import PyMa27Solver as LBLContext
from nlp.tools import norms
from nlp.tools.timing import cputime
import logging
        return

    def check_accurate(self):
        """Verify constraints consistency and residual accuracy."""
        scale_factor = norms.norm_infty(self.proj.x[:self.n])
        if self.b is not None:
            scale_factor = max(scale_factor, norms.norm_infty(self.b))
        max_res = max(1.0e-6 * scale_factor, self.abstol)
        res = norms.norm_infty(self.proj.residual)
        if res > max_res:
            if self.proj.isFullRank:
                self.log.info(' Large residual. ' +
                              'Factorization likely inaccurate...')
            else:
                self.log.info(' Large residual. ' +
                              'Constraints likely inconsistent...')
        self.log.debug(' accurate to within %8.1e...' % res)
        return

    def find_feasible(self):
        """Obtain `x_feasible` satisfying the constraints.

        `rhs` must have been specified.
        """
        n = self.n
        self.log.debug('Obtaining feasible solution...')
        self.t_feasible = cputime()
        self.rhs[n:] = self.b
        self.proj.solve(self.rhs)
        self.x_feasible = self.proj.x[:n].copy()

# Path: nlp/tools/norms.py
# def norm1(x):
# def norm2(x):
# def normp(x, p):
# def norm_infty(x):
# def normest(A, tol=1.0e-6, maxits=100):
#         A = np.random.randn(n, m)
#         A = np.random.rand(n, n)
#         A = .5 * (A.T + A)
# 
# Path: nlp/tools/timing.py
# def cputime():
#     """Return the user CPU time since the start of the process."""
#     return resource.getrusage(resource.RUSAGE_SELF)[0]


# Path: nlp/optimize/projKrylov.py
from pysparse.sparse import spmatrix
    from hsl.solvers.pyma57 import PyMa57Solver as LBLContext
    from hsl.solvers.pyma27 import PyMa27Solver as LBLContext
from nlp.tools import norms
from nlp.tools.timing import cputime
import logging

        return

    def check_accurate(self):
        """Verify constraints consistency and residual accuracy."""
        scale_factor = norms.norm_infty(self.proj.x[:self.n])
        if self.b is not None:
            scale_factor = max(scale_factor, norms.norm_infty(self.b))
        max_res = max(1.0e-6 * scale_factor, self.abstol)
        res = norms.norm_infty(self.proj.residual)
        if res > max_res:
            if self.proj.isFullRank:
                self.log.info(' Large residual. ' +
                              'Factorization likely inaccurate...')
            else:
                self.log.info(' Large residual. ' +
                              'Constraints likely inconsistent...')
        self.log.debug(' accurate to within %8.1e...' % res)
        return

    def find_feasible(self):
        """Obtain `x_feasible` satisfying the constraints.

        `rhs` must have been specified.
        """
        n = self.n
        self.log.debug('Obtaining feasible solution...')
        self.t_feasible = cputime()
        self.rhs[n:] = self.b
        self.proj.solve(self.rhs)
        self.x_feasible = self.proj.x[:n].copy()

        self.t_feasible = cputime() - self.t_feasible