Python scipy.sparse.linalg.onenormest() Examples
The following are 6
code examples of scipy.sparse.linalg.onenormest().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.sparse.linalg
, or try the search function
.
Example #1
Source File: matrixtools.py From pyGSTi with Apache License 2.0 | 5 votes |
def expop_multiply_prep(op, A_1_norm=None, tol=EXPM_DEFAULT_TOL): """ Returns "prepared" meta-info about operation op, which is assumed to be traceless (so no shift is needed). Used as input for use with _custom_expm_multiply_simple_core or fast C-reps. """ assert(isinstance(op, _spsl.LinearOperator)) if len(op.shape) != 2 or op.shape[0] != op.shape[1]: raise ValueError('expected op to have equal input and output dimensions') # n = op.shape[0] n0 = 1 # always act exp(op) on *single* vectors mu = 0 # _spsl._expm_multiply._trace(A) / float(n) #ASSUME op is *traceless* #FUTURE: get exact_1_norm specific for our ops - now just use approximate if A_1_norm is None: A_1_norm = _spsl.onenormest(op) #t = 1.0 # always, so t*<X> => just <X> below if A_1_norm == 0: m_star, s = 0, 1 else: ell = 2 norm_info = _spsl._expm_multiply.LazyOperatorNormInfo(op, A_1_norm=A_1_norm, ell=ell) m_star, s = _spsl._expm_multiply._fragment_3_1(norm_info, n0, tol, ell=ell) eta = 1.0 # _np.exp(t*mu / float(s)) # b/c mu always == 0 (traceless assumption) return mu, m_star, s, eta
Example #2
Source File: _matfuncs_inv_ssq.py From lambda-packs with MIT License | 5 votes |
def _onenormest_m1_power(A, p, t=2, itmax=5, compute_v=False, compute_w=False): """ Efficiently estimate the 1-norm of (A - I)^p. Parameters ---------- A : ndarray Matrix whose 1-norm of a power is to be computed. p : int Non-negative integer power. t : int, optional A positive parameter controlling the tradeoff between accuracy versus time and memory usage. Larger values take longer and use more memory but give more accurate output. itmax : int, optional Use at most this many iterations. compute_v : bool, optional Request a norm-maximizing linear operator input vector if True. compute_w : bool, optional Request a norm-maximizing linear operator output vector if True. Returns ------- est : float An underestimate of the 1-norm of the sparse matrix. v : ndarray, optional The vector such that ||Av||_1 == est*||v||_1. It can be thought of as an input to the linear operator that gives an output with particularly large norm. w : ndarray, optional The vector Av which has relatively large 1-norm. It can be thought of as an output of the linear operator that is relatively large in norm compared to the input. """ return onenormest(_MatrixM1PowerOperator(A, p), t=t, itmax=itmax, compute_v=compute_v, compute_w=compute_w)
Example #3
Source File: _matfuncs_inv_ssq.py From Computable with MIT License | 5 votes |
def _onenormest_m1_power(A, p, t=2, itmax=5, compute_v=False, compute_w=False): """ Efficiently estimate the 1-norm of (A - I)^p. Parameters ---------- A : ndarray Matrix whose 1-norm of a power is to be computed. p : int Non-negative integer power. t : int, optional A positive parameter controlling the tradeoff between accuracy versus time and memory usage. Larger values take longer and use more memory but give more accurate output. itmax : int, optional Use at most this many iterations. compute_v : bool, optional Request a norm-maximizing linear operator input vector if True. compute_w : bool, optional Request a norm-maximizing linear operator output vector if True. Returns ------- est : float An underestimate of the 1-norm of the sparse matrix. v : ndarray, optional The vector such that ||Av||_1 == est*||v||_1. It can be thought of as an input to the linear operator that gives an output with particularly large norm. w : ndarray, optional The vector Av which has relatively large 1-norm. It can be thought of as an output of the linear operator that is relatively large in norm compared to the input. """ return onenormest(_MatrixM1PowerOperator(A, p), t=t, itmax=itmax, compute_v=compute_v, compute_w=compute_w)
Example #4
Source File: LinearSolver.py From florence with MIT License | 5 votes |
def GetConditionNumber(self,A): self.matrix_condition_number = onenormest(K_b) return self.matrix_condition_number
Example #5
Source File: _matfuncs_inv_ssq.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def _onenormest_m1_power(A, p, t=2, itmax=5, compute_v=False, compute_w=False): """ Efficiently estimate the 1-norm of (A - I)^p. Parameters ---------- A : ndarray Matrix whose 1-norm of a power is to be computed. p : int Non-negative integer power. t : int, optional A positive parameter controlling the tradeoff between accuracy versus time and memory usage. Larger values take longer and use more memory but give more accurate output. itmax : int, optional Use at most this many iterations. compute_v : bool, optional Request a norm-maximizing linear operator input vector if True. compute_w : bool, optional Request a norm-maximizing linear operator output vector if True. Returns ------- est : float An underestimate of the 1-norm of the sparse matrix. v : ndarray, optional The vector such that ||Av||_1 == est*||v||_1. It can be thought of as an input to the linear operator that gives an output with particularly large norm. w : ndarray, optional The vector Av which has relatively large 1-norm. It can be thought of as an output of the linear operator that is relatively large in norm compared to the input. """ return onenormest(_MatrixM1PowerOperator(A, p), t=t, itmax=itmax, compute_v=compute_v, compute_w=compute_w)
Example #6
Source File: _matfuncs_inv_ssq.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
def _onenormest_m1_power(A, p, t=2, itmax=5, compute_v=False, compute_w=False): """ Efficiently estimate the 1-norm of (A - I)^p. Parameters ---------- A : ndarray Matrix whose 1-norm of a power is to be computed. p : int Non-negative integer power. t : int, optional A positive parameter controlling the tradeoff between accuracy versus time and memory usage. Larger values take longer and use more memory but give more accurate output. itmax : int, optional Use at most this many iterations. compute_v : bool, optional Request a norm-maximizing linear operator input vector if True. compute_w : bool, optional Request a norm-maximizing linear operator output vector if True. Returns ------- est : float An underestimate of the 1-norm of the sparse matrix. v : ndarray, optional The vector such that ||Av||_1 == est*||v||_1. It can be thought of as an input to the linear operator that gives an output with particularly large norm. w : ndarray, optional The vector Av which has relatively large 1-norm. It can be thought of as an output of the linear operator that is relatively large in norm compared to the input. """ return onenormest(_MatrixM1PowerOperator(A, p), t=t, itmax=itmax, compute_v=compute_v, compute_w=compute_w)