# PCGetFactoredMatrix

Barry Smith bsmith at mcs.anl.gov
Thu Nov 29 14:43:25 CST 2007

```    John,

There is no immediate way to do this.
For the SeqAIJ format, we store both the LU in a single CSR format.
with for each row first the part of L (below the diagonal) then 1/D_i
then the part of U for that row. You can see how the triangular solves
are done by looking at src/mat/impls/aij/seq/aijfact.c the routine
MatSolve_SeqAIJ()
Note that it is actually more complicated due to the row and column
permutations
(the factored matrix is stored in the ordering of the permutations).
For BAIJ matrix the storage is similar except it is stored by block
and the inverse of the block diagonal is stored.

One could take the MatSolve_SeqAIJ() routine and modify it to do the
matrix
vector product without too much difficulty.

If you decide to do this we would gladly include it in our distribution.

Barry

One can ask why we don't provide this functionality in PETSc since
computing
A - LU is a reasonable thing to do if one wants to understand the
convergence
of the method. The answer is two-fold 1) time and energy and 2) though
we
like everyone to use PETSc we driven more by people who are not
interested
in the solution algorithms etc but only in getting the answer easily
and relatively
efficiently.

On Nov 29, 2007, at 12:07 PM, John R. Wicks wrote:

> I would like to compute the residual A - LU, where LU is the ILU
> factorization of A.  What is the most convenient way of doing so?
>
>> -----Original Message-----
>> From: owner-petsc-users at mcs.anl.gov
>> [mailto:owner-petsc-users at mcs.anl.gov] On Behalf Of Matthew Knepley
>> Sent: Thursday, November 29, 2007 12:04 PM
>> To: petsc-users at mcs.anl.gov
>> Subject: Re: PCGetFactoredMatrix
>>
>>
>> It depends on the package, but the petsc stuff stores L and U
>> in one matrix.
>>
>>   Matt
>>
>> On Nov 29, 2007 9:03 AM, John R. Wicks <jwicks at cs.brown.edu> wrote:
>>> The documentation for PCGetFactoredMatrix is not clear.  What does
>>> this return for ILU(0), for example? Does it return the
>> product LU or
>>> the in place factorization?
>>>
>>>
>>
>>
>>
>> --
>> What most experimenters take for granted before they begin
>> their experiments is infinitely more interesting than any
>> results to which their experiments lead.
>> -- Norbert Wiener
>>
>

```