MCPcopy Create free account
hub / github.com/clMathLibraries/clSPARSE / MMReadBanner

Method MMReadBanner

src/benchmarks/cusparse-bench/src/mm_reader.cpp:305–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303
304template<typename FloatType>
305int MatrixMarketReader<FloatType>::MMReadBanner( FILE *infile )
306{
307 char line[ MM_MAX_LINE_LENGTH ];
308 char banner[ MM_MAX_TOKEN_LENGTH ];
309 char mtx[ MM_MAX_TOKEN_LENGTH ];
310 char crd[ MM_MAX_TOKEN_LENGTH ];
311 char data_type[ MM_MAX_TOKEN_LENGTH ];
312 char storage_scheme[ MM_MAX_TOKEN_LENGTH ];
313 char *p;
314
315 mm_clear_typecode( Typecode );
316
317 if( fgets( line, MM_MAX_LINE_LENGTH, infile ) == NULL )
318 return MM_PREMATURE_EOF;
319
320 if( sscanf( line, "%s %s %s %s %s", banner, mtx, crd, data_type,
321 storage_scheme ) != 5 )
322 return MM_PREMATURE_EOF;
323
324 for( p = mtx; *p != '\0'; *p = tolower( *p ), p++ ); /* convert to lower case */
325 for( p = crd; *p != '\0'; *p = tolower( *p ), p++ );
326 for( p = data_type; *p != '\0'; *p = tolower( *p ), p++ );
327 for( p = storage_scheme; *p != '\0'; *p = tolower( *p ), p++ );
328
329 /* check for banner */
330 if( strncmp( banner, MatrixMarketBanner, strlen( MatrixMarketBanner ) ) != 0 )
331 return MM_NO_HEADER;
332
333 /* first field should be "mtx" */
334 if( strcmp( mtx, MM_MTX_STR ) != 0 )
335 return MM_UNSUPPORTED_TYPE;
336 mm_set_matrix( Typecode );
337
338 /* second field describes whether this is a sparse matrix (in coordinate
339 storgae) or a dense array */
340 if( strcmp( crd, MM_SPARSE_STR ) == 0 )
341 mm_set_sparse( Typecode );
342 else if( strcmp( crd, MM_DENSE_STR ) == 0 )
343 mm_set_dense( Typecode );
344 else
345 return MM_UNSUPPORTED_TYPE;
346
347
348 /* third field */
349
350 if( strcmp( data_type, MM_REAL_STR ) == 0 )
351 mm_set_real( Typecode );
352 else
353 if( strcmp( data_type, MM_COMPLEX_STR ) == 0 )
354 mm_set_complex( Typecode );
355 else
356 if( strcmp( data_type, MM_PATTERN_STR ) == 0 )
357 mm_set_pattern( Typecode );
358 else
359 if( strcmp( data_type, MM_INT_STR ) == 0 )
360 mm_set_integer( Typecode );
361 else
362 return MM_UNSUPPORTED_TYPE;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected