Ejemplo n.º 1
0
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())
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
 def __init__(self, matrix, solver=None):
     import pybanded
     matrix = pybanded.BandedMatrix.from_sparse(matrix)
     self.QR = pybanded.BandedQR(matrix)
Ejemplo n.º 4
0
 def __init__(self, matrix):
     matrix = pybanded.BandedMatrix.from_sparse(matrix)
     self.QR = pybanded.BandedQR(matrix)