The numerical data in the Matrix Market file formats can be easily processed
using variants of ** fscanf()** and

Reading a Matrix Market file can be broken into three basic steps:

- use
to process the 1st line of file and identify the matrix type`mm_read_banner()` - use a type-specific function, such as
to skip the optional comments and process the matrix size information`mm_read_mtx_crd_size()` - use a variant of
to read the numerical data, one matrix entry per line`scanf()`

Saving a matrix from an internal data structure to a Matrix Market file is a similar process:

- use
to create the 1st line of the Matrix Market file`mm_write_banner()` - (optional) add '%' delimited comments
- use a type-specific function, such as
to record the matrix size information`mm_write_mtx_crd_size()` - use a variant of
to write the numerical data, one matrix entry per line`printf()`

- examples:
- library routines:

- mm_read_banner()
- mm_read_mtx_crd_size()
- mm_read_mtx_array_size()
- mm_write_banner()
- mm_write_mtx_crd_size()
`mm_write_mtx_array_size()`

mm_read_banner - determine the type of matrix being represented in a Matrix Market file

#include <stdio.h> #include "mmio.h" int mm_read_banner(FILE *f, MM_typecode *t);

and returns the matrix characteristics. File descriptor

- MM_PREMATURE_EOF if all items are not present on first line of file.
- MM_NO_HEADER if the file does not begin with "%%MatrixMarket".
- MM_UNSUPPORTED_TYPE if not recongizable description.

#include <stdio.h> #include "mmio.h" int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz);

- MM_PREMATURE_EOF if an end-of-file is encountered before processing these three values.

#include <stdio.h> #include "mmio.h" int mm_read_mtx_array_size(FILE *f, int *M, int *N);

- MM_PREMATURE_EOF if an end-of-file is encountered before reading M and N.

mm_write_banner - record matrix type information in Matrix Market file

#include <stdio.h> #include "mmio.h" int mm_write_banner(FILE *f, MM_typecode *t);

File descriptor ** f** is defined in "stdio.h" and is assumed
to have been opened for write access. The predefined descriptor

#include <stdio.h> #include "mmio.h" int mm_write_mtx_crd_size(FILE *f, int M, int N, int nz);

#include <stdio.h> #include "mmio.h" int mm_write_mtx_array_size(FILE *f, int M, int N);

#include <stdio.h> #include "mmio.h" int mm_is_matrix(MM_typecode t); int mm_is_sparse(MM_typecode t); int mm_is_coordinate(MM_typecode t); int mm_is_dense(MM_typecode t); int mm_is_array(MM_typecode t); int mm_is_complex(MM_typecode t); int mm_is_real(MM_typecode t); int mm_is_pattern(MM_typecode t); int mm_is_integer(MM_typecode t); int mm_is_symmetric(MM_typecode t); int mm_is_general(MM_typecode t); int mm_is_skew(MM_typecode t); int mm_is_hermitian(MM_typecode t);

#include <stdio.h> #include "mmio.h" int mm_set_matrix(MM_typecode &t); int mm_set_sparse(MM_typecode &t); int mm_set_coordinate(MM_typecode &t); int mm_set_dense(MM_typecode &t); int mm_set_array(MM_typecode &t); int mm_set_complex(MM_typecode &t); int mm_set_real(MM_typecode &t); int mm_set_pattern(MM_typecode &t); int mm_set_integer(MM_typecode &t); int mm_set_symmetric(MM_typecode &t); int mm_set_general(MM_typecode &t); int mm_set_skew(MM_typecode &t); int mm_set_hermitian(MM_typecode &t); int mm_clear_typecode(MM_typecode &t); int mm_initialize_typecode(MM_typecode &t);

mm_initialize_typecode(&t); mm_set_matrix(&t); mm_set_complex(&t); mm_set_coordinate(&t); mm_set_hermitian(&t);

#include <stdio.h> #include "mmio.h" char *mm_typecode_to_str(MM_typecode t);

[ Home ] [ Search ] [ Browse ] [ Resources ]

Last change in this page : *May 2, 2000*.
[
].