當前位置: 首頁>>代碼示例>>Python>>正文


Python linalg.factorized方法代碼示例

本文整理匯總了Python中scipy.sparse.linalg.factorized方法的典型用法代碼示例。如果您正苦於以下問題:Python linalg.factorized方法的具體用法?Python linalg.factorized怎麽用?Python linalg.factorized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.sparse.linalg的用法示例。


在下文中一共展示了linalg.factorized方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: admm_phase2

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
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 
開發者ID:cvxgrp,項目名稱:qcqp,代碼行數:39,代碼來源:qcqp.py

示例2: __init__

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
def __init__(self, A):
        self.solve = factorized(A.tocsc()) # LU decompose 
開發者ID:bendudson,項目名稱:freegs,代碼行數:4,代碼來源:multigrid.py

示例3: test_basic_factorized

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
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) 
開發者ID:haasad,項目名稱:PyPardisoProject,代碼行數:11,代碼來源:test_scipy_aliases.py

示例4: init_solver

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
def init_solver(self,L):
        from scipy.sparse import linalg
        self.lusolve = linalg.factorized(self.L1.tocsc()) 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:5,代碼來源:flow_matrix.py

示例5: _lufactorized

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
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) 
開發者ID:compas-dev,項目名稱:compas,代碼行數:32,代碼來源:linalg.py

示例6: init_solver

# 需要導入模塊: from scipy.sparse import linalg [as 別名]
# 或者: from scipy.sparse.linalg import factorized [as 別名]
def init_solver(self, L):
        from scipy.sparse import linalg
        self.lusolve = linalg.factorized(self.L1.tocsc()) 
開發者ID:holzschu,項目名稱:Carnets,代碼行數:5,代碼來源:flow_matrix.py


注:本文中的scipy.sparse.linalg.factorized方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。