RTOpPack_RTOpC.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
00005 //                  Copyright (2003) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 // ///////////////////////////////
00030 // RTOpPack_RTOpC.hpp
00031 
00032 #ifndef RTOPPACK_RTOP_NEW_C_HPP
00033 #define RTOPPACK_RTOP_NEW_C_HPP
00034 
00035 #include "RTOpPack_OldTypes.hpp"
00036 #include "RTOpPack_RTOpT.hpp"
00037 #include "RTOp.h"
00038 #include "Teuchos_dyn_cast.hpp"
00039 
00040 namespace RTOpPack {
00041 
00046 class RTOpC : public RTOpT<RTOp_value_type> {
00047 public:
00048 
00050   typedef RTOp_value_type Scalar;
00052   RTOpC();
00054   ~RTOpC();
00056   RTOp_RTOp& op();
00058   const RTOp_RTOp& op() const;
00060   RTOp_ReductTarget& operator()(ReductTarget& reduct_obj) const;
00062   const RTOp_ReductTarget& operator()(const ReductTarget& reduct_obj) const;
00063 
00066 
00068   void get_reduct_type_num_entries(
00069     int*   num_values
00070     ,int*  num_indexes
00071     ,int*  num_chars
00072     ) const;
00074   Teuchos::RefCountPtr<ReductTarget> reduct_obj_create() const;
00076   void reduce_reduct_objs(
00077     const ReductTarget& _in_reduct_obj, ReductTarget* _inout_reduct_obj
00078     ) const;
00080   void reduct_obj_reinit( ReductTarget* reduct_obj ) const;
00082   void extract_reduct_obj_state(
00083     const ReductTarget     &reduct_obj
00084     ,int                      num_values
00085     ,primitive_value_type     value_data[]
00086     ,int                      num_indexes
00087     ,index_type               index_data[]
00088     ,int                      num_chars
00089     ,char_type                char_data[]
00090     ) const;
00092   void load_reduct_obj_state(
00093     int                            num_values
00094     ,const primitive_value_type    value_data[]
00095     ,int                           num_indexes
00096     ,const index_type              index_data[]
00097     ,int                           num_chars
00098     ,const char_type               char_data[]
00099     ,ReductTarget               *reduct_obj
00100     ) const;
00102   void get_op_type_num_entries(
00103     int*  num_values
00104     ,int* num_indexes
00105     ,int* num_chars
00106     ) const;
00108   void extract_op_state(
00109     int                             num_values
00110     ,primitive_value_type           value_data[]
00111     ,int                            num_indexes
00112     ,index_type                     index_data[]
00113     ,int                            num_chars
00114     ,char_type                      char_data[]
00115     ) const;
00117   void load_op_state(
00118     int                           num_values
00119     ,const primitive_value_type   value_data[]
00120     ,int                          num_indexes
00121     ,const index_type             index_data[]
00122     ,int                          num_chars
00123     ,const char_type              char_data[]
00124     );
00126   bool coord_invariant() const;
00128   const char* op_name() const;
00130   void apply_op(
00131     const int   num_vecs,       const ConstSubVectorView<Scalar>         sub_vecs[]
00132     ,const int  num_targ_vecs,  const SubVectorView<Scalar>  targ_sub_vecs[]
00133     ,ReductTarget *_reduct_obj
00134     ) const;
00135 
00137 
00138 private:
00139 
00140   RTOp_RTOp op_;
00141 
00142 }; // class RTOpC
00143 
00146 class ReductTargetC : public ReductTarget {
00147 public:
00148   inline ReductTargetC( const RTOp_RTOp& op, RTOp_ReductTarget obj );
00149   inline ~ReductTargetC();
00150   inline RTOp_ReductTarget& obj();
00151   inline const RTOp_ReductTarget& obj() const;
00152 private:
00153   const RTOp_RTOp      &op_;
00154   RTOp_ReductTarget    obj_;
00155   ReductTargetC(); // Not defined and not to be called
00156 };
00157 
00158 // ///////////////////////////////
00159 // Inline member functions
00160 
00161 // RTOpC
00162 
00163 inline
00164 RTOp_RTOp& RTOpC::op()
00165 {
00166   return op_;
00167 }
00168 
00169 inline
00170 const RTOp_RTOp& RTOpC::op() const
00171 {
00172   return op_;
00173 }
00174 
00175 inline
00176 RTOp_ReductTarget&
00177 RTOpC::operator()(ReductTarget& reduct_obj) const
00178 {
00179   return Teuchos::dyn_cast<ReductTargetC>(reduct_obj).obj();
00180 }
00181 
00182 inline
00183 const RTOp_ReductTarget&
00184 RTOpC::operator()(const ReductTarget& reduct_obj) const
00185 {
00186   return Teuchos::dyn_cast<const ReductTargetC>(reduct_obj).obj();
00187 }
00188 
00189 // ReductTargetC
00190 
00191 inline
00192 ReductTargetC::ReductTargetC( const RTOp_RTOp& op, RTOp_ReductTarget obj )
00193   : op_(op), obj_(obj)
00194 {} 
00195 
00196 inline
00197 ReductTargetC::~ReductTargetC()
00198 {
00199   if( obj() != RTOp_REDUCT_OBJ_NULL ) {
00200     TEST_FOR_EXCEPTION(
00201       0!=RTOp_reduct_obj_free(&op_,&obj_)
00202       ,UnknownError
00203       ,"RTOpC::reduct_obj_free(...): Error, "
00204       "RTOp_reduct_obj_free(...) returned != 0"
00205       );
00206   }
00207 } 
00208 
00209 inline
00210 RTOp_ReductTarget& ReductTargetC::obj()
00211 {
00212   return obj_;
00213 }
00214 
00215 inline
00216 const RTOp_ReductTarget& ReductTargetC::obj() const
00217 {
00218   return obj_;
00219 }
00220 
00221 } // namespace RTOpPack
00222 
00223 #endif // RTOPPACK_RTOP_NEW_C_HPP

Generated on Thu Sep 18 12:35:20 2008 for MOOCHO (Single Doxygen Collection) by doxygen 1.3.9.1