f1eb91ba57a988ea0919c1ecebc45d3f926fc6c1 kent Mon Jan 11 14:58:50 2021 -0800 Adding 'centerLabel' to data structure. In TSV representation this is the first word in the file, in the upper left, where it could be constued to label first column or first row. diff --git src/inc/vMatrix.h src/inc/vMatrix.h index 6f77990..cea0189 100644 --- src/inc/vMatrix.h +++ src/inc/vMatrix.h @@ -8,57 +8,59 @@ * char *label; * double *row; * while ((row = vRowMatrixNextRow(v, &label)) * { * // do your processing * } * vRowMatrixClose(&v); */ struct vRowMatrix /* A virtual matrix optimized for row-at-a-time access */ { struct vRowMatrix *next; int xSize; /* Dimensions */ int y; /* Current Y position */ + char *centerLabel; /* Label to put in corner between row and column labels */ char **columnLabels; /* xSize of these */ double *(*nextRow)(struct vRowMatrix *matrix, char **retLabel); /* Fetch next row of data, NULL at end */ void (*free)(struct vRowMatrix *matrix); /* Free up any associated data */ void *vData; /* Type dependent pointer */ }; struct vRowMatrix *vRowMatrixOnTsv(char *fileName); /* Return a vRowMatrix on a tsv file with first column and row as labels */ double *vRowMatrixNextRow(struct vRowMatrix *v, char **retLabel); /* Return next row or NULL at end */ void vRowMatrixFree(struct vRowMatrix **pv); /* Free up vRowMatrix (and call it's free method) */ -struct vRowMatrix *vRowMatrixNewEmpty(int xSize, char **columnLabels); +struct vRowMatrix *vRowMatrixNewEmpty(int xSize, char **columnLabels, char *centerLabel); /* Allocate vRowMatrix but without methods or data filled in. Typically used by a factory/wrapper method * such as vRowMatrixOnTsv*/ void vMatrixSaveAsTsv(struct vRowMatrix *matrix, char **columnLabels, char **rowLabels, char *fileName); /* Save sparseRowMatrix to tab-sep-file as expanded non-sparse */ /* Big old memory unpacked in memory matrices - a useful thing sometimes. */ struct memMatrix /* Unpacked representation in memory */ { struct memMatrix *next; int xSize, ySize; /* Dimensions */ - double **rows; /* There are y items here */ + double **rows; /* There are xSize items in each of ySize rows */ char **xLabels, **yLabels; /* Arrays of labels */ + char *centerLabel; /* Label to put in corner between row and column labels */ struct lm *lm; }; void memMatrixFree(struct memMatrix **pMatrix); /* Free up memory matrix */ struct memMatrix *memMatrixFromTsv(char *fileName); /* Return a memMatrix based on file */ #endif /* VMATRIX_H */