Commit 2528910d authored by Alois SCHLOEGL's avatar Alois SCHLOEGL

sparse output format for MatrixMarket coordinate binary added

parent c595e316
......@@ -4,6 +4,15 @@ LIBS = -lgsl -lgslcblas -lgomp
CFLAGS = -Wall ${C_OPTIMIZE_SWITCH} -fopenmp
## Define sparse output format
# SPARSE_MM clear text ascii format
# SPARSE_COO coordinate format, binary
# SPARSE_CSR compressed row storage, most space efficient, default
#CFLAGS += -DSPARSE_MM
#CFLAGS += -DSPARSE_COO
#CFLAGS += -DSPARSE_CSR
run_secorder: run_secorder.o secorder_rec_1p.o calc_sqrtcov_rec_1p.o calc_rhos.o calc_stats_1p.o
${CC} run_secorder.o secorder_rec_1p.o calc_sqrtcov_rec_1p.o calc_rhos.o calc_stats_1p.o -o $@ ${LIBS}
......
......@@ -141,7 +141,7 @@ int main(int argc, char *argv[]) {
cerr << "Couldn't open outfile file " << FN << "\n";
exit(-1);
}
#if 0 //defined(SPARSE_COO)
#if defined(SPARSE_COO)
fwrite("SPARSE\x00\x00",8,1,fhnd);
size_t nr,nc;
nr=nc=N_nodes;
......@@ -158,6 +158,21 @@ int main(int argc, char *argv[]) {
}
}
}
#elif defined(SPARSE_MM) // MatrixMarket format
fprintf(fhnd,"%%MatrixMarket matrix coordinate binary general\n");
fprintf(fhnd,"%%\n%% see also http://math.nist.gov/MatrixMarket/formats.html#MMformat\n%%\n");
size_t nr,nc;
nr=nc=N_nodes;
fprintf(fhnd,"%lu\t%lu\t%lu\n",nr,nc,nnz);
for (int i=0; i<N_nodes; i++) {
for (int j=0; j<N_nodes; j++) {
int t = gsl_matrix_float_get(W,i,j) > 1.0;
gsl_matrix_float_set(W,i,j,(float)t);
if (t) {
fprintf(fhnd,"%lu\t%lu\n",i,j);
}
}
}
#elif 1 //defined(SPARSE_CSR)
fwrite("SPARSE\x00\x02",8,1,fhnd);
size_t nr,nc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment