Your link says that to create a sparse matrix in PETSc you should use the following command:
PETSc.Mat().createAIJ(size=(nrows,ncols), csr=(ai,aj,aa))
According to the this , in PETSc say ai, ajand aa:
> i - row indices
> j - column indices
> a - matrix values
.indptr, .indices .data a scypy.sparse.csr_matrix, . docs .
, , :
>>> from petsc4py import PETSc
>>> import scipy.sparse
>>> csr_mat = scipy.sparse.rand(1000, 1000, density=0.001, format='csr')
>>> petsc_mat = PETSc.Mat().createAIJ(size=csr_mat.shape,
... csr=(csr_mat.indptr, csr_mat.indices,
... csr_mat.data))
, .