Thyra Version of the Day
Loading...
Searching...
No Matches
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
19namespace Thyra {
20
21
22// Constructors / initializers
23
24
25template<class Scalar>
29
30
31template<class Scalar>
33 const Teuchos::RCP<const ScalarProdBase<Scalar> > &scalarProd_in
34 )
35 :scalarProd_(scalarProd_in.assert_not_null())
36{}
37
38
39template<class Scalar>
41 const Teuchos::RCP<const ScalarProdBase<Scalar> > &scalarProd_in
42 )
43{
44 scalarProd_ = scalarProd_in.assert_not_null();
45}
46
47
48template<class Scalar>
51{
52 return scalarProd_;
53}
54
55
56// Overridden from VectorSpaceBase
57
58
59template<class Scalar>
61{
62 return scalarProd_->isEuclidean();
63}
64
65
66template<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
80template<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
Concrete implementation of a scalar product for a Euclidean vector space (i.e. using the dot product)...
virtual RCP< const VectorSpaceBase< Scalar > > range() const =0
Return a smart pointer for the range space for this operator.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Interface for a collection of column vectors called a multi-vector.
Abstract interface for scalar products.
bool isEuclidean() const
Returns getScalarProd()->isEuclidean()
Scalar scalarProd(const VectorBase< Scalar > &x, const VectorBase< Scalar > &y) const
Returns getScalarProd()->scalarProd(x,y)
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()->scalarProds(X,Y,scalar_prods)
RCP< const ScalarProdBase< Scalar > > getScalarProd() const
Return the current scalar product.
virtual void setScalarProd(const RCP< const ScalarProdBase< Scalar > > &scalarProd)
Set a different scalar product.
Abstract interface for finite-dimensional dense vectors.
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.