Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
adapters
tpetra
src
Thyra_TpetraEuclideanScalarProd_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_TPETRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP
11
#define THYRA_TPETRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP
12
13
#include "Thyra_TpetraEuclideanScalarProd_decl.hpp"
14
#include "Thyra_TpetraMultiVector.hpp"
15
#include "Thyra_TpetraVector.hpp"
16
17
18
namespace
Thyra {
19
20
21
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
22
void
TpetraEuclideanScalarProd<Scalar,LocalOrdinal,GlobalOrdinal,Node>::scalarProdsImpl
(
23
const
MultiVectorBase<Scalar>
& X,
24
const
MultiVectorBase<Scalar>
& Y,
25
const
ArrayView<Scalar>
& scalarProds_out
26
)
const
27
{
28
typedef
Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> TMV;
29
Teuchos::RCP<const TMV>
X_tpetra = this->getConstTpetraMultiVector(Teuchos::rcpFromRef(X));
30
Teuchos::RCP<const TMV>
Y_tpetra = this->getConstTpetraMultiVector(Teuchos::rcpFromRef(Y));
31
32
if
(nonnull(X_tpetra) && nonnull(Y_tpetra)) {
33
// Which one do we want transposed?
34
// Tpetra transposes the argument of dot.
35
// Below is the order from TpetraVectorSpace::scalarProdsImpl,
36
// so this would transpose Y. However, Thyra::dots (which calls
37
// the RTOp) transposes the first argument, so scalarProdsImpl
38
// in EuclideanScalarProd transposes X...
39
X_tpetra->dot(*Y_tpetra, scalarProds_out);
40
}
else
{
41
EuclideanScalarProd<Scalar>::scalarProdsImpl
(X, Y, scalarProds_out);
42
}
43
}
44
45
46
template
<
class
Scalar,
class
LocalOrdinal,
class
GlobalOrdinal,
class
Node>
47
Teuchos::RCP<const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
>
48
TpetraEuclideanScalarProd<Scalar,LocalOrdinal,GlobalOrdinal,Node>::
49
getConstTpetraMultiVector
(
const
RCP
<
const
MultiVectorBase<Scalar>
>& mv)
const
50
{
51
using
Teuchos::rcp_dynamic_cast;
52
typedef
Thyra::TpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
TMV;
53
typedef
Thyra::TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>
TV;
54
55
RCP<const TMV>
tmv = rcp_dynamic_cast<const TMV>(mv);
56
if
(nonnull(tmv)) {
57
return
tmv->getConstTpetraMultiVector();
58
}
59
60
RCP<const TV> tv = rcp_dynamic_cast<const TV>(mv);
61
if
(nonnull(tv)) {
62
return
tv->getConstTpetraVector();
63
}
64
65
return
Teuchos::null;
66
}
67
68
69
}
// end namespace Thyra
70
71
72
#endif
// THYRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP
Teuchos::ArrayView
Teuchos::RCP
Thyra::EuclideanScalarProd::scalarProdsImpl
virtual void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
Simply calls dots(X,Y,scalar_prods).
Definition
Thyra_EuclideanScalarProd_def.hpp:29
Thyra::MultiVectorBase
Interface for a collection of column vectors called a multi-vector.
Definition
Thyra_MultiVectorBase_decl.hpp:464
Thyra::TpetraEuclideanScalarProd
Extends concrete implementation of a Euclidean scalar product for specifically Tpetra vectors/multive...
Definition
Thyra_TpetraEuclideanScalarProd_decl.hpp:26
Thyra::TpetraEuclideanScalarProd::scalarProdsImpl
virtual void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
If X and Y are both Tpetra wrappers, computes the pair-wise scalar products directly with Tpetra call...
Definition
Thyra_TpetraEuclideanScalarProd_def.hpp:22
Thyra::TpetraMultiVector
Concrete implementation of Thyra::MultiVector in terms of Tpetra::MultiVector.
Definition
Thyra_TpetraMultiVector_decl.hpp:32
Thyra::TpetraVector
Concrete Thyra::SpmdVectorBase using Tpetra::Vector.
Definition
Thyra_TpetraVector_decl.hpp:30
Generated by
1.17.0