# 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
        if self.precon is not None:
            P[:self.n, :self.n] = self.precon
        else:
            r = range(self.n)
            P.put(1, r, r)
            # for i in range(self.n):
            #    P[i,i] = 1
        P[self.n:, :self.n] = self.A

        # Add regularization if requested.
        if self.dreg > 0.0:
            r = range(self.n, self.n + self.m)
            P.put(-self.dreg, r, r)

        msg = 'Factorizing projection matrix '
        msg += '(size %-d, nnz = %-d)...' % (P.shape[0], P.nnz)
        self.log.debug(msg)
        self.t_fact = cputime()
        self.proj = LBLContext(P)
        self.t_fact = cputime() - self.t_fact
        self.log.debug('... done (%-5.2fs)' % self.t_fact)
        self.factorized = True
        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)

# 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

        if self.precon is not None:
            P[:self.n, :self.n] = self.precon
        else:
            r = range(self.n)
            P.put(1, r, r)
            # for i in range(self.n):
            #    P[i,i] = 1
        P[self.n:, :self.n] = self.A

        # Add regularization if requested.
        if self.dreg > 0.0:
            r = range(self.n, self.n + self.m)
            P.put(-self.dreg, r, r)

        msg = 'Factorizing projection matrix '
        msg += '(size %-d, nnz = %-d)...' % (P.shape[0], P.nnz)
        self.log.debug(msg)
        self.t_fact = cputime()
        self.proj = LBLContext(P)
        self.t_fact = cputime() - self.t_fact
        self.log.debug('... done (%-5.2fs)' % self.t_fact)
        self.factorized = True
        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)