53 using namespace EpetraExt;
64 const char * matrixName,
65 const char *matrixDescription,
85 handle = fopen(filename,
"w");
94 if (writeHeader==
true) {
98 if (matrixName!=0) fprintf(handle,
"%% \n%% %s\n", matrixName);
99 if (matrixDescription!=0) fprintf(handle,
"%% %s\n%% \n", matrixDescription);
107 if (handle!=0) fclose(handle);
124 long long numchunks = N/chunksize;
125 int rem = N%chunksize;
132 for (
int j=0; j<rem; j++) {
133 long long curGlobalCol = rootDomainMap.
GID64(j);
134 if (domainMap.
MyGID(curGlobalCol)) {
135 int curCol = domainMap.
LID(curGlobalCol);
136 xrem[j][curCol] = 1.0;
148 for (
long long ichunk = 0; ichunk<numchunks; ichunk++) {
149 long long startCol = ichunk*chunksize+rem;
151 for (
int j=0; j<chunksize; j++) {
152 long long curGlobalCol = rootDomainMap.
GID64(startCol+j);
153 if (domainMap.
MyGID(curGlobalCol)){
154 int curCol = domainMap.
LID(curGlobalCol);
162 for (
int j=0; j<chunksize; j++) {
163 long long curGlobalCol = rootDomainMap.
GID64(startCol+j);
164 if (domainMap.
MyGID(curGlobalCol)){
165 int curCol = domainMap.
LID(curGlobalCol);
176 long long numRows = y.GlobalLength64();
177 int numCols = y.NumVectors();
178 long long ioffset = 1 - rootRangeMap.
IndexBase64();
179 long long joffset = 1 - rootDomainMap.
IndexBase64();
180 if (y.Comm().MyPID()!=0) {
185 for (
int j=0; j<numCols; j++) {
186 long long J = rootDomainMap.
GID64(j + startColumn) + joffset;
187 for (
long long i=0; i<numRows; i++) {
188 double val = y[j][i];
190 long long I = rootRangeMap.
GID64(i) + ioffset;
191 fprintf(handle,
"%lld %lld %22.16e\n", I, J, val);
209 long long numchunks = N/chunksize;
210 int rem = N%chunksize;
217 for (
int j=0; j<rem; j++) {
218 long long curGlobalCol = rootDomainMap.
GID64(j);
219 if (domainMap.
MyGID(curGlobalCol)) xrem[j][domainMap.
LID(curGlobalCol)] = 1.0;
222 for (
int j=0; j<rem; j++) {
223 int mylength = yrem.MyLength();
224 for (
int i=0; i<mylength; i++)
225 if (yrem[j][i]!=0.0) lnz++;
232 for (
long long ichunk = 0; ichunk<numchunks; ichunk++) {
233 long long startCol = ichunk*chunksize+rem;
235 for (
int j=0; j<chunksize; j++) {
236 long long curGlobalCol = rootDomainMap.
GID64(startCol+j);
237 if (domainMap.
MyGID(curGlobalCol)) x[j][domainMap.
LID(curGlobalCol)] = 1.0;
240 for (
int j=0; j<chunksize; j++) {
241 int mylength = y.MyLength();
242 for (
int i=0; i<mylength; i++)
243 if (y[j][i]!=0.0) lnz++;
246 for (
int j=0; j<chunksize; j++) {
247 long long curGlobalCol = rootDomainMap.
GID64(startCol+j);
248 if (domainMap.
MyGID(curGlobalCol)) x[j][domainMap.
LID(curGlobalCol)] = 0.0;
#define mm_set_coordinate(typecode)
#define mm_set_real(typecode)
int OperatorToMatrixMarketFile(const char *filename, const Epetra_Operator &A, const char *matrixName, const char *matrixDescription, bool writeHeader)
Writes an Epetra_Operator object to a Matrix Market format file, forming the coefficients by applying...
long long IndexBase64() const
long long NumGlobalElements64() const
#define mm_set_matrix(typecode)
int mm_write_banner(FILE *f, MM_typecode matcode)
#define EPETRA_CHK_ERR(a)
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual int MyPID() const =0
virtual int SumAll(double *PartialSums, double *GlobalSums, int Count) const =0
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
int mm_write_mtx_crd_size(FILE *f, long long M, long long N, long long nz)
long long GID64(int LID) const
virtual const Epetra_Comm & Comm() const =0
static Epetra_Map Create_Root_Map(const Epetra_Map &usermap, int root=0)
int get_nz(const Epetra_Operator &A, long long &nz)
int OperatorToHandle(FILE *handle, const Epetra_Operator &A)
bool MyGID(int GID_in) const
const Epetra_Comm & Comm() const
int OperatorToMatlabFile(const char *filename, const Epetra_Operator &A)
Writes an Epetra_Operator object to a file that is compatible with Matlab.
#define mm_initialize_typecode(typecode)
int writeOperatorStrip(FILE *handle, const Epetra_MultiVector &y, const Epetra_Map &rootDomainMap, const Epetra_Map &rootRangeMap, long long startColumn)