Thanks a lot, without you I would sit for my code until midnight
Von: petsc-users-bounces at mcs.anl.gov [mailto:petsc-users-bounces at mcs.anl.gov] Im Auftrag von Jed Brown Gesendet: Freitag, 20. Mai 2011 13:33 An: PETSc users list Betreff: Re: [petsc-users] creating csr matrix from 3 arrays 2011/5/20 D?rrwang, J?rgen <Juergen.Duerrwang at iosb.fraunhofer.de<mailto:Juergen.Duerrwang at iosb.fraunhofer.de>> MatSetValues(A,n,prow,nz,pcol,pval,INSERT_VALUES); This function inserts logically dense blocks. You would loop over rows: for (row=0; row<n; row++) { PetscInt ncol = prow[row+1] - prow[row]; PetscInt offset = prow[row]; MatSetValues(A,1,&row,ncol,&pcol[offset],&pval[offset],INSERT_VALUES); } You should preallocate if at all possible. If your format is exactly as described here and you want the matrix to use your memory, look at: http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-dev/docs/manualpages/Mat/MatCreateSeqAIJWithArrays.html -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110520/5d9d5880/attachment.htm>
