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_MIN_HPP
00030 #define RTOPPACK_ROP_MIN_HPP
00031
00032 #include "RTOpPack_RTOpTHelpers.hpp"
00033
00034 namespace RTOpPack {
00035
00038 template<class Scalar>
00039 class ROpMin : public ROpScalarReductionBase<Scalar> {
00040 public:
00042 ROpMin() : RTOpT<Scalar>("ROpMin"), ROpScalarReductionBase<Scalar>(+Teuchos::ScalarTraits<Scalar>::rmax()) {}
00044 Scalar operator()(const ReductTarget& reduct_obj ) const { return this->getRawVal(reduct_obj); }
00048 void reduce_reduct_objs(
00049 const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00050 ) const
00051 {
00052 const Scalar in_min_ele = this->getRawVal(in_reduct_obj);
00053 const Scalar inout_min_ele = this->getRawVal(*inout_reduct_obj);
00054 this->setRawVal( in_min_ele < inout_min_ele ? in_min_ele : inout_min_ele, inout_reduct_obj );
00055 }
00057 void apply_op(
00058 const int num_vecs, const SubVectorT<Scalar> sub_vecs[]
00059 ,const int num_targ_vecs, const MutableSubVectorT<Scalar> targ_sub_vecs[]
00060 ,ReductTarget *reduct_obj
00061 ) const
00062 {
00063 RTOP_APPLY_OP_1_0(num_vecs,sub_vecs,num_targ_vecs,targ_sub_vecs);
00064 Scalar min_ele = this->getRawVal(*reduct_obj);
00065 if( v0_s == 1 ) {
00066 for( RTOp_index_type i = 0; i < subDim; ++i ) {
00067 const Scalar &v0_i = *v0_val++;
00068 min_ele = ( v0_i < min_ele ? v0_i : min_ele );
00069 }
00070 }
00071 else {
00072 for( RTOp_index_type i = 0; i < subDim; ++i, v0_val += v0_s ) {
00073 const Scalar &v0_i = *v0_val;
00074 min_ele = ( v0_i < min_ele ? v0_i : min_ele );
00075 }
00076 }
00077 this->setRawVal(min_ele,reduct_obj);
00078 }
00080 };
00081
00082 }
00083
00084 #endif // RTOPPACK_ROP_MIN_HPP