[petsc-users] Yet another inversion question
Barry Smith
bsmith at mcs.anl.gov
Sat May 1 15:44:50 CDT 2010
Umut,
You do not want to use MatGetColumnVector() on a sparse matrix it
is very slow.
Follow the directions at http://www.mcs.anl.gov/petsc/petsc-as/documentation/faq.html#invertmatrix
in your case don't use the identity for B but use your B as a dense
matrix.
For applying many rows, a direct solver will always win over
using an iterative solver for each column.
Barry
On May 1, 2010, at 3:27 PM, Umut Tabak wrote:
> Dear all,
>
> I need some terms in my algorithm such as
>
> A^{-1} B
>
> so and inverted matrix multiplied by another one(A and B pretty
> sparse, however inversion makes all the sparsity lost). Explicit
> inverse is not the way to go, however I thought of solving for the
> columns of B thorugh KSP and put them into another matrix as
> columns(which might be expensive as well I am not sure)and
> eventually I will get the term I would like. I know these kinds of
> terms should be avoided if possible but for the moment I can not
> avoid them so what would be the best way to compute this dense
> symmetric resulting matrix.
>
> I did a first try to solve for the columns of B, with the umfpack
> interface and direct solve, which seemed to be fastest on a matrix
> of size 5544( to solve for all the columns of B). About 1m11sec. to
> do the above mentioned solves. I was wondering if there some more
> efficient ways to make this operation faster than what I could
> accomplish now. Otherwise I should leave this way of thinking.
> Sth like,
>
> for(PetscInt indx=0; indx<c; indx++)
> {
> //cout << "Column : " << indx << endl;
> // retrieve column
> MatGetColumnVector(Mss, u, indx);
> /* Solve linear system
> */
> ierr = KSPSolve(ksp,u,x);CHKERRQ(ierr);
> }
>
> Best regards,
> Umut
>
>
>
>
>
More information about the petsc-users
mailing list