42 #include "Epetra_Comm.h" 43 #include "Epetra_MultiVector.h" 44 #include "Epetra_Vector.h" 45 #include "Epetra_BlockMap.h" 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);
86 int numMyPoints = map.NumMyPoints();
88 map.Comm().ScanSum(&numMyPoints, &offset, 1);
89 offset -= numMyPoints;
93 A =
new Epetra_Vector(map);
95 A =
new Epetra_MultiVector(map,
N);
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.
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.