44 #ifndef THYRA_DIAGONAL_SCALAR_PROD_DEF_HPP 45 #define THYRA_DIAGONAL_SCALAR_PROD_DEF_HPP 48 #include "Thyra_DiagonalScalarProd_decl.hpp" 49 #include "Thyra_DetachedSpmdVectorView.hpp" 50 #include "Thyra_SpmdVectorSpaceBase.hpp" 51 #include "Thyra_AssertOp.hpp" 52 #include "Teuchos_CommHelpers.hpp" 61 template<
class Scalar>
66 template<
class Scalar>
70 s_diag_ = s_diag.assert_not_null();
77 template<
class Scalar>
84 template<
class Scalar>
87 const ArrayView<Scalar> &scalarProds_out )
const 91 typedef Teuchos::ScalarTraits<Scalar> ST;
97 *s_diag_->space(), *Y.
range() );
102 TEUCHOS_ASSERT_EQUALITY( as<Ordinal>(scalarProds_out.size()), m );
107 const RCP<const Teuchos::Comm<Ordinal> > comm = s_diag.
spmdSpace()->getComm();
109 for (
Ordinal j = 0; j < m; ++j) {
114 Scalar scalarProd_j = ST::zero();
116 for (
Ordinal i = 0; i < x.subDim(); ++i) {
117 scalarProd_j += ST::conjugate(x[i]) * s_diag[i] * y[i];
120 if (!is_null(comm)) {
121 Scalar g_scalarProd_j = 0.0;
122 Teuchos::reduceAll<Ordinal,Scalar>(
123 *comm, Teuchos::REDUCE_SUM,
125 Teuchos::outArg(g_scalarProd_j)
127 scalarProds_out[j] = g_scalarProd_j;
130 scalarProds_out[j] = scalarProd_j;
138 template<
class Scalar>
139 RCP<const LinearOpBase<Scalar> >
142 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"ToDo: Implement when needed!")
143 return Teuchos::null;
150 #endif // THYRA_DIAGONAL_SCALAR_PROD_DEF_HPP #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.
const RCP< const SpmdVectorSpaceBase< Scalar > > spmdSpace() const
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Interface for a collection of column vectors called a multi-vector.
RCP< const VectorBase< Scalar > > col(Ordinal j) const
Calls colImpl().
Abstract interface for finite-dimensional dense vectors.
virtual void scalarProdsImpl(const MultiVectorBase< Scalar > &X, const MultiVectorBase< Scalar > &Y, const ArrayView< Scalar > &scalarProds_out) const
virtual bool isEuclideanImpl() const
Returns false.
virtual RCP< const VectorSpaceBase< Scalar > > domain() const =0
Return a smart pointer for the domain space for this operator.
Create an explicit detached non-mutable (const) view of all of the local elements on this process of ...
RCP< const LinearOpBase< Scalar > > getLinearOpImpl() const
void initialize(const RCP< const VectorBase< Scalar > > &s_diag)