47 using namespace EpetraExt;
52 const int lineLength = 1025;
53 const int tokenLength = 35;
54 char line[lineLength];
55 char token1[tokenLength];
56 char token2[tokenLength];
57 char token3[tokenLength];
58 char token4[tokenLength];
59 char token5[tokenLength];
64 handle = fopen(filename,
"r");
69 if(fgets(line, lineLength, handle)==0)
return(-1);
70 if(sscanf(line,
"%s %s %s %s %s", token1, token2, token3, token4, token5 )==0)
return(-1);
71 if (strcmp(token1,
"%%MatrixMarket") ||
72 strcmp(token2,
"matrix") ||
73 strcmp(token3,
"array") ||
74 strcmp(token4,
"real") ||
75 strcmp(token5,
"general"))
return(-1);
79 if(fgets(line, lineLength, handle)==0)
return(-1);
80 }
while (line[0] ==
'%');
83 if(sscanf(line,
"%d %d", &M, &N)==0)
return(-1);
89 offset -= numMyPoints;
97 double ** Ap = A->Pointers();
99 for (
int j=0; j<
N; j++) {
103 for (
int i=0; i<offset; i++)
104 if(fgets(line, lineLength, handle)==0)
return(-1);
108 for (
int i=0; i<numMyPoints; i++) {
109 if(fgets(line, lineLength, handle)==0)
return(-1);
110 if(sscanf(line,
"%lg\n", &V)==0)
return(-1);
114 for (
int i=0; i < M-numMyPoints-offset; i++) {
115 if(fgets(line, lineLength, handle)==0)
return(-1);
119 if (fclose(handle))
return(-1);
int MatrixMarketFileToMultiVector(const char *filename, const Epetra_BlockMap &map, Epetra_MultiVector *&A)
Constructs an Epetra_MultiVector object from a Matrix Market format file.
#define EPETRA_CHK_ERR(a)
const Epetra_Comm & Comm() const
virtual int ScanSum(double *MyVals, double *ScanSums, int Count) const =0