RTOpPack_RTOpT.hpp

00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //      Thyra: Interfaces and Support Code for the Interoperability of Abstract Numerical Algorithms 
00005 //                 Copyright (2004) 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 Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef RTOPPACK_RTOP_NEW_T_HPP
00030 #define RTOPPACK_RTOP_NEW_T_HPP
00031 
00032 #include "RTOpPack_RTOpTDecl.hpp"
00033 #include "Teuchos_Workspace.hpp"
00034 #include "Teuchos_TestForException.hpp"
00035 #include "Teuchos_ScalarTraits.hpp"
00036 
00037 namespace RTOpPack {
00038 
00039 template<class Scalar>
00040 RTOpT<Scalar>::RTOpT( const std::string &op_name_base )
00041   :op_name_(op_name_base + std::string(Teuchos::ScalarTraits<Scalar>::name()))
00042 {}
00043 
00044 // Reduction object functions
00045 
00046 template<class Scalar>
00047 void RTOpT<Scalar>::get_reduct_type_num_entries(
00048   int*   num_values
00049   ,int*  num_indexes
00050   ,int*  num_chars
00051   ) const
00052 {
00053 #ifdef RTOp_DEBUG
00054   TEST_FOR_EXCEPTION( !num_values, std::logic_error, "Error!" );
00055   TEST_FOR_EXCEPTION( !num_indexes, std::logic_error, "Error!"  );
00056   TEST_FOR_EXCEPTION( !num_chars, std::logic_error, "Error!"  );
00057 #endif
00058   *num_values  = 0;
00059   *num_indexes = 0;
00060   *num_chars   = 0;
00061 }
00062 
00063 template<class Scalar>
00064 Teuchos::RefCountPtr<ReductTarget>
00065 RTOpT<Scalar>::reduct_obj_create() const
00066 {
00067   return Teuchos::null;
00068 }
00069 
00070 template<class Scalar>
00071 void RTOpT<Scalar>::reduce_reduct_objs(
00072   const ReductTarget& in_reduct_obj, ReductTarget* inout_reduct_obj
00073   ) const
00074 {
00075   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00076 }
00077 
00078 template<class Scalar>
00079 void RTOpT<Scalar>::reduct_obj_reinit( ReductTarget* reduct_obj ) const
00080 {
00081   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00082 }
00083 
00084 template<class Scalar>
00085 void RTOpT<Scalar>::extract_reduct_obj_state(
00086   const ReductTarget     &reduct_obj
00087   ,int                      num_values
00088   ,primitive_value_type     value_data[]
00089   ,int                      num_indexes
00090   ,index_type               index_data[]
00091   ,int                      num_chars
00092   ,char_type                char_data[]
00093   ) const
00094 {
00095   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00096 }
00097 
00098 template<class Scalar>
00099 void RTOpT<Scalar>::load_reduct_obj_state(
00100   int                            num_values
00101   ,const primitive_value_type    value_data[]
00102   ,int                           num_indexes
00103   ,const index_type              index_data[]
00104   ,int                           num_chars
00105   ,const char_type               char_data[]
00106   ,ReductTarget               *reduct_obj
00107   ) const
00108 {
00109   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00110 }
00111 
00112 // Operator functions
00113 
00114 template<class Scalar>
00115 RTOpT<Scalar>::~RTOpT()
00116 {}
00117 
00118 template<class Scalar>
00119 const char* RTOpT<Scalar>::op_name() const
00120 {
00121   return op_name_.c_str();
00122 }
00123 
00124 template<class Scalar>
00125 RTOpT<Scalar>& RTOpT<Scalar>::operator=(const RTOpT<Scalar>& op)
00126 {
00127   using Teuchos::Workspace;
00128   Teuchos::WorkspaceStore* wss = Teuchos::get_default_workspace_store().get();
00129   int num_values = 0, num_indexes = 0, num_chars = 0;
00130   op.get_op_type_num_entries( &num_values, &num_indexes, &num_chars );
00131   Workspace<primitive_value_type> value_data(wss,num_values,false);
00132   Workspace<index_type>           index_data(wss,num_indexes,false);
00133   Workspace<char_type>            char_data(wss,num_chars,false);
00134   op.extract_op_state(
00135     num_values,   num_values  ? &value_data[0] : NULL
00136     ,num_indexes, num_indexes ? &index_data[0] : NULL
00137     ,num_chars,   num_chars   ? &char_data[0]  : NULL
00138     );
00139   this->load_op_state(
00140     num_values,   num_values  ? &value_data[0] : NULL
00141     ,num_indexes, num_indexes ? &index_data[0] : NULL
00142     ,num_chars,   num_chars   ? &char_data[0]  : NULL
00143     );
00144   return *this;
00145 }
00146 
00147 template<class Scalar>
00148 void RTOpT<Scalar>::get_op_type_num_entries(
00149   int*  num_values
00150   ,int* num_indexes
00151   ,int* num_chars
00152   ) const
00153 {
00154 #ifdef RTOp_DEBUG
00155   TEST_FOR_EXCEPTION( !num_values, std::logic_error, "Error!" );
00156   TEST_FOR_EXCEPTION( !num_indexes, std::logic_error, "Error!"  );
00157   TEST_FOR_EXCEPTION( !num_chars, std::logic_error, "Error!"  );
00158 #endif
00159   *num_values  = 0;
00160   *num_indexes = 0;
00161   *num_chars   = 0;
00162 }
00163 
00164 template<class Scalar>
00165 void RTOpT<Scalar>::extract_op_state(
00166   int                             num_values
00167   ,primitive_value_type           value_data[]
00168   ,int                            num_indexes
00169   ,index_type                     index_data[]
00170   ,int                            num_chars
00171   ,char_type                      char_data[]
00172   ) const
00173 {
00174   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00175 }
00176 
00177 template<class Scalar>
00178 void RTOpT<Scalar>::load_op_state(
00179   int                           num_values
00180   ,const primitive_value_type   value_data[]
00181   ,int                          num_indexes
00182   ,const index_type             index_data[]
00183   ,int                          num_chars
00184   ,const char_type              char_data[]
00185   )
00186 {
00187   TEST_FOR_EXCEPTION(true,std::logic_error,"Error, should not call!");
00188 }
00189 
00190 template<class Scalar>
00191 bool RTOpT<Scalar>::coord_invariant() const
00192 {
00193   return true;
00194 }
00195 
00196 } // end namespace RTOpPack
00197 
00198 #endif // RTOPPACK_RTOP_NEW_T_HPP

Generated on Thu Sep 18 12:39:44 2008 for RTOp : Vector Reduction/Transformation Operators by doxygen 1.3.9.1