I want to find some kinds of matrices for testing my code such as GMRES , MINRES and so on. But I can't find some testing matrices and corresponding preconditioner to verify my program.
I think there’s some confusion here. There’s no matrix and corresponding preconditioner. The latter are usually derived mechanically on the fly as the iterative scheme evolves unless you already have the matrix inverse, which would be the perfect preconditioner as you’d just apply the inverse and the iterative method would converge on its first step. The matrix may also be created from, say, timestep to timestep, and change as the code evolves. So, it may never be stored in a complete form either, just computed as needed.
In lots of methods where we have a step showing that we need the inverse of a matrix applied to an object, we often do not have the matrix fully formed, and so will never fully form it nor its inverse. We simply need to perform their actions on arbitrary vectors. As a result, the preconditioner will probably never be fully constructed in most production programs since, for big problems, the pieces of your matrix are scattered all over the memory of a large parallel computer.
But don’t despair, there are libraries, as mentioned in other answers and comments that handle these issues, so you “just” have to adapt your code to their manner of representing matrices and vectors.
Generally, preconditioners are considered to be part of the solver, so they are not included in test matrix collections. In fact, preconditioners are rarely constructed as an explicit matrix, making it hard to include them in a programming-language-agnostic manner.
If you're using an existing sparse linear algebra framework or a language like MATLAB or Julia, there should be plenty of preconditioners already implemented. Otherwise, there are a number that are easy to implement.
- The identity matrix - doesn't help convergence, but trivial to implement and helpful for checking correctness
- A scaler Jacobi preconditioner - just the matrix diagonal
- A block Jacobi preconditioner - diagonal blocks of the matrix (requires solving small linear systems at each step)
- Incomplete LU/Cholesky - A bit more involved, but still relatively straightforward to implement in it's most basic form.
As a final side note, I think the SuiteSparse collection has all of the matrices from MatrixMarket plus many more.