mmio.h 2.2 KB

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