8

I am currently working on a C++-based library for large, sparse linear algebra problems (yes, I know many such libraries exist, but I'm rolling my own mostly to learn about iterative solvers, sparse storage containers, etc..).

I am to the point where I am using my solvers within other programming projects of mine, and would like to test the solvers against problems that are not my own. Primarily, I am looking to test against symmetric sparse systems that are positive definite. I have found several sources for such system matrices such as:

Matrix Market UF Sparse Matrix Collection

That being said, I have not yet found any sources of good test matrices that include the entire system- system matrix and RHS. This would be great to have in order to check results. Any tips on where I can find such full systems, or alternatively, what I might do to generate a "good" RHS for the system matrices I can get online? I am currently just filling a matrix with random values, or all ones, but suspect that this is not necessarily the best way.

MarkD
  • 4,524
  • 2
  • 25
  • 49
  • "many such libraries exist": not really (at least natively written for C++). Writing clean wrappers for fortran libraries dealing with large sparse matrices is already some kind of a challenge to be honest. – Alexandre C. Jul 30 '11 at 12:11
  • However, I recall having seen in some research papers some reference to ill-conditioned test cases, but IIRC they were not for SPD sparse matrices. A simple way to manufacture test cases in your situation is to take a random n x p matrix M, multiply it by its own transpose, and add some lambda * Identity so that it is invertible. But this won't produce sparse matrices. – Alexandre C. Jul 30 '11 at 12:18
  • Also, what's wrong with UF sparse matrix collection ? Taking a few random RHS seems perfectly OK to me. – Alexandre C. Jul 30 '11 at 12:20

3 Answers3

1

I would suggest using a right-hand-side vector obtained from a predefined 'goal' solution x:

b = A*x

Then you have a goal solution, x, and a resulting solution, x, from the solver. This means you can compare the error (difference of the goal and resulting solutions) as well as the residuals (A*x - b).

Note that for careful evaluation of an iterative solver you'll also need to consider what to use for the initial x.

The online collections of matrices primarily contain the left-hand-side matrix, but some do include right-hand-sides and also some have solution vectors too.:

http://www.cise.ufl.edu/research/sparse/matrices/rhs.txt

By the way, for the UF sparse matrix collection I'd suggest this link instead:

http://www.cise.ufl.edu/research/sparse/matrices/

Paul Thompson
  • 540
  • 5
  • 6
0

I haven't used it yet, I'm about to, but GiNAC seems like the best thing I've found for C++. It is the library used behind Maple for CAS, I don't know the performance it has for .

http://www.ginac.de/

norcalli
  • 1,186
  • 2
  • 10
  • 22
0

it would do well to specify which kind of problems are you solving... different problems will require different RHS to be of any use to check validity..... what i'll suggest is get some example code from some projects like DUNE Numerics (i'm working on this right now), FENICS, deal.ii which are already using the solvers to solve matrices... generally they'll have some functionality to output your matrix in some kind of file (DUNE Numerics has functionality to output matrices and RHS in a matlab-compliant files).

This you can then feed to your solvers.. and then again use their the libraries functionality to create output data (like DUNE Numerics uses a VTK format)... That was, you'll get to analyse data using powerful tools.....

you may have to learn a little bit about compiling and using those libraries... but it is not much... and i believe the functionality you'll get would be worth the time invested......

i guess even a single well-defined and reasonably complex problem should be good enough for testing your libraries.... well actually two one for Ax=B problems and another for Ax=cBx (eigenvalue problems) ....