MatLoad

Loads a matrix that has been stored in binary format with MatView(). The matrix format is determined from the options database. Generates a parallel MPI matrix if the communicator has more than one processor. The default matrix type is AIJ.

Synopsis

int MatLoad(Viewer viewer,MatType outtype,Mat *newmat)
Collective on Viewer

Input Parameters

viewer - binary file viewer, created with ViewerFileOpenBinary()
outtype - type of matrix desired, for example MATSEQAIJ, MATMPIROWBS, etc. See types in petsc/include/mat.h.

Output Parameters

newmat -new matrix

Basic Options Database Keys

These options use MatCreateSeqXXX or MatCreateMPIXXX, depending on the communicator, comm.
-mat_aij - AIJ type
-mat_baij - block AIJ type
-mat_dense - dense type
-mat_bdiag - block diagonal type

More Options Database Keys

-mat_seqaij - AIJ type
-mat_mpiaij - parallel AIJ type
-mat_seqbaij - block AIJ type
-mat_mpibaij - parallel block AIJ type
-mat_seqbdiag - block diagonal type
-mat_mpibdiag - parallel block diagonal type
-mat_mpirowbs - parallel rowbs type
-mat_seqdense - dense type
-mat_mpidense - parallel dense type

More Options Database Keys

Used with block matrix formats (MATSEQBAIJ, MATMPIBDIAG, ...) to specifyblock size
-matload_block_size <bs> - Used to specify block diagonal numbers for MATSEQBDIAG and MATMPIBDIAG formats
-matload_bdiag_diags <s1,s2,s3,...> - Notes: 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.

Notes for advanced users

Most users should not need to know the details of the binary storageformat, since MatLoad() and MatView() completely hide these details. But for anyone who's interested, the standard binary matrix storageformat is

   int    MAT_COOKIE
   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)
   Scalar *values of all nonzeros

Note for Cray users, the int's stored in the binary file are 32 bitintegers; not 64 as they are represented in the memory, so if youwrite your own routines to read/write these binary files from the Crayyou need to adjust the integer sizes that you read in, seePetscReadBinary() and PetscWriteBinary() to see how this may bedone.

In addition, PETSc automatically does the byte swapping formachines that store the bytes reversed, e.g. DEC alpha, freebsd, linux, nt and the paragon; thus if you write your own binaryread/write routines you have to swap the bytes; see PetscReadBinary() and PetscWriteBinary() to see how this may be done.

Keywords

matrix, load, binary, input

See Also

ViewerFileOpenBinary(), MatView(), VecLoad(), MatLoadRegister(),
MatLoadRegisterAll()

Examples

src/mat/examples/tutorials/ex1.c
src/sles/examples/tutorials/ex10.c

Location: src/mat/utils/matio.c
Matrix Index
Table of Contents