void MatrixMarketReader<FloatType>::MMGenerateCOOFromFile( FILE *infile, cl_bool read_explicit_zeroes ) { clsparseIdx_t unsym_actual_nnz = 0; FloatType val; clsparseIdx_t ir, ic; const int exp_zeroes = read_explicit_zeroes; //silence warnings from fscanf (-Wunused-result) clsparseIdx_t rv = 0; for ( clsparseIdx_t i = 0; i < nNZ; i++) { if( mm_is_real( Typecode ) ) { fscanf(infile, "%" SIZET "u", &ir); fscanf(infile, "%" SIZET "u", &ic); if (typeid(FloatType) == typeid(float)) rv = fscanf(infile, "%f\n", (float*)(&val)); else if( typeid( FloatType ) == typeid( double ) ) rv = fscanf( infile, "%lf\n", (double*)( &val ) ); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } else if( mm_is_integer( Typecode ) ) { fscanf(infile, "%" SIZET "u", &ir); fscanf(infile, "%" SIZET "u", &ic); if(typeid(FloatType) == typeid(float)) rv = fscanf(infile, "%f\n", (float*)( &val ) ); else if(typeid(FloatType) == typeid(double)) rv = fscanf(infile, "%lf\n", (double*)( &val ) ); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } else if( mm_is_pattern( Typecode ) ) { rv = fscanf(infile, "%" SIZET "u", &ir); rv = fscanf(infile, "%" SIZET "u", &ic); val = static_cast<FloatType>( MAX_RAND_VAL * ( rand( ) / ( RAND_MAX + 1.0 ) ) ); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } } nNZ = unsym_actual_nnz; }
void MatrixMarketReader<FloatType>::MMGenerateCOOFromFile( FILE *infile ) { int unsym_actual_nnz = 0; FloatType val; int ir, ic; const int exp_zeroes = 0; for( int i = 0; i < nNZ; i++ ) { if( mm_is_real( Typecode ) ) { if( typeid( FloatType ) == typeid( float ) ) fscanf( infile, "%d %d %f\n", &ir, &ic, &val ); else if( typeid( FloatType ) == typeid( double ) ) fscanf( infile, "%d %d %lf\n", &ir, &ic, &val ); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } else if( mm_is_integer( Typecode ) ) { if(typeid(FloatType) == typeid(float)) fscanf(infile, "%d %d %f\n", &ir, &ic, &val); else if(typeid(FloatType) == typeid(double)) fscanf(infile, "%d %d %lf\n", &ir, &ic, &val); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } else if( mm_is_pattern( Typecode ) ) { fscanf( infile, "%d %d", &ir, &ic ); val = static_cast<FloatType>( MAX_RAND_VAL * ( rand( ) / ( RAND_MAX + 1.0 ) ) ); if( exp_zeroes == 0 && val == 0 ) continue; else FillCoordData( Typecode, unsym_coords, unsym_actual_nnz, ir, ic, val ); } } nNZ = unsym_actual_nnz; }