Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
support
operator_vector
client_support
Thyra_DefaultIdentityLinearOp_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_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
11
#define THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
12
13
#include "Thyra_DefaultIdentityLinearOp_decl.hpp"
14
#include "Thyra_MultiVectorStdOps.hpp"
15
#include "Thyra_AssertOp.hpp"
16
17
18
namespace
Thyra {
19
20
21
// Constructors/initializers/accessors
22
23
24
template
<
class
Scalar>
25
DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp
()
26
{}
27
28
29
template
<
class
Scalar>
30
DefaultIdentityLinearOp<Scalar>::DefaultIdentityLinearOp
(
31
const
Teuchos::RCP
<
const
VectorSpaceBase<Scalar>
> &space
32
)
33
{
34
initialize
(space);
35
}
36
37
38
template
<
class
Scalar>
39
void
DefaultIdentityLinearOp<Scalar>::initialize
(
40
const
Teuchos::RCP
<
const
VectorSpaceBase<Scalar>
> &space
41
)
42
{
43
space_ = space.assert_not_null();
44
}
45
46
47
template
<
class
Scalar>
48
void
DefaultIdentityLinearOp<Scalar>::uninitialize
()
49
{
50
space_ = Teuchos::null;
51
}
52
53
54
// Overridden from LinearOpBase
55
56
57
template
<
class
Scalar>
58
Teuchos::RCP< const VectorSpaceBase<Scalar>
>
59
DefaultIdentityLinearOp<Scalar>::range
()
const
60
{
61
return
space_;
62
}
63
64
65
template
<
class
Scalar>
66
Teuchos::RCP< const VectorSpaceBase<Scalar>
>
67
DefaultIdentityLinearOp<Scalar>::domain
()
const
68
{
69
return
space_;
70
}
71
72
73
template
<
class
Scalar>
74
Teuchos::RCP<const LinearOpBase<Scalar>
>
75
DefaultIdentityLinearOp<Scalar>::clone
()
const
76
{
77
typedef
DefaultIdentityLinearOp<Scalar>
this_t;
78
if
(space_.get())
79
return
Teuchos::rcp
(
new
this_t(space_));
80
return
Teuchos::rcp
(
new
this_t());
81
}
82
83
84
// Overridden from Teuchos::Describable
85
86
87
template
<
class
Scalar>
88
std::string
DefaultIdentityLinearOp<Scalar>::description
()
const
89
{
90
typedef
Teuchos::ScalarTraits<Scalar>
ST;
91
std::ostringstream oss;
92
oss
93
<<
"Thyra::DefaultIdentityLinearOp<"
<< ST::name() <<
">{"
94
<<
"space="
<<(space_.get()?space_->description():
"NULL"
)
95
<<
"}"
;
96
return
oss.str();
97
}
98
99
100
// protected
101
102
103
// Overridden from LinearOpBase
104
105
106
template
<
class
Scalar>
107
bool
DefaultIdentityLinearOp<Scalar>::opSupportedImpl
(EOpTransp
/* M_trans */
)
const
108
{
109
return
true
;
110
}
111
112
113
template
<
class
Scalar>
114
void
DefaultIdentityLinearOp<Scalar>::applyImpl
(
115
const
EOpTransp M_trans,
116
const
MultiVectorBase<Scalar>
&X,
117
const
Ptr
<
MultiVectorBase<Scalar>
> &Y,
118
const
Scalar alpha,
119
const
Scalar beta
120
)
const
121
{
122
using
Teuchos::tuple;
123
using
Teuchos::ptrFromRef;
124
#ifdef TEUCHOS_DEBUG
125
THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES
(
126
"DefaultIdentityLinearOp<Scalar>::apply(...)"
, *
this
, M_trans, X, &*Y
127
);
128
#else
129
(void)M_trans;
130
#endif
// TEUCHOS_DEBUG
131
Thyra::linear_combination<Scalar>
(
132
tuple<Scalar>(alpha)(),
133
tuple<
Ptr
<
const
MultiVectorBase<Scalar>
> >(ptrFromRef(X))(),
134
beta, Y
135
);
136
}
137
138
139
}
// end namespace Thyra
140
141
142
template
<
class
Scalar>
143
Teuchos::RCP<const Thyra::LinearOpBase<Scalar>
>
144
Thyra::identity
(
145
const
Teuchos::RCP
<
const
VectorSpaceBase<Scalar> > &space,
146
const
std::string &label
147
)
148
{
149
RCP<Thyra::LinearOpBase<Scalar> > ilo =
150
Teuchos::rcp
(
new
DefaultIdentityLinearOp<Scalar>(space));
151
if
(label.length())
152
ilo->setObjectLabel(label);
153
return
ilo;
154
}
155
156
157
//
158
// Explicit instantaition
159
//
160
161
162
#define THYRA_DEFAULT_IDENTITY_LINEAR_OP_INSTANT(SCALAR) \
163
\
164
template class DefaultIdentityLinearOp<SCALAR >; \
165
\
166
template RCP<const LinearOpBase<SCALAR > > \
167
identity( \
168
const RCP<const VectorSpaceBase<SCALAR > > &space, \
169
const std::string &label \
170
); \
171
172
173
#endif
// THYRA_DEFAULT_IDENTITY_LINEAR_OP_DEF_HPP
Teuchos::Ptr
Teuchos::RCP
Thyra::DefaultIdentityLinearOp::domain
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns Teuchos::null if uninitialized.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:67
Thyra::DefaultIdentityLinearOp::DefaultIdentityLinearOp
DefaultIdentityLinearOp()
Constructs to uninitialized.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:25
Thyra::DefaultIdentityLinearOp::opSupportedImpl
bool opSupportedImpl(EOpTransp M_trans) const
Returns true .
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:107
Thyra::DefaultIdentityLinearOp::clone
RCP< const LinearOpBase< Scalar > > clone() const
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:75
Thyra::DefaultIdentityLinearOp::identity
RCP< const LinearOpBase< Scalar > > identity(const RCP< const VectorSpaceBase< Scalar > > &space, const std::string &label="")
Create an identity linear operator with given a vector space.
Thyra::DefaultIdentityLinearOp::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_DefaultIdentityLinearOp_def.hpp:114
Thyra::DefaultIdentityLinearOp::range
RCP< const VectorSpaceBase< Scalar > > range() const
Returns Teuchos::null if uninitialized.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:59
Thyra::DefaultIdentityLinearOp::initialize
void initialize(const RCP< const VectorSpaceBase< Scalar > > &space)
Initialize given a list of non-const linear operators.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:39
Thyra::DefaultIdentityLinearOp::uninitialize
void uninitialize()
Set to uninitialized.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:48
Thyra::DefaultIdentityLinearOp::description
std::string description() const
Prints just the name DefaultIdentityLinearOp along with the overall dimensions.
Definition
Thyra_DefaultIdentityLinearOp_def.hpp:88
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition
Thyra_MultiVectorBase_decl.hpp:464
Thyra::MultiVectorBase::linear_combination
void linear_combination(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &X, const Scalar &beta, const Ptr< MultiVectorBase< Scalar > > &Y)
Y.col(j)(i) = beta*Y.col(j)(i) + sum( alpha[k]*X[k].col(j)(i), k=0...m-1 ), for i = 0....
Definition
Thyra_MultiVectorStdOps_def.hpp:188
Thyra::VectorSpaceBase
Abstract interface for objects that represent a space for vectors.
Definition
Thyra_VectorSpaceBase_decl.hpp:267
THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES
#define THYRA_ASSERT_LINEAR_OP_MULTIVEC_APPLY_SPACES(FUNC_NAME, M, M_T, X, Y)
This is a very useful macro that should be used to validate that the spaces for the multi-vector vers...
Definition
Thyra_AssertOp.hpp:218
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::ScalarTraits
Generated by
1.17.0