[petsc-users] Creating SBAIJ matrix using 1-based csr arrays ia, ja and acsr

Kirill Voronin kvoronin at labchem.sscc.ru
Tue Nov 25 09:07:34 CST 2014


Hello!

I am trying to create a matrix for solving Ax = b with PETSC with given
1-based(!) indexed ia, ja and acsr arrays for a symmetric (only upper part
is stored) complex matrix.

Without memory preallocation it takes too long to fill in all the values
of acsr into my Mat A object.

But I failed to call
ierr = MatSeqSBAIJSetPreallocationCSR(Afromcsr, dim, iaHSS, jaHSS, acHSS);
because of the 1 based indexing. And I didn't find an option how to handle
this issue.

>From the manual:
"By default the internal data representation for the AIJ formats employs
zero-based indexing. For compatibility
with standard Fortran storage, thus enabling use of external Fortran
software packages such as
SPARSKIT, the option -mat_aij_oneindex enables one-based indexing, where
the stored row and
column indices begin at one, not zero. All user calls to PETSc routines,
regardless of this option, use
zero-based indexing."

So, what can you recommend to do? I obviously don't want to double the
memory for storing ia and ja arrays in 0-based indexing. I don't want to
change the indexing everywhere to 0-based since I use a piece of external
code which works only for 1-based indexing as a preconditioner in PETSC
KSP solver.

Thanks in advance!

With best regards,

Kirill Voronin





More information about the petsc-users mailing list