00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef RTOPPACK_ROP_NORM2_HPP
00030 #define RTOPPACK_ROP_NORM2_HPP
00031
00032 #include "RTOpPack_RTOpTHelpers.hpp"
00033
00034 namespace RTOpPack {
00035
00038 template<class Scalar>
00039 class ROpNorm2 : public ROpScalarReductionBase<Scalar> {
00040 typedef Teuchos::ScalarTraits<Scalar> ST;
00041 public:
00043 ROpNorm2() : RTOpT<Scalar>("ROpNorm2") {}
00045 typename Teuchos::ScalarTraits<Scalar>::magnitudeType
00046 operator()(const ReductTarget& reduct_obj ) const
00047 { return ST::magnitude(ST::squareroot(this->getRawVal(reduct_obj))); }
00051 void apply_op(
00052 const int num_vecs, const SubVectorT<Scalar> sub_vecs[]
00053 ,const int num_targ_vecs, const MutableSubVectorT<Scalar> targ_sub_vecs[]
00054 ,ReductTarget *_reduct_obj
00055 ) const
00056 {
00057 using Teuchos::dyn_cast;
00058 ReductTargetScalar<Scalar> &reduct_obj = dyn_cast<ReductTargetScalar<Scalar> >(*_reduct_obj);
00059 RTOP_APPLY_OP_1_0(num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs);
00060 Scalar dot = reduct_obj.get();
00061 if( v0_s == 1 ) {
00062 for( RTOp_index_type i = 0; i < subDim; ++i, ++v0_val )
00063 dot += ST::conjugate(*v0_val) * (*v0_val);
00064 }
00065 else {
00066 for( RTOp_index_type i = 0; i < subDim; ++i, v0_val += v0_s )
00067 dot += ST::conjugate(*v0_val) * (*v0_val);
00068 }
00069 reduct_obj.set(dot);
00070 }
00072 };
00073
00074 }
00075
00076 #endif // RTOPPACK_ROP_NORM2_HPP