def lu_solve_AATI(A, rho, b, lu, piv):
r"""
Solve the linear system :math:`(A A^T + \rho I)\mathbf{x} = \mathbf{b}`
or :math:`(A A^T + \rho I)X = B` using :func:`scipy.linalg.lu_solve`.
Parameters
----------
A : array_like
Matrix :math:`A`
rho : float
Scalar :math:`\rho`
b : array_like
Vector :math:`\mathbf{b}` or matrix :math:`B`
lu : array_like
Matrix containing U in its upper triangle, and L in its lower triangle,
as returned by :func:`scipy.linalg.lu_factor`
piv : array_like
Pivot indices representing the permutation matrix P, as returned by
:func:`scipy.linalg.lu_factor`
Returns
-------
x : ndarray
Solution to the linear system.
"""
N, M = A.shape
if N >= M:
x = (b - linalg.lu_solve((lu, piv), b.dot(A).T).T.dot(A.T)) / rho
else:
x = linalg.lu_solve((lu, piv), b.T).T
return x
评论列表
文章目录