Python scipy.sparse.linalg.factorized() Examples
The following are 7
code examples of scipy.sparse.linalg.factorized().
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: qcqp.py From qcqp with MIT License | 5 votes |
def admm_phase2(x0, prob, rho, tol=1e-2, num_iters=1000, viol_lim=1e4): logging.info("Starting ADMM phase 2 with rho %.3f", rho) bestx = np.copy(x0) z = np.copy(x0) xs = [np.copy(x0) for i in range(prob.m)] us = [np.zeros(prob.n) for i in range(prob.m)] if prob.rho != rho: prob.rho = rho zlhs = 2*(prob.f0.P + rho*prob.m*sp.identity(prob.n)).tocsc() prob.z_solver = SLA.factorized(zlhs) last_z = None for t in range(num_iters): rhs = 2*rho*(sum(xs)-sum(us)) - prob.f0.qarray z = prob.z_solver(rhs) # TODO: parallel x/u-updates for i in range(prob.m): xs[i] = onecons_qcqp(z + us[i], prob.fi(i)) for i in range(prob.m): us[i] += z - xs[i] # TODO: termination condition if last_z is not None and LA.norm(last_z - z) < tol: break last_z = z maxviol = max(prob.violations(z)) logging.info("Iteration %d, violation %.3f", t, maxviol) if maxviol > viol_lim: break bestx = np.copy(prob.better(z, bestx)) return bestx
Example #2
Source File: multigrid.py From freegs with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, A): self.solve = factorized(A.tocsc()) # LU decompose
Example #3
Source File: test_scipy_aliases.py From PyPardisoProject with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_basic_factorized(): ps.remove_stored_factorization() ps.free_memory() A, b = create_test_A_b_rand() ppfact = factorized(A) xpp = ppfact(b) scipyfact = scipyfactorized(A) xscipy = scipyfact(b) np.testing.assert_array_almost_equal(xpp, xscipy)
Example #4
Source File: flow_matrix.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def init_solver(self,L): from scipy.sparse import linalg self.lusolve = linalg.factorized(self.L1.tocsc())
Example #5
Source File: linalg.py From compas with MIT License | 5 votes |
def _lufactorized(A): r"""Return a function for solving a sparse linear system (LU decomposition). Parameters ---------- A : array Matrix A represented as an (m x n) array. Returns ------- callable Function to solve linear system with input matrix (n x 1). Notes ----- LU decomposition factors a matrix as the product of a lower triangular and an upper triangular matrix L and U. .. math:: \mathbf{A} = \mathbf{L} \mathbf{U} Examples -------- >>> fn = _lufactorized(array([[3, 2, -1], [2, -2, 4], [-1, 0.5, -1]])) >>> fn(array([1, -2, 0])) array([ 1., -2., -2.]) """ return factorized(A)
Example #6
Source File: flow_matrix.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_solver(self, L): from scipy.sparse import linalg self.lusolve = linalg.factorized(self.L1.tocsc())
Example #7
Source File: flow_matrix.py From aws-kube-codesuite with Apache License 2.0 | 5 votes |
def init_solver(self, L): from scipy.sparse import linalg self.lusolve = linalg.factorized(self.L1.tocsc())