Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
support
operator_solve
client_support
Thyra_DefaultSerialDenseLinearOpWithSolve_decl.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_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP
44
#define THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP
45
46
47
#include "Thyra_LinearOpWithSolveBase.hpp"
48
#include "RTOpPack_LapackWrappers.hpp"
49
50
51
namespace
Thyra {
52
53
54
/* \brief . */
55
inline
RTOpPack::ETransp convertToRTOpPackETransp(
const
EOpTransp transp )
56
{
57
#ifdef TEUCHOS_DEBUG
58
TEUCHOS_TEST_FOR_EXCEPT
(transp == CONJ);
59
#endif
60
switch
(transp) {
61
case
NOTRANS
:
62
return
RTOpPack::NOTRANS;
63
case
TRANS:
64
return
RTOpPack::TRANS;
65
case
CONJTRANS:
66
return
RTOpPack::CONJTRANS;
67
default
:
68
TEUCHOS_TEST_FOR_EXCEPT
(
true
);
69
}
70
TEUCHOS_UNREACHABLE_RETURN
(RTOpPack::NOTRANS);
71
}
72
// ToDo: Move the above function into Thyra_OperatorVectorTypes.hpp
73
74
90
template
<
class
Scalar>
91
class
DefaultSerialDenseLinearOpWithSolve
92
:
virtual
public
LinearOpWithSolveBase
<Scalar>
93
{
94
public
:
95
98
100
DefaultSerialDenseLinearOpWithSolve
();
101
103
void
initialize
(
const
RCP
<
const
MultiVectorBase<Scalar>
> &M );
104
106
RCP<const LinearOpBase<Scalar>
>
getFwdOp
()
const
;
107
109
112
114
RCP<const VectorSpaceBase<Scalar>
>
range
()
const
;
116
RCP<const VectorSpaceBase<Scalar>
>
domain
()
const
;
117
119
120
protected
:
121
124
126
bool
opSupportedImpl
(EOpTransp M_trans)
const
;
128
void
applyImpl
(
129
const
EOpTransp M_trans,
130
const
MultiVectorBase<Scalar>
&X,
131
const
Ptr
<
MultiVectorBase<Scalar>
> &Y,
132
const
Scalar alpha,
133
const
Scalar beta
134
)
const
;
135
137
140
142
bool
solveSupportsImpl
(EOpTransp M_trans)
const
;
144
bool
solveSupportsSolveMeasureTypeImpl
(
145
EOpTransp M_trans,
const
SolveMeasureType
& solveMeasureType)
const
;
147
SolveStatus<Scalar>
solveImpl
(
148
const
EOpTransp transp,
149
const
MultiVectorBase<Scalar>
&B,
150
const
Ptr
<
MultiVectorBase<Scalar>
> &X,
151
const
Ptr
<
const
SolveCriteria<Scalar>
> solveCriteria
152
)
const
;
153
155
156
private
:
157
158
// /////////////////////////
159
// Private data members
160
161
RCP<const MultiVectorBase<Scalar>
> M_;
162
RTOpPack::ConstSubMultiVectorView<Scalar>
LU_;
163
Array<int>
ipiv_;
164
165
// /////////////////////////
166
// Private member functions
167
168
static
void
factorize(
169
const
MultiVectorBase<Scalar>
&M,
170
const
Ptr
<
RTOpPack::ConstSubMultiVectorView<Scalar>
> &LU,
171
const
Ptr
<
Array<int>
> &ipiv
172
);
173
174
static
void
backsolve(
175
const
RTOpPack::ConstSubMultiVectorView<Scalar>
&LU,
176
const
ArrayView<const int>
ipiv,
177
const
EOpTransp transp,
178
const
MultiVectorBase<Scalar>
&B,
179
const
Ptr
<
MultiVectorBase<Scalar>
> &X
180
);
181
182
// Not defined and not to be called
183
DefaultSerialDenseLinearOpWithSolve
(
const
DefaultSerialDenseLinearOpWithSolve
&);
184
DefaultSerialDenseLinearOpWithSolve
& operator=(
const
DefaultSerialDenseLinearOpWithSolve
&);
185
186
};
187
188
193
template
<
class
Scalar>
194
RCP<DefaultSerialDenseLinearOpWithSolve<Scalar>
>
195
defaultSerialDenseLinearOpWithSolve
()
196
{
197
return
Teuchos::rcp
(
new
DefaultSerialDenseLinearOpWithSolve<Scalar>
);
198
}
199
200
205
template
<
class
Scalar>
206
RCP<DefaultSerialDenseLinearOpWithSolve<Scalar>
>
207
defaultSerialDenseLinearOpWithSolve
(
const
RCP
<
const
MultiVectorBase<Scalar>
> &M )
208
{
209
RCP<DefaultSerialDenseLinearOpWithSolve<Scalar>
>
210
M_lows =
Teuchos::rcp
(
new
DefaultSerialDenseLinearOpWithSolve<Scalar>
());
211
M_lows->initialize(M);
// With throw if singular
212
return
M_lows;
213
}
214
215
216
}
// end namespace Thyra
217
218
219
#endif
// THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_DECL_HPP
RTOpPack::ConstSubMultiVectorView
Teuchos::ArrayView
Teuchos::Array
Teuchos::Ptr
Teuchos::RCP
Thyra::DefaultSerialDenseLinearOpWithSolve::applyImpl
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:126
Thyra::DefaultSerialDenseLinearOpWithSolve::opSupportedImpl
bool opSupportedImpl(EOpTransp M_trans) const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:118
Thyra::DefaultSerialDenseLinearOpWithSolve::solveSupportsSolveMeasureTypeImpl
bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:151
Thyra::DefaultSerialDenseLinearOpWithSolve::initialize
void initialize(const RCP< const MultiVectorBase< Scalar > > &M)
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:67
Thyra::DefaultSerialDenseLinearOpWithSolve::range
RCP< const VectorSpaceBase< Scalar > > range() const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:93
Thyra::DefaultSerialDenseLinearOpWithSolve::solveSupportsImpl
bool solveSupportsImpl(EOpTransp M_trans) const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:142
Thyra::DefaultSerialDenseLinearOpWithSolve::domain
RCP< const VectorSpaceBase< Scalar > > domain() const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:103
Thyra::DefaultSerialDenseLinearOpWithSolve::solveImpl
SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:161
Thyra::DefaultSerialDenseLinearOpWithSolve::getFwdOp
RCP< const LinearOpBase< Scalar > > getFwdOp() const
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:83
Thyra::DefaultSerialDenseLinearOpWithSolve::defaultSerialDenseLinearOpWithSolve
RCP< DefaultSerialDenseLinearOpWithSolve< Scalar > > defaultSerialDenseLinearOpWithSolve()
Nonmember constructor.
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_decl.hpp:195
Thyra::DefaultSerialDenseLinearOpWithSolve::DefaultSerialDenseLinearOpWithSolve
DefaultSerialDenseLinearOpWithSolve()
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_def.hpp:62
Thyra::DefaultSerialDenseLinearOpWithSolve::defaultSerialDenseLinearOpWithSolve
RCP< DefaultSerialDenseLinearOpWithSolve< Scalar > > defaultSerialDenseLinearOpWithSolve(const RCP< const MultiVectorBase< Scalar > > &M)
Nonmember constructor.
Definition
Thyra_DefaultSerialDenseLinearOpWithSolve_decl.hpp:207
Thyra::LinearOpWithSolveBase
Base class for all linear operators that can support a high-level solve operation.
Definition
Thyra_LinearOpWithSolveBase_decl.hpp:311
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition
Thyra_MultiVectorBase_decl.hpp:496
TEUCHOS_TEST_FOR_EXCEPT
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Thyra::NOTRANS
NOTRANS
Type for the dimension of a vector space. `**/ typedef Teuchos::Ordinal Ordinal;.
Definition
Thyra_OperatorVectorTypes.hpp:162
TEUCHOS_UNREACHABLE_RETURN
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Thyra::SolveCriteria
Simple struct that defines the requested solution criteria for a solve.
Definition
Thyra_SolveSupportTypes.hpp:312
Thyra::SolveMeasureType
Solve tolerance type.
Definition
Thyra_SolveSupportTypes.hpp:112
Thyra::SolveStatus
Simple struct for the return status from a solve.
Definition
Thyra_SolveSupportTypes.hpp:423
Generated by
1.17.0