Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultDiagonalLinearOpWithSolve_def.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
11 #define THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
12 
13 #include "Thyra_DefaultDiagonalLinearOpWithSolve_decl.hpp"
14 #include "Thyra_DefaultDiagonalLinearOp.hpp"
15 #include "Thyra_MultiVectorStdOps.hpp"
16 #include "Thyra_VectorBase.hpp"
17 #include "Thyra_TestingTools.hpp" // ToDo: I need to have a better way to get eps()!
18 #include "Teuchos_Assert.hpp"
19 
20 
21 namespace Thyra {
22 
23 
24 // Constructors/initializers/accessors
25 
26 
27 template<class Scalar>
29 {}
30 
31 
32 template<class Scalar>
34  const RCP<const VectorBase<Scalar> > &diag
35  )
36 {
37  this->initialize(diag);
38 }
39 
40 
41 // protected
42 
43 
44 // Overridden from LinearOpWithSolveBase
45 
46 
47 template<class Scalar>
48 bool
50  EOpTransp M_trans) const
51 {
53  return (ST::isComplex ? M_trans==NOTRANS || M_trans==TRANS : true);
54 }
55 
56 
57 template<class Scalar>
58 bool
60  EOpTransp M_trans, const SolveMeasureType& /* solveMeasureType */) const
61 {
62  return this->solveSupportsImpl(M_trans); // I am a direct solver!
63 }
64 
65 
66 template<class Scalar>
69  const EOpTransp transp,
70  const MultiVectorBase<Scalar> &B,
71  const Ptr<MultiVectorBase<Scalar> > &X,
72  const Ptr<const SolveCriteria<Scalar> > solveCriteria
73  ) const
74 {
75 
76 #ifdef THYRA_DEBUG
77  TEUCHOS_ASSERT(this->solveSupportsImpl(transp));
78 #else
79  (void)transp;
80 #endif
81 
83 
84  assign(X, ST::zero());
85 
86  const Ordinal numCols = B.domain()->dim();
87  SolveStatus<Scalar> overallSolveStatus;
88 
89  for (Ordinal col_j = 0; col_j < numCols; ++col_j) {
90 
91  const RCP<const VectorBase<Scalar> > b = B.col(col_j);
92  const RCP<VectorBase<Scalar> > x = X->col(col_j);
93 
94  ele_wise_divide( ST::one(), *b, *this->getDiag(), x.ptr() );
95 
96  }
97 
98  SolveStatus<Scalar> solveStatus;
99  solveStatus.solveStatus =
100  (nonnull(solveCriteria) && !solveCriteria->solveMeasureType.useDefault()
103  return solveStatus;
104 
105 }
106 
107 
108 } // end namespace Thyra
109 
110 
111 #endif // THYRA_DIAGONAL_LINEAR_OP_WITH_SOLVE_HPP
void initialize(int *argc, char ***argv)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Use the non-transposed operator.
The final solution status is unknown but he solve did not totally fail.
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Use the transposed operator.
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
Ptr< T > ptr() const
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
static ScalarMag unknownTolerance()
Abstract interface for finite-dimensional dense vectors.
Simple struct for the return status from a solve.
bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
ESolveStatus solveStatus
The return status of the solve.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
bool nonnull(const boost::shared_ptr< T > &p)
ScalarMag achievedTol
The maximum final tolerance actually achieved by the (block) linear solve. A value of unknownToleranc...
The requested solution criteria has likely been achieved.
#define TEUCHOS_ASSERT(assertion_test)
Simple struct that defines the requested solution criteria for a solve.