Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
support
operator_vector
client_support
Thyra_DetachedMultiVectorView.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
#include "Thyra_MultiVectorBase.hpp"
43
#include "Thyra_AssertOp.hpp"
44
45
#ifndef THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
46
#define THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
47
48
namespace
Thyra {
49
50
56
template
<
class
Scalar>
57
class
ConstDetachedMultiVectorView
{
58
public
:
60
ConstDetachedMultiVectorView
(
61
const
RCP
<
const
MultiVectorBase<Scalar>
> &mv,
62
const
Range1D
&rowRng =
Range1D
(),
const
Range1D
&colRng =
Range1D
()
63
)
64
: mv_(mv) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
65
66
ConstDetachedMultiVectorView
(
67
const
MultiVectorBase<Scalar>
& mv,
68
const
Range1D
&rowRng =
Range1D
(),
const
Range1D
&colRng =
Range1D
()
69
)
70
: mv_(rcpFromRef(mv)) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
71
72
~ConstDetachedMultiVectorView
() { mv_->releaseDetachedView(&smv_); }
74
const
RTOpPack::ConstSubMultiVectorView<Scalar>
&
smv
()
const
{
return
smv_; }
76
Ordinal
globalOffset
()
const
{
return
smv_.globalOffset(); }
78
Ordinal
subDim
()
const
{
return
smv_.subDim(); }
80
Ordinal
colOffset
()
const
{
return
smv_.colOffset(); }
82
Ordinal
numSubCols
()
const
{
return
smv_.numSubCols(); }
84
const
Scalar*
values
()
const
{
return
smv_.values().get(); }
86
Ordinal
leadingDim
()
const
{
return
smv_.leadingDim(); }
90
const
Scalar&
operator()
(Ordinal i, Ordinal j)
const
{
return
smv_(i,j); }
91
private
:
92
RCP<const MultiVectorBase<Scalar>
> mv_;
93
RTOpPack::ConstSubMultiVectorView<Scalar>
smv_;
94
// Not defined and not to be called
95
ConstDetachedMultiVectorView
();
96
ConstDetachedMultiVectorView
(
const
ConstDetachedMultiVectorView<Scalar>
&);
97
ConstDetachedMultiVectorView<Scalar>
& operator==(
98
const
ConstDetachedMultiVectorView<Scalar>
&);
99
};
100
101
107
template
<
class
Scalar>
108
class
DetachedMultiVectorView
{
109
public
:
111
DetachedMultiVectorView
(
112
const
RCP
<
MultiVectorBase<Scalar>
>& mv,
113
const
Range1D
&rowRng =
Range1D
(),
const
Range1D
&colRng =
Range1D
()
114
)
115
: mv_(mv) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
116
117
DetachedMultiVectorView
(
118
MultiVectorBase<Scalar>
& mv,
119
const
Range1D
&rowRng =
Range1D
(),
const
Range1D
&colRng =
Range1D
()
120
)
121
: mv_(rcpFromRef(mv)) { mv_->acquireDetachedView(rowRng,colRng,&smv_); }
122
123
~DetachedMultiVectorView
() { mv_->commitDetachedView(&smv_); }
125
const
RTOpPack::SubMultiVectorView<Scalar>
&
smv
()
const
{
return
smv_; }
127
Ordinal
globalOffset
()
const
{
return
smv_.globalOffset(); }
129
Ordinal
subDim
()
const
{
return
smv_.subDim(); }
131
Ordinal
colOffset
()
const
{
return
smv_.colOffset(); }
133
Ordinal
numSubCols
()
const
{
return
smv_.numSubCols(); }
135
Scalar*
values
()
const
{
return
smv_.values().get(); }
137
Ordinal
leadingDim
()
const
{
return
smv_.leadingDim(); }
141
Scalar&
operator()
(Ordinal i, Ordinal j) {
return
smv_(i,j); }
142
private
:
143
RCP<MultiVectorBase<Scalar>
> mv_;
144
RTOpPack::SubMultiVectorView<Scalar>
smv_;
145
// Not defined and not to be called
146
DetachedMultiVectorView
();
147
DetachedMultiVectorView
(
const
DetachedMultiVectorView<Scalar>
&);
148
DetachedMultiVectorView<Scalar>
& operator==(
149
const
DetachedMultiVectorView<Scalar>
&);
150
};
151
152
157
template
<
class
Scalar>
158
void
doExplicitMultiVectorAdjoint
(
159
const
MultiVectorBase<Scalar>
& mvIn,
MultiVectorBase<Scalar>
* mvTransOut
160
)
161
{
162
typedef
Teuchos::ScalarTraits<Scalar>
ST;
163
#ifdef TEUCHOS_DEBUG
164
TEUCHOS_TEST_FOR_EXCEPT
(0==mvTransOut);
165
THYRA_ASSERT_VEC_SPACES
(
"doExplicitMultiVectorAdjoint(...)"
,
166
*mvIn.
domain
(), *mvTransOut->
range
()
167
);
168
THYRA_ASSERT_VEC_SPACES
(
"doExplicitMultiVectorAdjoint(...)"
,
169
*mvIn.
range
(), *mvTransOut->
domain
()
170
);
171
#endif
172
ConstDetachedMultiVectorView<Scalar>
dMvIn(mvIn);
173
DetachedMultiVectorView<Scalar>
dMvTransOut(*mvTransOut);
174
const
int
m = dMvIn.
subDim
();
175
const
int
n = dMvIn.
numSubCols
();
176
for
(
int
j = 0; j < n; ++j ) {
177
for
(
int
i = 0; i < m; ++i ) {
178
dMvTransOut(j,i) = ST::conjugate(dMvIn(i,j));
179
}
180
}
181
}
182
183
184
}
// namespace Thyra
185
186
187
#endif
// THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
RTOpPack::ConstSubMultiVectorView
RTOpPack::SubMultiVectorView
Teuchos::RCP
Thyra::ConstDetachedMultiVectorView
Create an explicit non-mutable (const) view of a MultiVectorBase object.
Definition
Thyra_DetachedMultiVectorView.hpp:57
Thyra::ConstDetachedMultiVectorView::operator()
const Scalar & operator()(Ordinal i, Ordinal j) const
Definition
Thyra_DetachedMultiVectorView.hpp:90
Thyra::ConstDetachedMultiVectorView::colOffset
Ordinal colOffset() const
Definition
Thyra_DetachedMultiVectorView.hpp:80
Thyra::ConstDetachedMultiVectorView::numSubCols
Ordinal numSubCols() const
Definition
Thyra_DetachedMultiVectorView.hpp:82
Thyra::ConstDetachedMultiVectorView::smv
const RTOpPack::ConstSubMultiVectorView< Scalar > & smv() const
Definition
Thyra_DetachedMultiVectorView.hpp:74
Thyra::ConstDetachedMultiVectorView::values
const Scalar * values() const
Definition
Thyra_DetachedMultiVectorView.hpp:84
Thyra::ConstDetachedMultiVectorView::ConstDetachedMultiVectorView
ConstDetachedMultiVectorView(const RCP< const MultiVectorBase< Scalar > > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Definition
Thyra_DetachedMultiVectorView.hpp:60
Thyra::ConstDetachedMultiVectorView::~ConstDetachedMultiVectorView
~ConstDetachedMultiVectorView()
Definition
Thyra_DetachedMultiVectorView.hpp:72
Thyra::ConstDetachedMultiVectorView::leadingDim
Ordinal leadingDim() const
Definition
Thyra_DetachedMultiVectorView.hpp:86
Thyra::ConstDetachedMultiVectorView::globalOffset
Ordinal globalOffset() const
Definition
Thyra_DetachedMultiVectorView.hpp:76
Thyra::ConstDetachedMultiVectorView::ConstDetachedMultiVectorView
ConstDetachedMultiVectorView(const MultiVectorBase< Scalar > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Definition
Thyra_DetachedMultiVectorView.hpp:66
Thyra::ConstDetachedMultiVectorView::subDim
Ordinal subDim() const
Definition
Thyra_DetachedMultiVectorView.hpp:78
Thyra::DetachedMultiVectorView
Create an explicit mutable (non-const) view of a MultiVectorBase object.
Definition
Thyra_DetachedMultiVectorView.hpp:108
Thyra::DetachedMultiVectorView::DetachedMultiVectorView
DetachedMultiVectorView(MultiVectorBase< Scalar > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Definition
Thyra_DetachedMultiVectorView.hpp:117
Thyra::DetachedMultiVectorView::operator()
Scalar & operator()(Ordinal i, Ordinal j)
Definition
Thyra_DetachedMultiVectorView.hpp:141
Thyra::DetachedMultiVectorView::~DetachedMultiVectorView
~DetachedMultiVectorView()
Definition
Thyra_DetachedMultiVectorView.hpp:123
Thyra::DetachedMultiVectorView::leadingDim
Ordinal leadingDim() const
Definition
Thyra_DetachedMultiVectorView.hpp:137
Thyra::DetachedMultiVectorView::values
Scalar * values() const
Definition
Thyra_DetachedMultiVectorView.hpp:135
Thyra::DetachedMultiVectorView::numSubCols
Ordinal numSubCols() const
Definition
Thyra_DetachedMultiVectorView.hpp:133
Thyra::DetachedMultiVectorView::subDim
Ordinal subDim() const
Definition
Thyra_DetachedMultiVectorView.hpp:129
Thyra::DetachedMultiVectorView::smv
const RTOpPack::SubMultiVectorView< Scalar > & smv() const
Definition
Thyra_DetachedMultiVectorView.hpp:125
Thyra::DetachedMultiVectorView::colOffset
Ordinal colOffset() const
Definition
Thyra_DetachedMultiVectorView.hpp:131
Thyra::DetachedMultiVectorView::globalOffset
Ordinal globalOffset() const
Definition
Thyra_DetachedMultiVectorView.hpp:127
Thyra::DetachedMultiVectorView::DetachedMultiVectorView
DetachedMultiVectorView(const RCP< MultiVectorBase< Scalar > > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Definition
Thyra_DetachedMultiVectorView.hpp:111
Thyra::DetachedMultiVectorView::doExplicitMultiVectorAdjoint
void doExplicitMultiVectorAdjoint(const MultiVectorBase< Scalar > &mvIn, MultiVectorBase< Scalar > *mvTransOut)
Do an explicit multi-vector adjoint.
Definition
Thyra_DetachedMultiVectorView.hpp:158
Thyra::LinearOpBase::range
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
Thyra::LinearOpBase::domain
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
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_ASSERT_VEC_SPACES
#define THYRA_ASSERT_VEC_SPACES(FUNC_NAME, VS1, VS2)
This is a very useful macro that should be used to validate that two vector spaces are compatible.
Definition
Thyra_AssertOp.hpp:188
Thyra::Range1D
Teuchos::Range1D Range1D
Definition
Thyra_OperatorVectorTypes.hpp:97
Teuchos::ScalarTraits
Generated by
1.17.0