本文整理汇总了Python中suitesparse.umfpack.umfpack_solver.UmfpackSolver.get_LU方法的典型用法代码示例。如果您正苦于以下问题:Python UmfpackSolver.get_LU方法的具体用法?Python UmfpackSolver.get_LU怎么用?Python UmfpackSolver.get_LU使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类suitesparse.umfpack.umfpack_solver.UmfpackSolver
的用法示例。
在下文中一共展示了UmfpackSolver.get_LU方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CySparseUmfpackget_LUWithSymmetrySWithZero_CSRSparseMatrix_INT32_t_COMPLEX128_t_TestCase
# 需要导入模块: from suitesparse.umfpack.umfpack_solver import UmfpackSolver [as 别名]
# 或者: from suitesparse.umfpack.umfpack_solver.UmfpackSolver import get_LU [as 别名]
class CySparseUmfpackget_LUWithSymmetrySWithZero_CSRSparseMatrix_INT32_t_COMPLEX128_t_TestCase(unittest.TestCase):
def setUp(self):
self.size = SIZE
self.A = LinearFillLLSparseMatrix(
size=self.size, dtype=COMPLEX128_T, itype=INT32_T, store_symmetry=True, store_zero=True
)
self.C = self.A.to_csr()
self.solver = UmfpackSolver(self.C)
def test_factorization_element_by_element(self):
"""
Verify the equality ``L * U = P * R * A * Q``
"""
(L, U, P, Q, D, do_recip, R) = self.solver.get_LU()
lhs = L * U
P_mat = PermutationLLSparseMatrix(P=P, size=SIZE, dtype=COMPLEX128_T, itype=INT32_T)
Q_mat = PermutationLLSparseMatrix(P=Q, size=SIZE, dtype=COMPLEX128_T, itype=INT32_T)
R_mat = None
if do_recip:
R_mat = LLSparseMatrix(size=SIZE, dtype=COMPLEX128_T, itype=INT32_T)
for i in xrange(SIZE):
R_mat[i, i] = R[i]
else:
R_mat = LLSparseMatrix(size=size, dtype=COMPLEX128_T, itype=INT32_T)
for i in xrange(SIZE):
R_mat[i, i] = 1 / R[i]
rhs = P_mat * R_mat * self.C * Q_mat
for i in xrange(SIZE):
for j in xrange(SIZE):
self.assertTrue(
abs(lhs[i, j] - rhs[i, j]) < EPS,
"lhs[%d, %d] =? %f + %f j , rhs[%d, %d] = %f + %f j"
% (i, j, lhs[i, j].real, lhs[i, j].imag, i, j, rhs[i, j].real, rhs[i, j].imag),
)
开发者ID:PythonOptimizers,项目名称:SuiteSparse.py,代码行数:46,代码来源:test_umfpack_get_LU_cysparse_INT32_t_COMPLEX128_t_CSRSparseMatrix.py
示例2: CySparseUmfpackget_LUNoSymmetryNoZero_CSCSparseMatrix_INT32_t_FLOAT64_t_TestCase
# 需要导入模块: from suitesparse.umfpack.umfpack_solver import UmfpackSolver [as 别名]
# 或者: from suitesparse.umfpack.umfpack_solver.UmfpackSolver import get_LU [as 别名]
class CySparseUmfpackget_LUNoSymmetryNoZero_CSCSparseMatrix_INT32_t_FLOAT64_t_TestCase(unittest.TestCase):
def setUp(self):
self.A = LinearFillLLSparseMatrix(size=SIZE, dtype=FLOAT64_T, itype=INT32_T)
self.C = self.A.to_csc()
self.solver = UmfpackSolver(self.C)
def test_factorization_element_by_element(self):
"""
Verify the equality ``L * U = P * R * A * Q``
"""
(L, U, P, Q, D, do_recip, R) = self.solver.get_LU()
lhs = L * U
P_mat = PermutationLLSparseMatrix(P=P, size=SIZE, dtype=FLOAT64_T, itype=INT32_T)
Q_mat = PermutationLLSparseMatrix(P=Q, size=SIZE, dtype=FLOAT64_T, itype=INT32_T)
R_mat = None
if do_recip:
R_mat = LLSparseMatrix(size=SIZE, dtype=FLOAT64_T, itype=INT32_T)
for i in xrange(SIZE):
R_mat[i, i] = R[i]
else:
R_mat = LLSparseMatrix(size=size, dtype=FLOAT64_T, itype=INT32_T)
for i in xrange(SIZE):
R_mat[i, i] = 1/R[i]
rhs = P_mat * R_mat * self.C * Q_mat
for i in xrange(SIZE):
for j in xrange(SIZE):
self.assertTrue(lhs[i, j] - rhs[i, j] < EPS, "lhs[%d, %d] =? %f , rhs[%d, %d] = %f" % (i,j, lhs[i, j], i, j, rhs[i, j]))
开发者ID:PythonOptimizers,项目名称:SuiteSparse.py,代码行数:42,代码来源:test_umfpack_get_LU_cysparse_INT32_t_FLOAT64_t_CSCSparseMatrix.py