EpetraExt Package Browser (Single Doxygen Collection)  Development
test/inout_LL/cxx_main.cpp
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ***********************************************************************
4 //
5 // EpetraExt: Epetra Extended - Linear Algebra Services Package
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //@HEADER
42 */
43 
44 #include "Epetra_ConfigDefs.h"
45 #include "EpetraExt_Version.h"
46 #ifdef EPETRA_MPI
47 #include "mpi.h"
48 #include "Epetra_MpiComm.h"
49 #else
50 #include "Epetra_SerialComm.h"
51 #endif
52 #include "Trilinos_Util.h"
53 #include "Epetra_Comm.h"
54 #include "Epetra_Map.h"
55 #include "Epetra_Time.h"
56 #include "Epetra_BlockMap.h"
57 #include "Epetra_MultiVector.h"
58 #include "Epetra_Vector.h"
59 #include "Epetra_Export.h"
60 
61 #include "Epetra_VbrMatrix.h"
62 #include "Epetra_CrsMatrix.h"
63 #include "EpetraExt_RowMatrixOut.h"
64 #include "EpetraExt_OperatorOut.h"
66 #include "EpetraExt_VectorOut.h"
67 #include "EpetraExt_BlockMapOut.h"
68 #include "EpetraExt_BlockMapIn.h"
69 #include "EpetraExt_CrsMatrixIn.h"
71 #include "EpetraExt_VectorIn.h"
72 // include the header files again to check if guards are in place
73 #include "EpetraExt_RowMatrixOut.h"
74 #include "EpetraExt_VectorOut.h"
75 #include "EpetraExt_BlockMapOut.h"
76 #include "EpetraExt_BlockMapIn.h"
77 #include "EpetraExt_CrsMatrixIn.h"
79 #include "EpetraExt_VectorIn.h"
80 #include <string>
81 #include <vector>
82 #include "Poisson2dOperator.h"
83 // prototypes
84 
85 int checkValues( double x, double y, std::string message = "", bool verbose = false) {
86  if (fabs((x-y)/x) > 0.01 && x > 1.0e-12) {
87  if (verbose) std::cout << "********** " << message << " check failed.********** " << std::endl;
88  return(1);
89  }
90  else {
91  if (verbose) std::cout << message << " check OK." << std::endl;
92  return(0);
93  }
94 }
95 int runTests(Epetra_Map & map, Epetra_CrsMatrix & A, Epetra_Vector & x, Epetra_Vector & b, Epetra_Vector & xexact, bool verbose);
96 int runOperatorTests(Epetra_Operator & A, bool verbose);
97 int generateHyprePrintOut(const char* filename, const Epetra_Comm &comm);
98 int runHypreTest(Epetra_CrsMatrix &A);
99 
100 int main(int argc, char *argv[]) {
101 
102 #ifdef EPETRA_MPI
103  MPI_Init(&argc,&argv);
104  Epetra_MpiComm comm (MPI_COMM_WORLD);
105 #else
106  Epetra_SerialComm comm;
107 #endif
108 
109  int MyPID = comm.MyPID();
110 
111  bool verbose = false;
112  bool verbose1 = false;
113  // Check if we should print results to standard out
114  if (argc > 1) {
115  if ((argv[1][0] == '-') && (argv[1][1] == 'v')) {
116  verbose1 = true;
117  if (MyPID==0) verbose = true;
118  }
119  }
120  if (verbose)
121  std::cout << EpetraExt::EpetraExt_Version() << std::endl << std::endl;
122 
123  if (verbose1) std::cout << comm << std::endl;
124 
125 
126  // Uncomment the next three lines to debug in mpi mode
127  //int tmp;
128  //if (MyPID==0) cin >> tmp;
129  //comm.Barrier();
130 
131  Epetra_Map * map;
132  Epetra_CrsMatrix * A;
133  Epetra_Vector * x;
134  Epetra_Vector * b;
135  Epetra_Vector * xexact;
136 
137  int nx = 20*comm.NumProc();
138  int ny = 30;
139  int npoints = 7;
140  int xoff[] = {-1, 0, 1, -1, 0, 1, 0};
141  int yoff[] = {-1, -1, -1, 0, 0, 0, 1};
142 
143 
144  int ierr = 0;
145  // Call routine to read in HB problem 0-base
146  Trilinos_Util_GenerateCrsProblem64(nx, ny, npoints, xoff, yoff, comm, map, A, x, b, xexact);
147 
148  ierr += runTests(*map, *A, *x, *b, *xexact, verbose);
149 
150  delete A;
151  delete x;
152  delete b;
153  delete xexact;
154  delete map;
155 
156  // Call routine to read in HB problem 1-base
157  Trilinos_Util_GenerateCrsProblem64(nx, ny, npoints, xoff, yoff, comm, map, A, x, b, xexact, 1);
158 
159  ierr += runTests(*map, *A, *x, *b, *xexact, verbose);
160 
161  delete A;
162  delete x;
163  delete b;
164  delete xexact;
165  delete map;
166 
167  // Call routine to read in HB problem -1-base
168  Trilinos_Util_GenerateCrsProblem64(nx, ny, npoints, xoff, yoff, comm, map, A, x, b, xexact, -1);
169 
170  ierr += runTests(*map, *A, *x, *b, *xexact, verbose);
171 
172  delete A;
173  delete x;
174  delete b;
175  delete xexact;
176  delete map;
177 
178  int nx1 = 5;
179  int ny1 = 4;
180  Poisson2dOperator Op(nx1, ny1, comm);
181  ierr += runOperatorTests(Op, verbose);
182 
183  generateHyprePrintOut("MyMatrixFile", comm);
184 
185  EPETRA_CHK_ERR(EpetraExt::HypreFileToCrsMatrix64("MyMatrixFile", comm, A));
186 
187  runHypreTest(*A);
188  delete A;
189 
190  #ifdef EPETRA_MPI
191  MPI_Finalize() ;
192 #endif
193 
194  return(ierr);
195 }
196 
197 int runHypreTest(Epetra_CrsMatrix &A){
198 
199  Epetra_Vector X(A.RowMap());
200  EPETRA_CHK_ERR(X.Random());
201  Epetra_Vector Y(A.RowMap());
202  EPETRA_CHK_ERR(A.Multiply(false, X, Y));
203 
204  return 0;
205 }
206 
207 int runTests(Epetra_Map & map, Epetra_CrsMatrix & A, Epetra_Vector & x, Epetra_Vector & b, Epetra_Vector & xexact, bool verbose) {
208 
209  int ierr = 0;
210 
211  // Create MultiVectors and put x, b, xexact in both columns of X, B, and Xexact, respectively.
212  Epetra_MultiVector X( map, 2, false );
213  Epetra_MultiVector B( map, 2, false );
214  Epetra_MultiVector Xexact( map, 2, false );
215 
216  for (int i=0; i<X.NumVectors(); ++i) {
217  *X(i) = x;
218  *B(i) = b;
219  *Xexact(i) = xexact;
220  }
221  double residual;
222  std::vector<double> residualmv(2);
223  residual = A.NormInf(); double rAInf = residual;
224  if (verbose) std::cout << "Inf Norm of A = " << residual << std::endl;
225  residual = A.NormOne(); double rAOne = residual;
226  if (verbose) std::cout << "One Norm of A = " << residual << std::endl;
227  xexact.Norm2(&residual); double rxx = residual;
228  Xexact.Norm2(&residualmv[0]); std::vector<double> rXX( residualmv );
229  if (verbose) std::cout << "Norm of xexact = " << residual << std::endl;
230  if (verbose) std::cout << "Norm of Xexact = (" << residualmv[0] << ", " <<residualmv[1] <<")"<< std::endl;
231  Epetra_Vector tmp1(map);
232  Epetra_MultiVector tmp1mv(map,2,false);
233  A.Multiply(false, xexact, tmp1);
234  A.Multiply(false, Xexact, tmp1mv);
235  tmp1.Norm2(&residual); double rAx = residual;
236  tmp1mv.Norm2(&residualmv[0]); std::vector<double> rAX( residualmv );
237  if (verbose) std::cout << "Norm of Ax = " << residual << std::endl;
238  if (verbose) std::cout << "Norm of AX = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
239  b.Norm2(&residual); double rb = residual;
240  B.Norm2(&residualmv[0]); std::vector<double> rB( residualmv );
241  if (verbose) std::cout << "Norm of b (should equal norm of Ax) = " << residual << std::endl;
242  if (verbose) std::cout << "Norm of B (should equal norm of AX) = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
243  tmp1.Update(1.0, b, -1.0);
244  tmp1mv.Update(1.0, B, -1.0);
245  tmp1.Norm2(&residual);
246  tmp1mv.Norm2(&residualmv[0]);
247  if (verbose) std::cout << "Norm of difference between compute Ax and Ax from file = " << residual << std::endl;
248  if (verbose) std::cout << "Norm of difference between compute AX and AX from file = (" << residualmv[0] << ", " << residualmv[1] <<")"<< std::endl;
249  map.Comm().Barrier();
250 
251  EPETRA_CHK_ERR(EpetraExt::BlockMapToMatrixMarketFile("Test_map.mm", map, "Official EpetraExt test map",
252  "This is the official EpetraExt test map generated by the EpetraExt regression tests"));
253 
254  EPETRA_CHK_ERR(EpetraExt::RowMatrixToMatrixMarketFile("Test_A.mm", A, "Official EpetraExt test matrix",
255  "This is the official EpetraExt test matrix generated by the EpetraExt regression tests"));
256 
257  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_x.mm", x, "Official EpetraExt test initial guess",
258  "This is the official EpetraExt test initial guess generated by the EpetraExt regression tests"));
259 
260  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvX.mm", X, "Official EpetraExt test initial guess",
261  "This is the official EpetraExt test initial guess generated by the EpetraExt regression tests"));
262 
263  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_xexact.mm", xexact, "Official EpetraExt test exact solution",
264  "This is the official EpetraExt test exact solution generated by the EpetraExt regression tests"));
265 
266  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvXexact.mm", Xexact, "Official EpetraExt test exact solution",
267  "This is the official EpetraExt test exact solution generated by the EpetraExt regression tests"));
268 
269  EPETRA_CHK_ERR(EpetraExt::VectorToMatrixMarketFile("Test_b.mm", b, "Official EpetraExt test right hand side",
270  "This is the official EpetraExt test right hand side generated by the EpetraExt regression tests"));
271 
272  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatrixMarketFile("Test_mvB.mm", B, "Official EpetraExt test right hand side",
273  "This is the official EpetraExt test right hand side generated by the EpetraExt regression tests"));
274 
275  EPETRA_CHK_ERR(EpetraExt::MultiVectorToMatlabFile("Test_mvB.mat", B));
276 
277  EPETRA_CHK_ERR(EpetraExt::RowMatrixToMatlabFile("Test_A.dat", A));
278 
279  Epetra_Map * map1;
280  Epetra_CrsMatrix * A1;
281  Epetra_CrsMatrix * A2;
282  Epetra_CrsMatrix * A3;
283  Epetra_Vector * x1;
284  Epetra_Vector * b1;
285  Epetra_Vector * xexact1;
286  Epetra_MultiVector * X1;
287  Epetra_MultiVector * B1;
288  Epetra_MultiVector * Xexact1;
289 
290  EpetraExt::MatrixMarketFileToMap64("Test_map.mm", map.Comm(), map1);
291 
292  if (map.SameAs(*map1)) {
293  if (verbose) std::cout << "Maps are equal. In/Out works." << std::endl;
294  }
295  else {
296  if (verbose) std::cout << "Maps are not equal. In/Out fails." << std::endl;
297  ierr += 1;
298  }
299  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix64("Test_A.mm", *map1, A1));
300  // If map is zero-based, then we can compare to the convenient reading versions
301  if (map1->IndexBase64()==0) EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix64("Test_A.mm", map1->Comm(), A2));
302  if (map1->IndexBase64()==0) EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix64("Test_A.dat", map1->Comm(), A3));
303  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_x.mm", *map1, x1));
304  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_xexact.mm", *map1, xexact1));
305  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToVector("Test_b.mm", *map1, b1));
306  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvX.mm", *map1, X1));
307  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvXexact.mm", *map1, Xexact1));
308  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToMultiVector("Test_mvB.mm", *map1, B1));
309 
310  residual = A1->NormInf(); double rA1Inf = residual;
311  if (verbose) std::cout << "Inf Norm of A1 = " << residual << std::endl;
312  ierr += checkValues(rA1Inf,rAInf,"Inf Norm of A", verbose);
313 
314  residual = A1->NormOne(); double rA1One = residual;
315  if (verbose) std::cout << "One Norm of A1 = " << residual << std::endl;
316  ierr += checkValues(rA1One,rAOne,"One Norm of A", verbose);
317 
318  xexact1->Norm2(&residual); double rxx1 = residual;
319  if (verbose) std::cout << "Norm of xexact1 = " << residual << std::endl;
320  ierr += checkValues(rxx1,rxx,"Norm of xexact", verbose);
321 
322  Xexact1->Norm2(&residualmv[0]); std::vector<double> rXX1(residualmv);
323  if (verbose) std::cout << "Norm of Xexact1 = (" << residualmv[0] <<", " <<residualmv[1]<<")"<< std::endl;
324  ierr += checkValues(rXX1[0],rXX[0],"Norm of Xexact", verbose);
325  ierr += checkValues(rXX1[1],rXX[1],"Norm of Xexact", verbose);
326 
327  Epetra_Vector tmp11(*map1);
328  A1->Multiply(false, *xexact1, tmp11);
329 
330  Epetra_MultiVector tmp11mv(*map1,2,false);
331  A1->Multiply(false, *Xexact1, tmp11mv);
332 
333  tmp11.Norm2(&residual); double rAx1 = residual;
334  if (verbose) std::cout << "Norm of A1*x1 = " << residual << std::endl;
335  ierr += checkValues(rAx1,rAx,"Norm of A1*x", verbose);
336 
337  tmp11mv.Norm2(&residualmv[0]); std::vector<double> rAX1(residualmv);
338  if (verbose) std::cout << "Norm of A1*X1 = (" << residualmv[0] <<", "<<residualmv[1]<<")"<< std::endl;
339  ierr += checkValues(rAX1[0],rAX[0],"Norm of A1*X", verbose);
340  ierr += checkValues(rAX1[1],rAX[1],"Norm of A1*X", verbose);
341 
342  if (map1->IndexBase64()==0) {
343  Epetra_Vector tmp12(*map1);
344  A2->Multiply(false, *xexact1, tmp12);
345 
346  tmp12.Norm2(&residual); double rAx2 = residual;
347  if (verbose) std::cout << "Norm of A2*x1 = " << residual << std::endl;
348  ierr += checkValues(rAx2,rAx,"Norm of A2*x", verbose);
349 
350  Epetra_Vector tmp13(*map1);
351  A3->Multiply(false, *xexact1, tmp13);
352 
353  tmp13.Norm2(&residual); double rAx3 = residual;
354  if (verbose) std::cout << "Norm of A3*x1 = " << residual << std::endl;
355  ierr += checkValues(rAx3,rAx,"Norm of A3*x", verbose);
356  }
357  b1->Norm2(&residual); double rb1 = residual;
358  if (verbose) std::cout << "Norm of b1 (should equal norm of Ax) = " << residual << std::endl;
359  ierr += checkValues(rb1,rb,"Norm of b", verbose);
360 
361  B1->Norm2(&residualmv[0]); std::vector<double> rB1(residualmv);
362  if (verbose) std::cout << "Norm of B1 (should equal norm of AX) = (" << residualmv[0] <<", "<<residualmv[1]<<")"<< std::endl;
363  ierr += checkValues(rB1[0],rB[0],"Norm of B", verbose);
364  ierr += checkValues(rB1[1],rB[1],"Norm of B", verbose);
365 
366  tmp11.Update(1.0, *b1, -1.0);
367  tmp11.Norm2(&residual);
368  if (verbose) std::cout << "Norm of difference between computed A1x1 and A1x1 from file = " << residual << std::endl;
369  ierr += checkValues(residual,0.0,"Norm of difference between computed A1x1 and A1x1 from file", verbose);
370 
371  tmp11mv.Update(1.0, *B1, -1.0);
372  tmp11mv.Norm2(&residualmv[0]);
373  if (verbose) std::cout << "Norm of difference between computed A1X1 and A1X1 from file = (" << residualmv[0] << ", "<<residualmv[1]<<")"<< std::endl;
374  ierr += checkValues(residualmv[0],0.0,"Norm of difference between computed A1X1 and A1X1 from file", verbose);
375  ierr += checkValues(residualmv[1],0.0,"Norm of difference between computed A1X1 and A1X1 from file", verbose);
376 
377  if (map1->IndexBase64()==0) {delete A2; delete A3;}
378  delete A1;
379  delete x1;
380  delete b1;
381  delete xexact1;
382  delete X1;
383  delete B1;
384  delete Xexact1;
385  delete map1;
386 
387  return(ierr);
388 }
389 
390 int runOperatorTests(Epetra_Operator & A, bool verbose) {
391 
392  int ierr = 0;
393 
394 
395  double residual;
396  EPETRA_CHK_ERR(EpetraExt::OperatorToMatrixMarketFile("Test_A1.mm", A, "Official EpetraExt test operator",
397  "This is the official EpetraExt test operator generated by the EpetraExt regression tests"));
398  EPETRA_CHK_ERR(EpetraExt::OperatorToMatlabFile("Test_A1.dat", A));
399 
400  A.OperatorRangeMap().Comm().Barrier();
401  A.OperatorRangeMap().Comm().Barrier();
402  Epetra_CrsMatrix * A1;
403  Epetra_CrsMatrix * A2;
404  EPETRA_CHK_ERR(EpetraExt::MatrixMarketFileToCrsMatrix64("Test_A1.mm", A.OperatorRangeMap(), A1));
405  EPETRA_CHK_ERR(EpetraExt::MatlabFileToCrsMatrix64("Test_A1.dat", A.OperatorRangeMap().Comm(), A2));
406 
407 
408  residual = A.NormInf(); double rAInf = residual;
409  if (verbose) std::cout << "Inf Norm of Operator A = " << residual << std::endl;
410  residual = A1->NormInf(); double rA1Inf = residual;
411  if (verbose) std::cout << "Inf Norm of Matrix A1 = " << residual << std::endl;
412  ierr += checkValues(rA1Inf,rAInf,"Inf Norm of A", verbose);
413 
414 
415  Epetra_Vector x(A.OperatorDomainMap()); x.Random();
416  Epetra_Vector y1(A.OperatorRangeMap());
417  Epetra_Vector y2(A.OperatorRangeMap());
418  Epetra_Vector y3(A.OperatorRangeMap());
419  A.Apply(x,y1);
420  A1->Multiply(false, x, y2);
421  A2->Multiply(false, x, y3);
422 
423  y1.Norm2(&residual); double rAx1 = residual;
424  if (verbose) std::cout << "Norm of A*x = " << residual << std::endl;
425 
426  y2.Norm2(&residual); double rAx2 = residual;
427  if (verbose) std::cout << "Norm of A1*x = " << residual << std::endl;
428  ierr += checkValues(rAx1,rAx2,"Norm of A1*x", verbose);
429 
430  y3.Norm2(&residual); double rAx3 = residual;
431  if (verbose) std::cout << "Norm of A2*x = " << residual << std::endl;
432  ierr += checkValues(rAx1,rAx3,"Norm of A2*x", verbose);
433 
434  delete A1;
435  delete A2;
436 
437  return(ierr);
438 }
439 
440 int generateHyprePrintOut(const char *filename, const Epetra_Comm &comm){
441  int MyPID = comm.MyPID();
442  int NumProc = comm.NumProc();
443 
444  int N = 100;
445  int ilower = MyPID * N;
446  int iupper = (MyPID+1)*N-1;
447 
448  double filePID = (double)MyPID/(double)100000;
449  std::ostringstream stream;
450  // Using setprecision() puts it in the std::string
451  stream << std::setiosflags(std::ios::fixed) << std::setprecision(5) << filePID;
452  // Then just ignore the first character
453  std::string fileName(filename);
454  fileName += stream.str().substr(1,7);
455 
456  std::ofstream myfile(fileName.c_str());
457 
458  if(myfile.is_open()){
459  myfile << ilower << " " << iupper << " " << ilower << " " << iupper << std::endl;
460  for(int i = ilower; i <= iupper; i++){
461  for(int j=i-5; j <= i+5; j++){
462  if(j >= 0 && j < N*NumProc)
463  myfile << i << " " << j << " " << (double)rand()/(double)RAND_MAX << std::endl;
464  }
465  }
466  myfile.close();
467  return 0;
468  } else {
469  std::cout << "\nERROR:\nCouldn't open file.\n";
470  return -1;
471  }
472 }
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...
int MatrixMarketFileToMultiVector(const char *filename, const Epetra_BlockMap &map, Epetra_MultiVector *&A)
Constructs an Epetra_MultiVector object from a Matrix Market format file.
int MultiVectorToMatlabFile(const char *filename, const Epetra_MultiVector &A)
Writes an Epetra_MultiVector object to a file that is compatible with Matlab.
int BlockMapToMatrixMarketFile(const char *filename, const Epetra_BlockMap &map, const char *mapName, const char *mapDescription, bool writeHeader)
Writes an Epetra_BlockMap or Epetra_Map object to a Matrix Market format file.
int main(int argc, char *argv[])
int MatrixMarketFileToCrsMatrix64(const char *filename, const Epetra_Comm &comm, Epetra_CrsMatrix *&A)
std::string EpetraExt_Version()
int HypreFileToCrsMatrix64(const char *filename, const Epetra_Comm &comm, Epetra_CrsMatrix *&Matrix)
int MatrixMarketFileToMap64(const char *filename, const Epetra_Comm &comm, Epetra_Map *&map)
int runOperatorTests(Epetra_Operator &A, bool verbose)
const int N
std::string filename
int RowMatrixToMatlabFile(const char *filename, const Epetra_RowMatrix &A)
Writes an Epetra_RowMatrix object to a file that is compatible with Matlab.
int MatlabFileToCrsMatrix64(const char *filename, const Epetra_Comm &comm, Epetra_CrsMatrix *&A)
int MultiVectorToMatrixMarketFile(const char *filename, const Epetra_MultiVector &A, const char *matrixName, const char *matrixDescription, bool writeHeader)
Writes an Epetra_MultiVector object to a Matrix Market format file.
Poisson2dOperator: A sample implementation of the Epetra_Operator class.
int runHypreTest(Epetra_CrsMatrix &A)
int RowMatrixToMatrixMarketFile(const char *filename, const Epetra_RowMatrix &A, const char *matrixName, const char *matrixDescription, bool writeHeader)
Writes an Epetra_RowMatrix object to a Matrix Market format file.
int VectorToMatrixMarketFile(const char *filename, const Epetra_Vector &A, const char *matrixName, const char *matrixDescription, bool writeHeader)
Writes an Epetra_Vector object to a Matrix Market format file.
int OperatorToMatlabFile(const char *filename, const Epetra_Operator &A)
Writes an Epetra_Operator object to a file that is compatible with Matlab.
int MatrixMarketFileToVector(const char *filename, const Epetra_BlockMap &map, Epetra_Vector *&A)
Constructs an Epetra_Vector object from a Matrix Market format file.
int checkValues(double x, double y, std::string message="", bool verbose=false)
int runTests(Epetra_Map &map, Epetra_CrsMatrix &A, Epetra_Vector &x, Epetra_Vector &b, Epetra_Vector &xexact, bool verbose)
int generateHyprePrintOut(const char *filename, const Epetra_Comm &comm)