Collection of Concrete Vector Reduction/Transformation Operator Implementations  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RTOpPack_ROpWeightedNorm2.hpp
1 // @HEADER
2 // *****************************************************************************
3 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
4 // Operations
5 //
6 // Copyright 2006 NTESS and the RTOp contributors.
7 // SPDX-License-Identifier: BSD-3-Clause
8 // *****************************************************************************
9 // @HEADER
10 
11 #ifndef RTOPPACK_ROP_WEIGHTED_NORM2_HPP
12 #define RTOPPACK_ROP_WEIGHTED_NORM2_HPP
13 
14 #include "RTOpPack_RTOpTHelpers.hpp"
15 
16 
17 namespace RTOpPack {
18 
19 
21 template<class Scalar>
23 {
24 public:
25  void operator()( const Scalar &v0, const Scalar &v1, Scalar &reduct ) const
26  {
27  reduct += v0 * ScalarTraits<Scalar>::conjugate(v1)*v1;
28  }
29 };
30 
31 
35 template<class Scalar>
37  : public ROp_2_ScalarReduction<Scalar, Scalar,
38  ROpWeightedNorm2EleWiseReduction<Scalar> >
39 {
40 public:
45  {
46  this->setOpNameBase("ROpWeightedNorm2");
47  }
49  typename ST::magnitudeType operator()(const ReductTarget& reduct_obj ) const
50  { return ST::magnitude(ST::squareroot(this->getRawVal(reduct_obj))); }
51 };
52 
53 
54 } // namespace RTOpPack
55 
56 
57 #endif // RTOPPACK_ROP_WEIGHTED_NORM2_HPP
Teuchos::ScalarTraits< Scalar > ST
static T squareroot(T x)
Weighted Two (Euclidean) norm reduction operator: result = sqrt( sum( v0[i]*conj(v1[i])*v1[i], i=0...n-1 ) ).
void setOpNameBase(const std::string &op_name_base)
static magnitudeType magnitude(T a)
ST::magnitudeType operator()(const ReductTarget &reduct_obj) const
const ReductScalar & getRawVal(const ReductTarget &reduct_obj) const