Thyra Version of the Day
Loading...
Searching...
No Matches
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
18namespace Thyra {
19
20
21template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
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 {
42 }
43}
44
45
46template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
50{
51 using Teuchos::rcp_dynamic_cast;
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
virtual void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds) const
Simply calls dots(X,Y,scalar_prods).
Interface for a collection of column vectors called a multi-vector.
Extends concrete implementation of a Euclidean scalar product for specifically Tpetra vectors/multive...
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...
Concrete implementation of Thyra::MultiVector in terms of Tpetra::MultiVector.
Concrete Thyra::SpmdVectorBase using Tpetra::Vector.
T_To & dyn_cast(T_From &from)