44 #ifndef IRTR_DRIVER_HPP 45 #define IRTR_DRIVER_HPP 50 #include <Teuchos_FancyOStream.hpp> 52 #include <Tpetra_Version.hpp> 53 #include <Tpetra_MatrixIO.hpp> 54 #include <Tpetra_RTI.hpp> 55 #include <Tpetra_CrsMatrix.hpp> 56 #include <Tpetra_Vector.hpp> 58 #include "IRTR_solvers.hpp" 61 #define XFORM_REDUCE TPETRA_BINARY_PRETRANSFORM_REDUCE 65 struct trivial_fpu_fix {
70 struct nontrivial_fpu_fix {
72 void fix() {fpu_fix_start(&old_cw);}
73 void unfix() {fpu_fix_end(&old_cw);}
77 template <
class T>
struct fpu_fix : trivial_fpu_fix {};
79 template <>
struct fpu_fix<qd_real> : nontrivial_fpu_fix {};
80 template <>
struct fpu_fix<dd_real> : nontrivial_fpu_fix {};
86 template <
class S,
class Sinner = S>
92 std::string matrixFile;
104 using Teuchos::parameterList;
115 IRTRdetails::fpu_fix<S> ff; ff.fix();
117 *out <<
"Running test with Node==" <<
Teuchos::typeName(*node) <<
" on rank " << comm->getRank() <<
"/" << comm->getSize() << std::endl;
121 RCP<const Map> rowMap = null;
122 RCP<ParameterList> fillParams = parameterList();
125 fillParams->set(
"Preserve Local Graph",
false);
128 fillParams->set(
"Preserve Local Graph",
true);
130 Tpetra::Utils::readHBMatrix(matrixFile,comm,node,A,rowMap,fillParams);
131 rowMap = A->getRowMap();
136 auto x = Tpetra::createVector<S>(rowMap);
140 S lambda = TpetraExamples::IRTR<Sinner,S,LO,GO,Node>(out,*params,A,x);
144 auto r = Tpetra::createVector<S>(rowMap);
147 const S r_r = XFORM_REDUCE(r, x,
149 r*r, ZeroOp<S>, plus<S>() );
152 *out <<
"|A*x - x*lambda|/|lambda|: " << rnrm / ST::magnitude(lambda) << endl;
153 const double tolerance = params->get<
double>(
"tolerance");
154 if (rnrm / lambda > tolerance) testPassed =
false;
164 #endif // IRTR_DRIVER_HPP Sparse matrix that presents a compressed sparse row interface.
static void summarize(Ptr< const Comm< int > > comm, std::ostream &out=std::cout, const bool alwaysWriteLocal=false, const bool writeGlobalStats=true, const bool writeZeroTimers=true, const ECounterSetOp setOp=Intersection, const std::string &filter="")
Describes a parallel distribution of objects over processes.
A distributed dense vector.
A static identity functor, providing a static method identity() that returns zero.
std::string typeName(const T &t)