Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_ScalarProdVectorSpaceBase_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_SCALAR_PROD_VECTOR_SPACE_BASE_DEF_HPP
11 #define THYRA_SCALAR_PROD_VECTOR_SPACE_BASE_DEF_HPP
12 
13 #include "Thyra_ScalarProdVectorSpaceBase_decl.hpp"
14 #include "Thyra_VectorSpaceDefaultBase.hpp"
15 #include "Thyra_EuclideanScalarProd.hpp"
16 #include "Thyra_AssertOp.hpp"
17 
18 
19 namespace Thyra {
20 
21 
22 // Constructors / initializers
23 
24 
25 template<class Scalar>
27  :scalarProd_(Teuchos::rcp(new EuclideanScalarProd<Scalar>()))
28 {}
29 
30 
31 template<class Scalar>
33  const Teuchos::RCP<const ScalarProdBase<Scalar> > &scalarProd_in
34  )
35  :scalarProd_(scalarProd_in.assert_not_null())
36 {}
37 
38 
39 template<class Scalar>
41  const Teuchos::RCP<const ScalarProdBase<Scalar> > &scalarProd_in
42  )
43 {
44  scalarProd_ = scalarProd_in.assert_not_null();
45 }
46 
47 
48 template<class Scalar>
51 {
52  return scalarProd_;
53 }
54 
55 
56 // Overridden from VectorSpaceBase
57 
58 
59 template<class Scalar>
61 {
62  return scalarProd_->isEuclidean();
63 }
64 
65 
66 template<class Scalar>
68  const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const
69 {
70 #ifdef TEUCHOS_DEBUG
71  THYRA_ASSERT_VEC_SPACES("ScalarProdVectorSpaceBase<Scalar>::scalarProd(...)",
72  *x.space(), *this);
73  THYRA_ASSERT_VEC_SPACES("ScalarProdVectorSpaceBase<Scalar>::scalarProd(...)",
74  *y.space(), *this);
75 #endif
76  return scalarProd_->scalarProd(x,y);
77 }
78 
79 
80 template<class Scalar>
83  const ArrayView<Scalar> &scalarProds_out ) const
84 {
85 #ifdef TEUCHOS_DEBUG
86  THYRA_ASSERT_VEC_SPACES("ScalarProdVectorSpaceBase<Scalar>::scalarProds(...)",
87  *X.range(), *this);
88  THYRA_ASSERT_VEC_SPACES("ScalarProdVectorSpaceBase<Scalar>::scalarProds(...)",
89  *Y.range(), *this);
90  THYRA_ASSERT_VEC_SPACES("ScalarProdVectorSpaceBase<Scalar>::scalarProds(...)",
91  *X.domain(), *Y.domain());
92 #endif
93  scalarProd_->scalarProds(X, Y, scalarProds_out);
94 }
95 
96 
97 } // end namespace Thyra
98 
99 
100 #endif // THYRA_SCALAR_PROD_VECTOR_SPACE_BASE_DEF_HPP
virtual RCP< const VectorSpaceBase< Scalar > > space() const =0
Return a smart pointer to the vector space that this vector belongs to.
#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...
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
ScalarProdVectorSpaceBase()
Construct to use dot product as the default.
void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds_out) const
Calls getScalarProd()-&gt;scalarProds(X,Y,scalar_prods)
bool isEuclidean() const
Returns getScalarProd()-&gt;isEuclidean()
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Interface for a collection of column vectors called a multi-vector.
Abstract interface for finite-dimensional dense vectors.
RCP< const ScalarProdBase< Scalar > > getScalarProd() const
Return the current scalar product.
Concrete implementation of a scalar product for a Euclidean vector space (i.e. using the dot product)...
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
virtual void setScalarProd(const RCP< const ScalarProdBase< Scalar > > &scalarProd)
Set a different scalar product.
Abstract interface for scalar products.
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
Returns getScalarProd()-&gt;scalarProd(x,y)