20 gk_csr_t * constraint = gk_csr_Read(file, GK_CSR_FMT_CSR, 1, 1);
25 constraint->colptr = constraint->rowptr;
26 constraint->colind = constraint->rowind;
27 constraint->colval = constraint->rowval;
28 int tmp_ncols = constraint->ncols;
29 constraint->ncols = constraint->nrows;
30 constraint->rowptr = NULL;
31 constraint->rowind = NULL;
32 constraint->rowval = NULL;
33 constraint->nrows = tmp_ncols;
34 gk_csr_CreateIndex(constraint, GK_CSR_ROW);
37 gk_csr_CreateIndex(constraint, GK_CSR_COL);
49 void csr_Write(gk_csr_t *mat,
char *filename,
char * mode,
50 int format,
int writevals,
int numbering) {
56 fpout = gk_fopen(filename, mode,
"gk_csr_Write: fpout");
60 if (format == GK_CSR_FMT_CLUTO) {
61 fprintf(fpout,
"%d %d %d\n", mat->nrows, mat->ncols, mat->rowptr[mat->nrows]);
66 for (i=0; i<mat->nrows; i++) {
67 for (j=mat->rowptr[i]; j<mat->rowptr[i+1]; j++) {
68 fprintf(fpout,
" %d", mat->rowind[j]+(numbering ? 1 : 0));
70 fprintf(fpout,
" %.5f", mat->rowval[j]);