RTOpPack_RTOpT_decl.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 // RTOp: Interfaces and Support Software for Vector Reduction Transformation
00005 //       Operations
00006 //                Copyright (2006) 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 Roscoe A. Bartlett (rabartl@sandia.gov) 
00026 // 
00027 // ***********************************************************************
00028 // @HEADER
00029 
00030 
00031 #ifndef RTOPPACK_RTOP_NEW_T_DECL_HPP
00032 #define RTOPPACK_RTOP_NEW_T_DECL_HPP
00033 
00034 
00035 #include "RTOpPack_Types.hpp"
00036 #include "Teuchos_Describable.hpp"
00037 
00038 
00039 namespace RTOpPack {
00040 
00041 
00045 
00046 
00049 class ReductTarget : public Teuchos::Describable
00050 {};
00051 
00052 
00160 template<class Scalar>
00161 class RTOpT : public Teuchos::Describable {
00162 public:
00163 
00166 
00168   typedef typename PrimitiveTypeTraits<Scalar,Scalar>::primitiveType
00169   primitive_value_type;
00170 
00172 
00175 
00191   void get_reduct_type_num_entries(
00192     const Ptr<int> &num_values,
00193     const Ptr<int> &num_indexes,
00194     const Ptr<int> &num_chars
00195     ) const
00196     {
00197       get_reduct_type_num_entries_impl(num_values, num_indexes, num_chars);
00198     }
00199 
00210   Teuchos::RCP<ReductTarget> reduct_obj_create() const
00211     {
00212       return reduct_obj_create_impl();
00213     }
00214 
00220   void reduce_reduct_objs(
00221     const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
00222     ) const
00223     {
00224       reduce_reduct_objs_impl( in_reduct_obj, inout_reduct_obj );
00225     }
00226 
00234   void reduct_obj_reinit( const Ptr<ReductTarget> &reduct_obj ) const
00235     {
00236       reduct_obj_reinit_impl(reduct_obj);
00237     }
00238 
00248   void extract_reduct_obj_state(
00249     const ReductTarget &reduct_obj,
00250     const ArrayView<primitive_value_type> &value_data,
00251     const ArrayView<index_type> &index_data,
00252     const ArrayView<char_type> &char_data
00253     ) const
00254     {
00255       extract_reduct_obj_state_impl( reduct_obj,
00256         value_data, index_data, char_data );
00257     }
00258 
00264   void load_reduct_obj_state(
00265     const ArrayView<const primitive_value_type> &value_data,
00266     const ArrayView<const index_type> &index_data,
00267     const ArrayView<const char_type> &char_data,
00268     const Ptr<ReductTarget> &reduct_obj
00269     ) const
00270     {
00271       load_reduct_obj_state_impl( value_data, index_data, char_data, reduct_obj );
00272     }
00273 
00275 
00278 
00288   const std::string op_name() const
00289     {
00290       return op_name_impl();
00291     }
00292 
00293   // 2007/11/14: rabartl: ToDo: Above: change to return std::string.  Don't
00294   // bother deprecating the old function since you can't really do it very
00295   // well.
00296 
00302   bool coord_invariant() const
00303     {
00304       return coord_invariant_impl();
00305     }
00306 
00378   void apply_op(
00379     const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
00380     const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
00381     const Ptr<ReductTarget> &reduct_obj
00382     ) const
00383     {
00384       apply_op_impl(sub_vecs, targ_sub_vecs, reduct_obj);
00385     }
00386 
00388 
00391 
00393   void get_reduct_type_num_entries(
00394     int* num_values, int* num_indexes, int* num_chars
00395     ) const
00396     {
00397       using Teuchos::ptr;
00398       get_reduct_type_num_entries_impl(ptr(num_values),
00399         ptr(num_indexes), ptr(num_chars) );
00400     }
00401 
00403   void reduce_reduct_objs(
00404     const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00405     ) const
00406     {
00407       reduce_reduct_objs_impl( in_reduct_obj, Teuchos::ptr(inout_reduct_obj) );
00408     }
00409 
00411   void reduct_obj_reinit( ReductTarget* reduct_obj ) const
00412     {
00413       reduct_obj_reinit_impl(Teuchos::ptr(reduct_obj));
00414     }
00415 
00417   void extract_reduct_obj_state(
00418     const ReductTarget &reduct_obj,
00419     int num_values, primitive_value_type value_data[],
00420     int num_indexes, index_type index_data[],
00421     int num_chars, char_type char_data[]
00422     ) const
00423     {
00424       using Teuchos::arrayView;
00425       extract_reduct_obj_state_impl( reduct_obj,
00426         arrayView(value_data, num_values), arrayView(index_data, num_indexes),
00427         arrayView(char_data, num_chars) );
00428     }
00429 
00431   void load_reduct_obj_state(
00432     int num_values, const primitive_value_type value_data[],
00433     int num_indexes, const index_type index_data[],
00434     int num_chars, const char_type char_data[],
00435     ReductTarget *reduct_obj
00436     ) const
00437     {
00438       using Teuchos::arrayView;
00439       load_reduct_obj_state_impl( arrayView(value_data, num_values),
00440         arrayView(index_data, num_indexes), arrayView(char_data, num_chars),
00441         Teuchos::ptr(reduct_obj) );
00442     }
00443 
00445   void apply_op(
00446     const int num_vecs, const ConstSubVectorView<Scalar> sub_vecs[],
00447     const int num_targ_vecs, const SubVectorView<Scalar> targ_sub_vecs[],
00448     ReductTarget *reduct_obj
00449     ) const
00450     {
00451       apply_op_impl(
00452         Teuchos::arrayView(sub_vecs, num_vecs),
00453         Teuchos::arrayView(targ_sub_vecs, num_targ_vecs),
00454         Teuchos::ptr(reduct_obj)
00455         );
00456     }
00457 
00459 
00460 protected:
00461 
00464 
00466   virtual void get_reduct_type_num_entries_impl(
00467     const Ptr<int> &num_values,
00468     const Ptr<int> &num_indexes,
00469     const Ptr<int> &num_chars
00470     ) const;
00471 
00473   virtual Teuchos::RCP<ReductTarget> reduct_obj_create_impl() const;
00474 
00476   virtual void reduce_reduct_objs_impl(
00477     const ReductTarget& in_reduct_obj, const Ptr<ReductTarget>& inout_reduct_obj
00478     ) const;
00479 
00481   virtual void reduct_obj_reinit_impl( const Ptr<ReductTarget> &reduct_obj ) const;
00482 
00484   virtual void extract_reduct_obj_state_impl(
00485     const ReductTarget &reduct_obj,
00486     const ArrayView<primitive_value_type> &value_data,
00487     const ArrayView<index_type> &index_data,
00488     const ArrayView<char_type> &char_data
00489     ) const;
00490 
00492   virtual void load_reduct_obj_state_impl(
00493     const ArrayView<const primitive_value_type> &value_data,
00494     const ArrayView<const index_type> &index_data,
00495     const ArrayView<const char_type> &char_data,
00496     const Ptr<ReductTarget> &reduct_obj
00497     ) const;
00498 
00500   virtual const std::string op_name_impl() const;
00501 
00503   virtual bool coord_invariant_impl() const;
00504 
00506   virtual void apply_op_impl(
00507     const ArrayView<const ConstSubVectorView<Scalar> > &sub_vecs,
00508     const ArrayView<const SubVectorView<Scalar> > &targ_sub_vecs,
00509     const Ptr<ReductTarget> &reduct_obj
00510     ) const = 0;
00511 
00513 
00516 
00519   RTOpT( const std::string &op_name_base = "" );
00520 
00522   void setOpNameBase( const std::string &op_name_base );
00523 
00525 
00526 private:
00527 
00528   std::string op_name_;
00529 
00530   void throwNoReductError() const;
00531 
00532 }; // end class RTOpT
00533 
00534 
00535 // 2007/11/14: rabartl: ToDo: Break off an RTOpDefaultBase interface and put
00536 // all default implementation functions in there.
00537 
00538 
00539 // 2007/11/14: rabartl: ToDo: Change functions to accept ArrayView objects and
00540 // depricate raw pointer functions.
00541 
00542 
00543 } // end namespace RTOpPack
00544 
00545 
00546 #endif // RTOPPACK_RTOP_NEW_T_DECL_HPP

Generated on Wed May 12 21:41:16 2010 for Fundamental Vector Reduction/Transformation Operator (RTOp) Interfaces by  doxygen 1.4.7