RTOpPack_SUNDIALS_Helpers.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //      Thyra: Interfaces and Support Code for the Interoperability 
00005 //                   of Abstract Numerical Algorithms 
00006 //                 Copyright (2004) Sandia Corporation
00007 // 
00008 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 // license for use of this work by or on behalf of the U.S. Government.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //  
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA
00025 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 
00030 #ifndef RTOPPACK_RTOP_SUNDIALS_HELPERS_HPP
00031 #define RTOPPACK_RTOP_SUNDIALS_HELPERS_HPP
00032 
00033 #include "RTOpPack_RTOpTHelpers.hpp"
00034 
00035 
00036 
00037 namespace RTOpPack 
00038 {
00039   /**
00040    *
00041    */
00042 #ifdef TRILINOS_6.0
00043 
00044   template<class Scalar>
00045   class RTOpBoolReduceAndTransform 
00046     : public ROpIndexReductionBase<Scalar>,
00047       public ROpScalarTransformationBase<Scalar>
00048 {
00049 
00050   public:
00051     typedef typename RTOpT<Scalar>::primitive_value_type primitive_value_type;
00052     /** */
00053     RTOpBoolReduceAndTransform()
00054       : RTOpT<Scalar>(""), 
00055         ROpIndexReductionBase<Scalar>(1),
00056         ROpScalarTransformationBase<Scalar>() 
00057     {;}
00058 
00059     /** */
00060     virtual ~RTOpBoolReduceAndTransform(){;}
00061 
00062     /** */
00063     index_type operator()(const ReductTarget& reduct_obj ) const 
00064     { return this->getRawVal(reduct_obj); }
00065 
00066 
00067     /** \brief Default implementation here is for a logical AND. */
00068     void reduce_reduct_objs(const ReductTarget& in_reduct_obj, 
00069                             ReductTarget* inout_reduct_obj) const
00070     {
00071       const index_type in_val    = this->getRawVal(in_reduct_obj);
00072       const index_type inout_val = this->getRawVal(*inout_reduct_obj);
00073       this->setRawVal( in_val && inout_val, inout_reduct_obj );
00074     }
00075 
00076   };
00077 
00078 #endif /* TRILINOS_6 */
00079 
00080 }
00081 
00082 /** \brief Use within an apply_op(...) function implementation where num_vecs==3, num_targ_vecs==0.
00083  *
00084  * \ingroup RTOpPack_RTOpTHelpers_grp
00085  */
00086 #define RTOP_APPLY_OP_3_0( NUM_VECS, SUB_VECS, NUM_TARG_VECS, TARG_SUB_VECS ) \
00087   TEST_FOR_EXCEPTION(                                                   \
00088                      (NUM_VECS)!=3 || (SUB_VECS)==NULL                  \
00089                      ,RTOpPack::InvalidNumVecs                          \
00090                      ,"Error, num_vecs="<<(NUM_VECS)<<" not allowed, only num_vecs==3, sub_vecs!=NULL" \
00091                      );                                                 \
00092   TEST_FOR_EXCEPTION(                                                   \
00093                      (NUM_TARG_VECS)!=0 || (TARG_SUB_VECS)!=NULL        \
00094                      ,RTOpPack::InvalidNumTargVecs                      \
00095                      ,"Error, num_targ_vecs="<<(NUM_TARG_VECS)<<" not allowed, only num_targ_vecs==0, targ_sub_vecs==NULL" \
00096                      );                                                 \
00097   TEST_FOR_EXCEPTION(                                                   \
00098                      (SUB_VECS)[0].subDim() != (SUB_VECS)[1].subDim()   \
00099                      || (SUB_VECS)[0].subDim() != (SUB_VECS)[2].subDim() \
00100                      ||(SUB_VECS)[0].globalOffset() != (SUB_VECS)[1].globalOffset() \
00101                      ||(SUB_VECS)[0].globalOffset() != (SUB_VECS)[1].globalOffset() \
00102                      ,IncompatibleVecs                                  \
00103                      ,"Error, num_targ_vecs="<<(NUM_TARG_VECS)<<" not allowed, only num_targ_vecs==0, targ_sub_vecs==NULL" \
00104                      );                                                 \
00105   const RTOpPack::index_type   subDim  = (SUB_VECS)[0].subDim();        \
00106   const Scalar                 *v0_val = (SUB_VECS)[0].values();        \
00107   const ptrdiff_t              v0_s    = (SUB_VECS)[0].stride();        \
00108   const Scalar                 *v1_val = (SUB_VECS)[1].values();        \
00109   const ptrdiff_t              v1_s    = (SUB_VECS)[1].stride();        \
00110   const Scalar                 *v2_val = (SUB_VECS)[2].values();        \
00111   const ptrdiff_t              v2_s    = (SUB_VECS)[2].stride();
00112 
00113 
00114 #endif

Site Contact