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

Function clsparseHeaderfromFile

src/library/io/mm-reader.cpp:440–467  ·  view source on GitHub ↗

This function reads the file header at the given filepath, and returns the size of the sparse matrix in the clsparseCooMatrix parameter. Post-condition: clears clsparseCooMatrix, then sets pCooMatx->m, pCooMatx->n pCooMatx->nnz

Source from the content-addressed store, hash-verified

438// Post-condition: clears clsparseCooMatrix, then sets pCooMatx->m, pCooMatx->n
439// pCooMatx->nnz
440clsparseStatus
441clsparseHeaderfromFile( clsparseIdx_t* nnz, clsparseIdx_t* row, clsparseIdx_t* col, const char* filePath )
442{
443
444 // Check that the file format is matrix market; the only format we can read right now
445 // This is not a complete solution, and fails for directories with file names etc...
446 // TODO: Should we use boost filesystem?
447 std::string strPath( filePath );
448 if( strPath.find_last_of( '.' ) != std::string::npos )
449 {
450 std::string ext = strPath.substr( strPath.find_last_of( '.' ) + 1 );
451 if( ext != "mtx" )
452 return clsparseInvalidFileFormat;
453 }
454 else
455 return clsparseInvalidFileFormat;
456
457 MatrixMarketReader< cl_float > mm_reader;
458
459 if( mm_reader.MMReadHeader( filePath ) )
460 return clsparseInvalidFile;
461
462 *row = mm_reader.GetNumRows( );
463 *col = mm_reader.GetNumCols( );
464 *nnz = mm_reader.GetNumNonZeroes( );
465
466 return clsparseSuccess;
467}
468
469// This function reads the file at the given filepath, and returns the sparse
470// matrix in the COO struct. All matrix data is written to device memory

Callers 15

mainFunction · 0.85
mainFunction · 0.85
test_coo_to_csrMethod · 0.85
TESTFunction · 0.85
CSRSparseEnvironmentMethod · 0.85
CSREnvironmentMethod · 0.85
setup_bufferMethod · 0.85
setup_bufferMethod · 0.85
setup_bufferMethod · 0.85
setup_bufferMethod · 0.85
setup_bufferMethod · 0.85
setup_bufferMethod · 0.85

Calls 4

MMReadHeaderMethod · 0.45
GetNumRowsMethod · 0.45
GetNumColsMethod · 0.45
GetNumNonZeroesMethod · 0.45

Tested by 4

test_coo_to_csrMethod · 0.68
TESTFunction · 0.68
CSRSparseEnvironmentMethod · 0.68
CSREnvironmentMethod · 0.68