I created a binary matrix using the following loop in cchar filename[6];filename=sprintf(filename,file01);moutput=fopen(filename,wb+);for (i=0; i<2*m+1; i++){      for (j=0; j<2*n+1; j++) {            r=rmin+(rmax-rmin)*GetRand(N);            fwrite(&r, sizeof(double), 1, moutput);      }}fclose(moutput);where r is a uniformly distributed pseudorandom double precision number between $rmin$ and $rmax$.  I verified that it wrote the values correctly.So, I am using this tutorial as a guideline to load file01 as a binary matrix.  I ran the following script:  make ex1./ex1 -f0 file01However, it does not seem to work.  I get an error saying:  [0]PETSC ERROR: Unexpected data in file![0]PETSC ERROR: not matrix object in file!Is the problem that I wrote the binary file initially or that I'm using the wrong example to load this particular binary file?
How do I read a binary file into PETSc as a matrix?
petsc;io
Okay, the full format of the binary file is here, and reduces to:int              id:  MAT_FILE_CLASSIDint              nr:  number of rowsint              nc:  number of columnsint              nnz: total number of nonzerosint[nr]          nz:  number nonzeros in each rowint[nnz]         j:   column indices of all nonzeros (starting index is zero)PetscScalar[nnz] a:   values of all nonzerosYou can also use bin/matlab/PetscBinaryWrite.m to write a Matlab matrix to PETSc binary format.