#include "petscmat.h" PetscErrorCode MatLoad(Mat newmat,PetscViewer viewer)Collective on PetscViewer
newmat | - the newly loaded matrix, this needs to have been created with MatCreate() or some related function before a call to MatLoad() | |
viewer | - binary file viewer, created with PetscViewerBinaryOpen() |
MatLoad() automatically loads into the options database any options given in the file filename.info where filename is the name of the file that was passed to the PetscViewerBinaryOpen(). The options in the info file will be ignored if you use the -viewer_binary_skip_info option.
If the type or size of newmat is not set before a call to MatLoad, PETSc sets the default matrix type AIJ and sets the local and global sizes. If type and/or size is already set, then the same are used.
In parallel, each processor can load a subset of rows (or the entire matrix). This routine is especially useful when a large matrix is stored on disk and only part of it is desired on each processor. For example, a parallel solver may access only some of the rows from each processor. The algorithm used here reads relatively small blocks of data rather than reading the entire matrix and then subsetting it.
int MAT_FILE_CLASSID
int number of rows
int number of columns
int total number of nonzeros
int *number nonzeros in each row
int *column indices of all nonzeros (starting index is zero)
PetscScalar *values of all nonzeros
PETSc automatically does the byte swapping for machines that store the bytes reversed, e.g. DEC alpha, freebsd, linux, Windows and the paragon; thus if you write your own binary read/write routines you have to swap the bytes; see PetscBinaryRead() and PetscBinaryWrite() to see how this may be done.