68882077fc47d554bfb5284949c52cc871ca8903 kent Sat Dec 18 09:50:50 2021 -0800 Added special case for zero during printing out of matrix cause it's so common and fprintf(f, %g, 0.0) is rather slower than fputs(0, f); diff --git src/utils/matrixNormalize/matrixNormalize.c src/utils/matrixNormalize/matrixNormalize.c index 410dbdd..1bc9c6a 100644 --- src/utils/matrixNormalize/matrixNormalize.c +++ src/utils/matrixNormalize/matrixNormalize.c @@ -88,31 +88,37 @@ /* Print label row */ fprintf(f, "%s", m->centerLabel); int x, xSize = m->xSize; for (x=0; x<xSize; ++x) fprintf(f, "\t%s", m->xLabels[x]); fprintf(f, "\n"); /* Print rest */ /* Now output going through row by row */ int y, ySize = m->ySize; for (y=0; y<ySize; ++y) { fprintf(f, "%s", m->yLabels[y]); double *row = m->rows[y]; for (x=0; x<xSize; ++x) + { + double val = row[x]; + if (val == 0.0) + fputs("\t0", f); // Common special case in these sparse matrices + else fprintf(f, "\t%g", row[x]); + } fprintf(f, "\n"); } carefulClose(&f); } void matrixNormalizeColumns(char *inFile, boolean isLength, double target, char *outFile) /* Normalize matrix one row at a time. */ { /* Open up input file */ struct memMatrix *m = memMatrixFromTsv(inFile); /* Go through matrix by column (y-dimension) */ int xSize = m->xSize, ySize = m->ySize; int x,y; for (x=0; x<xSize; ++x)