petsc-3.7.1 2016-05-15
Report Typos and Errors

# 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

    #include "petscmat.h"
    PetscErrorCode MatLoad(Mat newmat,PetscViewer viewer)

Collective on PetscViewer Many br

### Input Parameters

| newmat | - the newly loaded matrix, this needs to have been created with MatCreate() Many bror some related function before a call to MatLoad() Many br
| viewer | - binary file viewer, created with PetscViewerBinaryOpen() Many br

### Options Database Keys

Used with block matrix formats (MATSEQBAIJ, ...) to specify Many brblock size Many br
-matload_block_size <bs> - Many br Many br

### Notes

If the Mat type has not yet been given then MATAIJ is used, call MatSetFromOptions() on the Many brMat before calling this routine if you wish to set it from the options database. Many br

MatLoad() automatically loads into the options database any options Many brgiven in the file filename.info where filename is the name of the file Many brthat was passed to the PetscViewerBinaryOpen(). The options in the info Many brfile will be ignored if you use the -viewer_binary_skip_info option. Many br

If the type or size of newmat is not set before a call to MatLoad, PETSc Many brsets the default matrix type AIJ and sets the local and global sizes. Many brIf type and/or size is already set, then the same are used. Many br

In parallel, each processor can load a subset of rows (or the Many brentire matrix). This routine is especially useful when a large Many brmatrix is stored on disk and only part of it is desired on each Many brprocessor. For example, a parallel solver may access only some of Many brthe rows from each processor. The algorithm used here reads Many brrelatively small blocks of data rather than reading the entire Many brmatrix and then subsetting it. Many br

### Notes for advanced users

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

       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 Many brmachines that store the bytes reversed, e.g. DEC alpha, freebsd, Many brlinux, Windows and the paragon; thus if you write your own binary Many brread/write routines you have to swap the bytes; see PetscBinaryRead() Many brand PetscBinaryWrite() to see how this may be done. Many br

### Keywords

matrix, load, binary, input

### See Also

PetscViewerBinaryOpen(), MatView(), VecLoad()

Level:beginner
Location:src/mat/interface/matrix.c
Index of all Mat routines
Table of Contents for all manual pages
Index of all manual pages

### Examples

src/vec/vec/examples/tutorials/ex6.c.html
src/mat/examples/tutorials/ex1.c.html
src/mat/examples/tutorials/ex4.c.html
src/mat/examples/tutorials/ex9.c.html
src/mat/examples/tutorials/ex10.c.html
src/mat/examples/tutorials/ex12.c.html
src/mat/examples/tutorials/ex16.c.html
src/ksp/ksp/examples/tutorials/ex10.c.html
src/ksp/ksp/examples/tutorials/ex27.c.html
src/ksp/ksp/examples/tutorials/ex41.c.html
src/ksp/ksp/examples/tutorials/ex63.cxx.html