13 _rhsFileName(rhsFileName),
24 int& nNonZeroes,
bool& isSymmetric)
38 if (h2 !=
"MatrixMarket")
41 else if (h1 !=
"%%MatrixMarket")
45 string matrixType(buf);
48 string coordinate(buf);
59 if (matrixType !=
"matrix")
62 if (coordinate !=
"coordinate")
68 if (symm ==
"symmetric")
70 else if (symm !=
"general")
71 throw CException(
"not symmetric or general matrix");
73 fscanf(
_fp,
"%d %d %d", &nRows, &nCols, &nNonZeroes);
79 shared_ptr<LinearSystem>
82 int nRows, nCols, nNonZeroes;
85 readHeader(nRows,nCols,nNonZeroes,isSymmetric);
87 cout <<
" nRow " << nRows <<
" x " << nCols
88 <<
" matrix with " << nNonZeroes <<
" entries "
91 cout <<
"reading sizes" << endl;
100 for(
int nr=0; nr<nNonZeroes; nr++)
104 fscanf(
_fp,
"%d %d %lf",&i,&j,&c);
117 shared_ptr<MatrixType> m(
new MatrixType(*_cm));
126 ls->getX().addArray(rowI,xPtr);
127 ls->getMatrix().addMatrix(rowI,rowI,m);
135 cout <<
"rewinding and reading coeffs" << endl;
139 readHeader(nRows,nCols,nNonZeroes,isSymmetric);
141 for(
int nr=0; nr<nNonZeroes; nr++)
145 fscanf(
_fp,
"%d %d %lf",&i,&j,&c);
150 int pos = _cm->add(i,j);
164 cout <<
"finished reading " << endl;
175 for(
int i=0; i<nRows; i++)
178 fscanf(bFile,
"%lf",&r);
shared_ptr< CRConnectivity > _cm
void readHeader(int &nRows, int &nCols, int &nNonZeroes, bool &isSymmetric)
pair< const Field *, const StorageSite * > ArrayIndex
shared_ptr< LinearSystem > getLS()
MMReader(const string &matrixFileName, const string &rhsFileName)
CRMatrix< double, double, double > MatrixType
const string _rhsFileName
shared_ptr< StorageSite > _site