pyqpanda_alg.QSolver.qsolver

Module Contents

Functions

iter_sparse_mixed_subspace_solver(A, b, maxdim, ...)

The mixed HHL solver is an optimization of the HHL algorithm, which is mainly applied to solve large-scale linear equations, such as computational fluid dynamics.

pyqpanda_alg.QSolver.qsolver.iter_sparse_mixed_subspace_solver(A, b, maxdim, iter_Kyrlov_subspace_pre)

The mixed HHL solver is an optimization of the HHL algorithm, which is mainly applied to solve large-scale linear equations, such as computational fluid dynamics.

Parameters:

\(A\): numpy.array

represents the matrix A of Ax = b

\(b\) : List[float]

represent the b of Ax = b

maxdim : int

represent max dimension of Kyrlov subspace

iter_Kyrlov_subspace_pre: double

represent min iterative residual error

Return:

solution x.

Example:

from pyqpanda_alg.QSolver.qsolver import iter_sparse_mixed_subspace_solver
import numpy as np

if __name__ == '__main__':

        A = np.matrix([[1,0,0,0], [0,2,0,0],[0,0,2,0],[0,0,0,4]])
        b = np.array([1,1,1,1])
        result_x = iter_sparse_mixed_subspace_solver(A, b, 2, 1e-8)
        print(result_x)

The function above would give results:

[0.999998561636645, 0.5000004774207323, 0.5000004774207323, 0.25000004284598887]