Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultAdjointLinearOpWithSolve_def.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 
43 #ifndef THYRA_DEFAULT_ADJOINT_LINEAR_OP_WITH_SOLVE_DEF_HPP
44 #define THYRA_DEFAULT_ADJOINT_LINEAR_OP_WITH_SOLVE_DEF_HPP
45 
46 
47 #include "Thyra_DefaultAdjointLinearOpWithSolve_decl.hpp"
48 #include "Thyra_LinearOpWithSolveBase.hpp"
49 
50 
51 namespace Thyra {
52 
53 
54 // Constructors/initializers/accessors
55 
56 
57 template<class Scalar>
59  : transp_(NOTRANS)
60 {}
61 
62 
63 template<class Scalar>
65  const RCP<LinearOpWithSolveBase<Scalar> > &lows,
66  const EOpTransp transp )
67 {
68  lows_ = lows;
69  transp_ = transp;
70 }
71 
72 
73 template<class Scalar>
75  const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
76  const EOpTransp transp )
77 {
78  lows_ = lows;
79  transp_ = transp;
80 }
81 
82 
83 template<class Scalar>
86 {
87  return lows_.getNonconstObj();
88 }
89 
90 
91 template<class Scalar>
94 {
95  return lows_.getConstObj();
96 }
97 
98 
99 // Overridden from LinearOpBase */
100 
101 
102 template<class Scalar>
105 {
106  return ( real_trans(transp_) == NOTRANS
107  ? lows_()->range() : lows_()->domain() );
108 }
109 
110 
111 template<class Scalar>
114 {
115  return ( real_trans(transp_) == NOTRANS
116  ? lows_()->domain() : lows_()->range() );
117 }
118 
119 
120 // protected
121 
122 
123 // Overridden from LinearOpBase
124 
125 
126 template<class Scalar>
128  EOpTransp M_trans) const
129 {
130  return Thyra::opSupported(*lows_(), trans_trans(transp_, M_trans));
131 }
132 
133 
134 template<class Scalar>
136  const EOpTransp M_trans,
137  const MultiVectorBase<Scalar> &X,
138  const Ptr<MultiVectorBase<Scalar> > &Y,
139  const Scalar alpha,
140  const Scalar beta
141  ) const
142 {
143  Thyra::apply( *lows_(), trans_trans(transp_, M_trans),
144  X, Y, alpha, beta );
145 }
146 
147 
148 // Overridden from LinearOpWithSolveBase
149 
150 
151 template<class Scalar>
153 {
154  return Thyra::solveSupports(*lows_(), trans_trans(transp_, M_trans));
155 }
156 
157 
158 template<class Scalar>
160  EOpTransp M_trans, const SolveMeasureType& solveMeasureType) const
161 {
162  return Thyra::solveSupportsSolveMeasureType(*lows_(),
163  trans_trans(transp_, M_trans), solveMeasureType );
164 }
165 
166 
167 
168 template<class Scalar>
171  const EOpTransp transp,
172  const MultiVectorBase<Scalar> &B,
173  const Ptr<MultiVectorBase<Scalar> > &X,
174  const Ptr<const SolveCriteria<Scalar> > solveCriteria
175  ) const
176 {
177  return Thyra::solve( *lows_(), trans_trans(transp_, transp),
178  B, X, solveCriteria );
179 }
180 
181 
182 } // namespace Thyra
183 
184 
185 #endif // THYRA_DEFAULT_ADJOINT_LINEAR_OP_WITH_SOLVE_DEF_HPP
bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
Base class for all linear operators that can support a high-level solve operation.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Use the non-transposed operator.
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
const RCP< const LinearOpWithSolveBase< Scalar > > getOp() const
Get the const underlying LOWSB object.
RCP< const VectorSpaceBase< Scalar > > range() const
Interface for a collection of column vectors called a multi-vector.
const RCP< LinearOpWithSolveBase< Scalar > > getNonconstOp()
Get the non-const underlying LOWSB object.
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
Combine two transpose arguments.
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Simple struct for the return status from a solve.
RCP< const VectorSpaceBase< Scalar > > domain() const
Simple struct that defines the requested solution criteria for a solve.
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
void initialize(const RCP< LinearOpWithSolveBase< Scalar > > &lows, const EOpTransp transp)
Initialize with non-const LOWSB .