From: Roy Stogner <roystgnr@ic...>  20060630 19:08:43

On Fri, 30 Jun 2006, David Knezevic wrote: > I've precomputed some (SparseMatrix<Number>) matrices that I can > reuse repeatedly in my computation, and I'd also like to be able to > compute the inverse of these matrices. I couldn't see any libMesh > functionality for computing matrix inverses, but I just wanted to > check I didn't overlook something. No, you didn't miss it, it's not there. The inverse of a sparse matrix is usually a dense matrix, and so you rarely want to compute it explicitly unless you're doing far more linear solves than you have matrix rows. You can trick PETSc into doing the equivalent of a matrix inverse by using pc_type lu, but you'll have to dig into the PETSc interface code to figure out how to get it to save that preconditioner between solves. > If there isn't anything in libMesh, would there be an easy way to do > this (perhaps using PETSc functionality)? > > Also, if I can compute these inverses, I'd then need to do a > SparseMatrix multiplication with a NumericVector. Again, I didn't see > multiplication defined anywhere, just wondering if multiplication is > already available or if I'd have to implement it myself? You're planning to multiply a matrix inverse by a vector  are you sure you don't just want to do a linear solve using that matrix and vector? You'll probably get better performance with a few ILU steps (saved between solves) and a few Krylov steps per solve, instead of one big Gaussian elimination. There is a NumericVector::add_vector() method that does U += A*V with a SparseMatrix A, though.  Roy 