MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / mm_read_mtx_crd_size

Function mm_read_mtx_crd_size

test/mmio/mmio.c:167–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167int mm_read_mtx_crd_size(FILE *f, int *M, int *N, int *nz) {
168 char line[MM_MAX_LINE_LENGTH];
169 int num_items_read;
170
171 /* set return null parameter values, in case we exit with errors */
172 *M = *N = *nz = 0;
173
174 /* now continue scanning until you reach the end-of-comments */
175 do {
176 if (fgets(line, MM_MAX_LINE_LENGTH, f) == NULL) return MM_PREMATURE_EOF;
177 } while (line[0] == '%');
178
179 /* line[] is either blank or has M,N, nz */
180 if (sscanf(line, "%d %d %d", M, N, nz) == 3)
181 return 0;
182
183 else
184 do {
185 num_items_read = fscanf(f, "%d %d %d", M, N, nz);
186 if (num_items_read == EOF) return MM_PREMATURE_EOF;
187 } while (num_items_read != 3);
188
189 return 0;
190}
191
192int mm_read_mtx_array_size(FILE *f, int *M, int *N) {
193 char line[MM_MAX_LINE_LENGTH];

Callers 3

mtxReadSparseMatrixFunction · 0.85
mm_read_mtx_crdFunction · 0.85

Calls

no outgoing calls

Tested by 1

mtxReadSparseMatrixFunction · 0.68