def test_QR_recomposition(I, ImJ, L, U, A_complex): """Test recomposition of QR factorization.""" J = I - ImJ A = random_banded(I, J, L, U, A_complex) A.data += 10 # offset entries to avoid precision issues QR = pybanded.BandedQR(A) A_recomp = QR.Q @ QR.R.toarray() assert np.allclose(A_recomp, A.toarray())
def test_QR_solve(I, L, U, A_complex, x_complex): """Test linear solve by QR factorization.""" J = I A = random_banded(I, J, L, U, A_complex) A.data += 10 # offset entries to avoid precision issues QR = pybanded.BandedQR(A) x = random_vector(J, x_complex) b = A @ x x_solve = QR.solve(b) assert np.allclose(x_solve, x)
def __init__(self, matrix, solver=None): import pybanded matrix = pybanded.BandedMatrix.from_sparse(matrix) self.QR = pybanded.BandedQR(matrix)
def __init__(self, matrix): matrix = pybanded.BandedMatrix.from_sparse(matrix) self.QR = pybanded.BandedQR(matrix)