| 1 |
/** |
| 2 |
* @file |
| 3 |
* @brief <a href=https://math.nist.gov/MatrixMarket/>Matrix Market</a> I/O API |
| 4 |
*/ |
| 5 |
|
| 6 |
/************************************************************************* |
| 7 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 8 |
* All rights reserved. This program and the accompanying materials |
| 9 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 10 |
* which accompanies this distribution, and is available at |
| 11 |
* https://www.eclipse.org/legal/epl-v10.html |
| 12 |
* |
| 13 |
* Contributors: Details at https://graphviz.org |
| 14 |
*************************************************************************/ |
| 15 |
/* |
| 16 |
* Matrix Market I/O library for ANSI C |
| 17 |
* |
| 18 |
* See http://math.nist.gov/MatrixMarket for details. |
| 19 |
* |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
#pragma once |
| 24 |
|
| 25 |
#include <stddef.h> |
| 26 |
#include <stdio.h> |
| 27 |
|
| 28 |
#define MM_MAX_LINE_LENGTH 100025 |
| 29 |
#define MatrixMarketBanner "%%MatrixMarket" |
| 30 |
#define MM_MAX_TOKEN_LENGTH 64 |
| 31 |
|
| 32 |
typedef enum { MS_GENERAL, MS_SYMMETRIC, MS_HERMITIAN, MS_SKEW } matrix_shape_t; |
| 33 |
|
| 34 |
typedef struct { |
| 35 |
int type; ///< one of the `MATRIX_TYPE_*` values from lib/sparse |
| 36 |
matrix_shape_t shape; |
| 37 |
} MM_typecode; |
| 38 |
|
| 39 |
int mm_read_banner(FILE * f, MM_typecode * matcode); |
| 40 |
int mm_read_mtx_crd_size(FILE * f, int *M, int *N, size_t *nz); |
| 41 |
|
| 42 |
/********************* Matrix Market error codes ***************************/ |
| 43 |
|
| 44 |
|
| 45 |
#define MM_COULD_NOT_READ_FILE 11 |
| 46 |
#define MM_PREMATURE_EOF 12 |
| 47 |
#define MM_NOT_MTX 13 |
| 48 |
#define MM_NO_HEADER 14 |
| 49 |
#define MM_UNSUPPORTED_TYPE 15 |
| 50 |
#define MM_LINE_TOO_LONG 16 |
| 51 |
|
| 52 |
/******************** Matrix Market internal definitions ******************** |
| 53 |
|
| 54 |
MM_matrix_typecode: 4-character sequence |
| 55 |
|
| 56 |
ojbect sparse/ data storage |
| 57 |
dense type scheme |
| 58 |
|
| 59 |
string position: [0] [1] [2] [3] |
| 60 |
|
| 61 |
Matrix typecode: M(atrix) C(oord) R(eal) G(eneral) |
| 62 |
A(array) C(omplex) H(ermitian) |
| 63 |
P(attern) S(ymmetric) |
| 64 |
I(nteger) K(kew) |
| 65 |
|
| 66 |
***********************************************************************/ |
| 67 |
|
| 68 |
#define MM_MTX_STR "matrix" |
| 69 |
#define MM_COORDINATE_STR "coordinate" |
| 70 |
#define MM_SPARSE_STR "coordinate" |
| 71 |
#define MM_COMPLEX_STR "complex" |
| 72 |
#define MM_REAL_STR "real" |
| 73 |
#define MM_INT_STR "integer" |
| 74 |
#define MM_GENERAL_STR "general" |
| 75 |
#define MM_SYMM_STR "symmetric" |
| 76 |
#define MM_HERM_STR "hermitian" |
| 77 |
#define MM_SKEW_STR "skew-symmetric" |
| 78 |
#define MM_PATTERN_STR "pattern" |