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
00030 #ifndef RTOPPACK_ROP_MAX_HPP
00031 #define RTOPPACK_ROP_MAX_HPP
00032
00033 #include "RTOpPack_RTOpTHelpers.hpp"
00034
00035 namespace RTOpPack {
00036
00039 template<class Scalar>
00040 class ROpMax : public ROpScalarReductionBase<Scalar> {
00041 public:
00043 ROpMax() : RTOpT<Scalar>("ROpMax"), ROpScalarReductionBase<Scalar>(-Teuchos::ScalarTraits<Scalar>::rmax()) {}
00045 Scalar operator()(const ReductTarget& reduct_obj ) const { return this->getRawVal(reduct_obj); }
00049 void reduce_reduct_objs(
00050 const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00051 ) const
00052 {
00053 const Scalar in_max_ele = this->getRawVal(in_reduct_obj);
00054 const Scalar inout_max_ele = this->getRawVal(*inout_reduct_obj);
00055 this->setRawVal( in_max_ele > inout_max_ele ? in_max_ele : inout_max_ele, inout_reduct_obj );
00056 }
00058 void apply_op(
00059 const int num_vecs, const ConstSubVectorView<Scalar> sub_vecs[]
00060 ,const int num_targ_vecs, const SubVectorView<Scalar> targ_sub_vecs[]
00061 ,ReductTarget *reduct_obj
00062 ) const
00063 {
00064 RTOP_APPLY_OP_1_0(num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs);
00065 Scalar max_ele = this->getRawVal(*reduct_obj);
00066 if( v0_s == 1 ) {
00067 for( Teuchos_Index i = 0; i < subDim; ++i ) {
00068 const Scalar &v0_i = *v0_val++;
00069 max_ele = ( v0_i > max_ele ? v0_i : max_ele );
00070 }
00071 }
00072 else {
00073 for( Teuchos_Index i = 0; i < subDim; ++i, v0_val += v0_s ) {
00074 const Scalar &v0_i = *v0_val;
00075 max_ele = ( v0_i > max_ele ? v0_i : max_ele );
00076 }
00077 }
00078 this->setRawVal(max_ele,reduct_obj);
00079 }
00081 };
00082
00083 }
00084
00085 #endif // RTOPPACK_ROP_MAX_HPP