#include "mmio.h"
-int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_,
- int *nz_, double **val_, int **I_, int **J_)
-{
- FILE *f;
- MM_typecode matcode;
- int M, N, nz;
- int i;
- double *val;
- int *I, *J;
-
- if ((f = fopen(fname, "r")) == NULL)
- return -1;
-
-
- if (mm_read_banner(f, &matcode) != 0) {
- fprintf(stderr,
- "mm_read_unsymetric: Could not process Matrix Market banner ");
- fprintf(stderr, " in file [%s]\n", fname);
- return -1;
- }
-
-
-
- if (!(mm_is_real(matcode) && mm_is_matrix(matcode) &&
- mm_is_sparse(matcode))) {
- fprintf(stderr, "Sorry, this application does not support ");
- fprintf(stderr, "Market Market type: [%s]\n",
- mm_typecode_to_str(matcode));
- return -1;
- }
-
- /* find out size of sparse matrix: M, N, nz .... */
-
- if (mm_read_mtx_crd_size(f, &M, &N, &nz) != 0) {
- fprintf(stderr,
- "read_unsymmetric_sparse(): could not parse matrix size.\n");
- return -1;
- }
-
- *M_ = M;
- *N_ = N;
- *nz_ = nz;
-
- /* reseve memory for matrices */
-
- I = malloc(nz * sizeof(int));
- J = malloc(nz * sizeof(int));
- val = malloc(nz * sizeof(double));
-
- *val_ = val;
- *I_ = I;
- *J_ = J;
-
- /* NOTE: when reading in doubles, ANSI C requires the use of the "l" */
- /* specifier as in "%lg", "%lf", "%le", otherwise errors will occur */
- /* (ANSI C X3.159-1989, Sec. 4.9.6.2, p. 136 lines 13-15) */
-
- for (i = 0; i < nz; i++) {
- int num = fscanf(f, "%d %d %lg\n", &I[i], &J[i], &val[i]);
- (void)num;
- assert(num == 3);
- I[i]--; /* adjust from 1-based to 0-based */
- J[i]--;
- }
- fclose(f);
-
- return 0;
-}
-
int mm_is_valid(MM_typecode matcode)
{
if (!mm_is_matrix(matcode))
double val[], MM_typecode matcode);
int mm_read_mtx_crd_entry(FILE * f, int *I, int *J, double *realpart,
double *img, MM_typecode matcode);
-
-int mm_read_unsymmetric_sparse(const char *fname, int *M_, int *N_,
- int *nz_, double **val_, int **I_,
- int **J_);