glphbm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* glphbm.h (Harwell-Boeing sparse matrix format) */
  2. /***********************************************************************
  3. * This code is part of GLPK (GNU Linear Programming Kit).
  4. *
  5. * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
  6. * 2009, 2010 Andrew Makhorin, Department for Applied Informatics,
  7. * Moscow Aviation Institute, Moscow, Russia. All rights reserved.
  8. * E-mail: <mao@gnu.org>.
  9. *
  10. * GLPK is free software: you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * GLPK is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  17. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  18. * License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with GLPK. If not, see <http://www.gnu.org/licenses/>.
  22. ***********************************************************************/
  23. #ifndef GLPHBM_H
  24. #define GLPHBM_H
  25. typedef struct HBM HBM;
  26. struct HBM
  27. { /* sparse matrix in Harwell-Boeing format; for details see the
  28. report: I.S.Duff, R.G.Grimes, J.G.Lewis. User's Guide for the
  29. Harwell-Boeing Sparse Matrix Collection (Release I), 1992 */
  30. char title[72+1];
  31. /* matrix title (informative) */
  32. char key[8+1];
  33. /* matrix key (informative) */
  34. char mxtype[3+1];
  35. /* matrix type:
  36. R.. real matrix
  37. C.. complex matrix
  38. P.. pattern only (no numerical values supplied)
  39. .S. symmetric (lower triangle + main diagonal)
  40. .U. unsymmetric
  41. .H. hermitian (lower triangle + main diagonal)
  42. .Z. skew symmetric (lower triangle only)
  43. .R. rectangular
  44. ..A assembled
  45. ..E elemental (unassembled) */
  46. char rhstyp[3+1];
  47. /* optional types:
  48. F.. right-hand sides in dense format
  49. M.. right-hand sides in same format as matrix
  50. .G. starting vector(s) (guess) is supplied
  51. ..X exact solution vector(s) is supplied */
  52. char ptrfmt[16+1];
  53. /* format for pointers */
  54. char indfmt[16+1];
  55. /* format for row (or variable) indices */
  56. char valfmt[20+1];
  57. /* format for numerical values of coefficient matrix */
  58. char rhsfmt[20+1];
  59. /* format for numerical values of right-hand sides */
  60. int totcrd;
  61. /* total number of cards excluding header */
  62. int ptrcrd;
  63. /* number of cards for ponters */
  64. int indcrd;
  65. /* number of cards for row (or variable) indices */
  66. int valcrd;
  67. /* number of cards for numerical values */
  68. int rhscrd;
  69. /* number of lines for right-hand sides;
  70. including starting guesses and solution vectors if present;
  71. zero indicates no right-hand side data is present */
  72. int nrow;
  73. /* number of rows (or variables) */
  74. int ncol;
  75. /* number of columns (or elements) */
  76. int nnzero;
  77. /* number of row (or variable) indices;
  78. equal to number of entries for assembled matrix */
  79. int neltvl;
  80. /* number of elemental matrix entries;
  81. zero in case of assembled matrix */
  82. int nrhs;
  83. /* number of right-hand sides */
  84. int nrhsix;
  85. /* number of row indices;
  86. ignored in case of unassembled matrix */
  87. int nrhsvl;
  88. /* total number of entries in all right-hand sides */
  89. int nguess;
  90. /* total number of entries in all starting guesses */
  91. int nexact;
  92. /* total number of entries in all solution vectors */
  93. int *colptr; /* alias: eltptr */
  94. /* column pointers (in case of assembled matrix);
  95. elemental matrix pointers (in case of unassembled matrix) */
  96. int *rowind; /* alias: varind */
  97. /* row indices (in case of assembled matrix);
  98. variable indices (in case of unassembled matrix) */
  99. int *rhsptr;
  100. /* right-hand side pointers */
  101. int *rhsind;
  102. /* right-hand side indices */
  103. double *values;
  104. /* matrix values */
  105. double *rhsval;
  106. /* right-hand side values */
  107. double *sguess;
  108. /* starting guess values */
  109. double *xexact;
  110. /* solution vector values */
  111. };
  112. #define hbm_read_mat _glp_hbm_read_mat
  113. HBM *hbm_read_mat(const char *fname);
  114. /* read sparse matrix in Harwell-Boeing format */
  115. #define hbm_free_mat _glp_hbm_free_mat
  116. void hbm_free_mat(HBM *hbm);
  117. /* free sparse matrix in Harwell-Boeing format */
  118. #endif
  119. /* eof */