On Wed, Oct 26, 2022 at 11:00 PM 晓峰 何 <tlanyan@hotmail.com> wrote:
Dear developers,

To avoid zero pivot error in IC/ILU preconditioners,  I plan to permute matrix before solving the linear system. I referred example ex10(https://petsc.org/main/src/ksp/ksp/tutorials/ex10.c.html) and ex18(https://petsc.org/main/src/ksp/ksp/tutorials/ex18.c.html), and was confused that why vector b is permuted by column permutation index set:

// in ex18.c
174:   if (permute) {
175:     Mat Aperm;
176:     MatGetOrdering(A, ordering, &rowperm, &colperm);
177:     MatPermute(A, rowperm, colperm, &Aperm);
178:     VecPermute(b, colperm, PETSC_FALSE);
179:     MatDestroy(&A);
180:     A = Aperm; /* Replace original operator with permuted version */
181:   }
As far as I understand, vector b should be only  affected by permuting rows in matrix A, instead of column permutation. How to understand that permuting vector b with column permutation index set of matrix A?


I get confused by this also. I just test it. Try one and if thats wrong, its the other! 
As I recall a permutation vector has the place where the equation sould _go_

Another question is why  MatReorderForNonzeroDiagonal function only works for type MATSEQAIJ? If it works for other matrix types, then this function will meet my requirement.


It has not been implemented. You could do this, clone the MATSEQAIJ one for the matrix type that you want.
See https://petsc.org/release/developers/contributing/  for instructions on contributing to PETSc.

Thanks,
Mark
 

Thanks,

Xiaofeng