// @HEADER // ***************************************************************************** // Thyra: Interfaces and Support for Abstract Numerical Algorithms // // Copyright 2004 NTESS and the Thyra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef THYRA_TPETRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP #define THYRA_TPETRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP #include "Thyra_TpetraEuclideanScalarProd_decl.hpp" #include "Thyra_TpetraMultiVector.hpp" #include "Thyra_TpetraVector.hpp" namespace Thyra { template void TpetraEuclideanScalarProd::scalarProdsImpl( const MultiVectorBase& X, const MultiVectorBase& Y, const ArrayView& scalarProds_out ) const { typedef Tpetra::MultiVector TMV; Teuchos::RCP X_tpetra = this->getConstTpetraMultiVector(Teuchos::rcpFromRef(X)); Teuchos::RCP Y_tpetra = this->getConstTpetraMultiVector(Teuchos::rcpFromRef(Y)); if (nonnull(X_tpetra) && nonnull(Y_tpetra)) { // Which one do we want transposed? // Tpetra transposes the argument of dot. // Below is the order from TpetraVectorSpace::scalarProdsImpl, // so this would transpose Y. However, Thyra::dots (which calls // the RTOp) transposes the first argument, so scalarProdsImpl // in EuclideanScalarProd transposes X... X_tpetra->dot(*Y_tpetra, scalarProds_out); } else { EuclideanScalarProd::scalarProdsImpl(X, Y, scalarProds_out); } } template Teuchos::RCP > TpetraEuclideanScalarProd:: getConstTpetraMultiVector(const RCP >& mv) const { using Teuchos::rcp_dynamic_cast; typedef Thyra::TpetraMultiVector TMV; typedef Thyra::TpetraVector TV; RCP tmv = rcp_dynamic_cast(mv); if (nonnull(tmv)) { return tmv->getConstTpetraMultiVector(); } RCP tv = rcp_dynamic_cast(mv); if (nonnull(tv)) { return tv->getConstTpetraVector(); } return Teuchos::null; } } // end namespace Thyra #endif // THYRA_EUCLIDEAN_SCALAR_PROD_DEF_HPP