Hi,<br><br>I have a text file containing the non-zero entries of a sparse matrix of dimension 2683x1274, stored in the form (row, column, element) i.e. [i, j, element] format. <br><br>That is ALL the information I have regarding the matrix. <br>
<br>However when pre-allocating memory with  MatSeqAIJSetPreallocation(Mat B,PetscInt nz,const PetscInt nnz[]),  the parameters nz and nnz need to be known,<br><br>nz=number of nonzeros per row (same for all rows)
<br>nnz=array containing the number of nonzeros in the various rows 
(possibly different for each row) or <a href="http://www.mcs.anl.gov/petsc/petsc-2/snapshots/petsc-dev/docs/manualpages/Sys/PETSC_NULL.html#PETSC_NULL">PETSC_NULL</a><br><br>which i do not know for my matrix, ( unless I resort to using MATLAB. ). <br>
<br>Does that mean I have to set nz= 1274 (the length of a row) and nnz=PETSC_NULL ?  Though,  I guess this setting would consume a lot of memory for higher order matrices. <br><br>How then, should I go about memory pre-allocation more efficiently?<br>
<br>Thanks,<br>Gaurish Telang<br><br><br><br> <br><br> <br><br><br><br>There is a code in the PETSc folder (/src/mat/examples/tests/ex78.c ) which reads in a matrix of this format. <br><br><br><br><br>