44 #ifndef IRTR_DRIVER_HPP
45 #define IRTR_DRIVER_HPP
47 #include <Teuchos_TypeNameTraits.hpp>
48 #include <Teuchos_TimeMonitor.hpp>
49 #include <Teuchos_ParameterList.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
63 namespace IRTRdetails {
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>
90 Teuchos::RCP<Teuchos::FancyOStream> out;
91 Teuchos::RCP<Teuchos::ParameterList> params;
92 std::string matrixFile;
97 void run(Teuchos::ParameterList &myMachPL,
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm,
const Teuchos::RCP<Node> &node)
103 using Teuchos::ParameterList;
104 using Teuchos::parameterList;
113 typedef Teuchos::ScalarTraits<S> ST;
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();
124 if (Teuchos::TypeTraits::is_same<S,Sinner>::value) {
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>() );
150 const S rnrm = Teuchos::ScalarTraits<S>::squareroot(r_r);
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;
160 Teuchos::TimeMonitor::summarize( *out );
164 #endif // IRTR_DRIVER_HPP
Sparse matrix that presents a compressed sparse row interface.
Describes a parallel distribution of objects over processes.
A distributed dense vector.
A static identity functor, providing a static method identity() that returns zero.