Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Common.hpp
Go to the documentation of this file.
1 #ifndef COMMON_HPP
2 #define COMMON_HPP
3 
4 //
5 // Header file for classes common to all "packages" in this example.
6 //
7 
10 #include <iostream>
11 #include <sstream>
12 
13 // Namespace for classes common to all "packages" in this example.
14 namespace Common {
15 
16  // Stub of a MultiVector (MV) class, templated on Scalar type (the
17  // type of its entries).
18  template<class Scalar>
19  class MultiVector {};
20 
21  // Stub of an Operator (OP) class, templated on Scalar type (the
22  // template parameter of the MultiVector specialization that it
23  // uses).
24  template<class Scalar>
25  class Operator {
26  public:
28 
29  void apply (MV& /* Y */, const MV& /* X */) {
30  std::cout << "Operator<" << typeid (Scalar).name () << ">::apply" << std::endl;
31  }
32  };
33 
34  // Base classes of Trilinos::Details::LinearSolver must implement
35  // all the pure virtual methods of that interface. This base class
36  // only exists to make the example more concise. Its subclasses
37  // must implement solve(), name(), and the virtual destructor.
38  template<class MV, class OP, class NormType>
39  class LinearSolverTestBase : public Trilinos::Details::LinearSolver<MV, OP, NormType> {
40  protected:
41  virtual std::string name () const = 0;
42 
43  public:
44  virtual ~LinearSolverTestBase () {}
45 
47  std::cout << this->name () << "::setMatrix" << std::endl;
48  A_ = A;
49  }
50 
52  std::cout << this->name () << "::getMatrix" << std::endl;
53  return A_; // this could be null if setMatrix wasn't called
54  }
55 
57  std::cout << this->name () << "::setParameters" << std::endl;
58  }
59 
60  void symbolic () {
61  std::cout << this->name () << "::symbolic" << std::endl;
62  }
63 
64  void numeric () {
65  std::cout << this->name () << "::numeric" << std::endl;
66  }
67 
68  private:
69  Teuchos::RCP<const OP> A_; // the matrix given to setMatrix
70  };
71 
72 } // namespace Common
73 
74 #endif // COMMON_HPP
virtual ~LinearSolverTestBase()
Definition: Common.hpp:44
Teuchos::RCP< const OP > getMatrix() const
Get a pointer to this solver&#39;s matrix.
Definition: Common.hpp:51
Interface for a method for solving linear system(s) AX=B.
Declaration and definition of linear solver factory, and &quot;factory of factories&quot;.
void symbolic()
Set up any part of the solve that depends on the structure of the input matrix, but not its numerical...
Definition: Common.hpp:60
void numeric()
Set up any part of the solve that depends on both the structure and the numerical values of the input...
Definition: Common.hpp:64
virtual std::string name() const =0
Teuchos::RCP< const OP > A_
Definition: Common.hpp:69
Declaration of linear solver interface.
MultiVector< Scalar > MV
Definition: Common.hpp:27
void apply(MV &, const MV &)
Definition: Common.hpp:29
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > &)
Set this solver&#39;s parameters.
Definition: Common.hpp:56
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver&#39;s matrix.
Definition: Common.hpp:46