# Test set for linear solvers

Lets assume I have a iterative linear system solver, e. g. this one.

Whats the typical approach on verifying and testing this kind of solvers? Is there a standard test set of linear systems one could use to verify the above BiCGStab-Implementation and if not, how would one create such test data?

• Hi alexz, and welcome to scicomp! You may find what you're looking for in this post: scicomp.stackexchange.com/questions/46/…
– Paul
Sep 5 '14 at 20:34
• I would also try to reproduce the results from the original paper, in this case Sep 14 '14 at 16:09

## 3 Answers

One thing you can do for smoke testing is to take a known solution $x$ (you could generate it randomly or pick something convenient) and a known matrix $A$, and then set $b$ equal to $Ax$, and solve the equation $Ax = b$ to see if you recover your known solution. This method is known as the method of manufactured solutions.

To avoid the influence of convergence issues, you probably want to make sure that $A$ is well-conditioned. One way to manufacture a well-conditioned $A$ would be to select a collection of eigenvalues that are in a bounded interval, and construct the diagonal matrix $\Lambda$ such that the main diagonal consists of those eigenvalues. Then, if you generate an invertible matrix $V$ (also should be well conditioned), $A = V \Lambda V^{-1}$. It's probably best to let $V$ be orthogonal in some of your test cases, in which case $V^{-1} = V^{T}$ and you avoid conditioning issues at the cost of making $A$ symmetric.

By no means will such a procedure substitute for using the matrices in collections like the Matrix Market and the University of Florida sparse matrix collection, but by generating small matrices and using the method of manufactured solutions, you should be able to detect and correct simple errors (say, due to indexing, or faulty logic) without having to run large test cases. It's also a methodology that will generalize to other types of problems (testing ODE solvers, testing PDE solvers, and so on).

Have you looked at the Matrix Market?

http://math.nist.gov/MatrixMarket/

I would try to reproduce the results from the original paper, in this case paper. Matrix market link and the sparse matrix collection link are also good repositories. You could also try to compare the convergence results of the code, with a well-tested implementation such as MATLAB, PETSc, etc.