Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DetachedMultiVectorView.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 #include "Thyra_MultiVectorBase.hpp"
11 #include "Thyra_AssertOp.hpp"
12 
13 #ifndef THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
14 #define THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
15 
16 namespace Thyra {
17 
18 
24 template<class Scalar>
26 public:
29  const RCP<const MultiVectorBase<Scalar> > &mv,
30  const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
31  )
32  : mv_(mv) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
35  const MultiVectorBase<Scalar>& mv,
36  const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
37  )
38  : mv_(rcpFromRef(mv)) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
40  ~ConstDetachedMultiVectorView() { mv_->releaseDetachedView(&smv_); }
42  const RTOpPack::ConstSubMultiVectorView<Scalar>& smv() const { return smv_; }
44  Ordinal globalOffset() const { return smv_.globalOffset(); }
46  Ordinal subDim() const { return smv_.subDim(); }
48  Ordinal colOffset() const { return smv_.colOffset(); }
50  Ordinal numSubCols() const { return smv_.numSubCols(); }
52  const Scalar* values() const { return smv_.values().get(); }
54  Ordinal leadingDim() const { return smv_.leadingDim(); }
58  const Scalar& operator()(Ordinal i, Ordinal j) const { return smv_(i,j); }
59 private:
62  // Not defined and not to be called
67 };
68 
69 
75 template<class Scalar>
77 public:
80  const RCP<MultiVectorBase<Scalar> >& mv,
81  const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
82  )
83  : mv_(mv) { mv_->acquireDetachedView(rowRng, colRng, &smv_); }
87  const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
88  )
89  : mv_(rcpFromRef(mv)) { mv_->acquireDetachedView(rowRng,colRng,&smv_); }
91  ~DetachedMultiVectorView() { mv_->commitDetachedView(&smv_); }
93  const RTOpPack::SubMultiVectorView<Scalar>& smv() const { return smv_; }
95  Ordinal globalOffset() const { return smv_.globalOffset(); }
97  Ordinal subDim() const { return smv_.subDim(); }
99  Ordinal colOffset() const { return smv_.colOffset(); }
101  Ordinal numSubCols() const { return smv_.numSubCols(); }
103  Scalar* values() const { return smv_.values().get(); }
105  Ordinal leadingDim() const { return smv_.leadingDim(); }
109  Scalar& operator()(Ordinal i, Ordinal j) { return smv_(i,j); }
110 private:
113  // Not defined and not to be called
118 };
119 
120 
125 template<class Scalar>
127  const MultiVectorBase<Scalar>& mvIn, MultiVectorBase<Scalar>* mvTransOut
128  )
129 {
131 #ifdef TEUCHOS_DEBUG
132  TEUCHOS_TEST_FOR_EXCEPT(0==mvTransOut);
133  THYRA_ASSERT_VEC_SPACES("doExplicitMultiVectorAdjoint(...)",
134  *mvIn.domain(), *mvTransOut->range()
135  );
136  THYRA_ASSERT_VEC_SPACES("doExplicitMultiVectorAdjoint(...)",
137  *mvIn.range(), *mvTransOut->domain()
138  );
139 #endif
141  DetachedMultiVectorView<Scalar> dMvTransOut(*mvTransOut);
142  const int m = dMvIn.subDim();
143  const int n = dMvIn.numSubCols();
144  for ( int j = 0; j < n; ++j ) {
145  for ( int i = 0; i < m; ++i ) {
146  dMvTransOut(j,i) = ST::conjugate(dMvIn(i,j));
147  }
148  }
149 }
150 
151 
152 } // namespace Thyra
153 
154 
155 #endif // THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
const Scalar & operator()(Ordinal i, Ordinal j) const
#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...
Create an explicit non-mutable (const) view of a MultiVectorBase object.
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
const RTOpPack::ConstSubMultiVectorView< Scalar > & smv() const
Create an explicit mutable (non-const) view of a MultiVectorBase object.
ConstDetachedMultiVectorView(const MultiVectorBase< Scalar > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
const RTOpPack::SubMultiVectorView< Scalar > & smv() const
void doExplicitMultiVectorAdjoint(const MultiVectorBase< Scalar > &mvIn, MultiVectorBase< Scalar > *mvTransOut)
Do an explicit multi-vector adjoint.
DetachedMultiVectorView(MultiVectorBase< Scalar > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
ConstDetachedMultiVectorView(const RCP< const MultiVectorBase< Scalar > > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
DetachedMultiVectorView(const RCP< MultiVectorBase< Scalar > > &mv, const Range1D &rowRng=Range1D(), const Range1D &colRng=Range1D())
Scalar & operator()(Ordinal i, Ordinal j)
Teuchos::Range1D Range1D