Sacado_ScalarFlopCounterTraits.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 //
00031 // The forward-mode AD classes in Sacado are a derivative work of the
00032 // expression template classes in the Fad package by Nicolas Di Cesare.  
00033 // The following banner is included in the original Fad source code:
00034 //
00035 // ************ DO NOT REMOVE THIS BANNER ****************
00036 //
00037 //  Nicolas Di Cesare <Nicolas.Dicesare@ann.jussieu.fr>
00038 //  http://www.ann.jussieu.fr/~dicesare
00039 //
00040 //            CEMRACS 98 : C++ courses, 
00041 //         templates : new C++ techniques 
00042 //            for scientific computing 
00043 // 
00044 //********************************************************
00045 //
00046 //  NumericalTraits class to illustrate TRAITS
00047 //
00048 //********************************************************
00049 // @HEADER
00050 
00051 #ifndef SACADO_SCALARFLOPCOUNTERTRAITS_HPP
00052 #define SACADO_SCALARFLOPCOUNTERTRAITS_HPP
00053 
00054 #include "Sacado_Traits.hpp"
00055 
00056 // Forward declarations
00057 namespace Sacado {
00058   namespace FlopCounterPack {
00059     template <typename T> class ScalarFlopCounter;
00060   }
00061 }
00062 
00063 namespace Sacado {
00064 
00066   template <typename ScalarT>
00067   struct Promote< FlopCounterPack::ScalarFlopCounter<ScalarT>, 
00068       FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00069     typedef FlopCounterPack::ScalarFlopCounter<ScalarT> type;
00070   };
00071 
00073   template <typename ScalarT, typename R>
00074   struct Promote< FlopCounterPack::ScalarFlopCounter<ScalarT>, R > {
00075     typedef typename ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> >::type value_type_l;
00076     typedef typename ValueType<R>::type value_type_r;
00077     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00078 
00079     typedef FlopCounterPack::ScalarFlopCounter<value_type> type;
00080   };
00081 
00083   template <typename L, typename ScalarT>
00084   struct Promote< L, FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00085   public:
00086 
00087     typedef typename ValueType<L>::type value_type_l;
00088     typedef typename ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> >::type value_type_r;
00089     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00090 
00091     typedef FlopCounterPack::ScalarFlopCounter<value_type> type;
00092   };
00093 
00095   template <typename ScalarT>
00096   struct ScalarType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00097     typedef typename ScalarType<ScalarT>::type type;
00098   };
00099 
00101   template <typename ScalarT>
00102   struct ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00103     typedef ScalarT type;
00104   };
00105 
00107   template <typename ScalarT>
00108   struct IsADType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00109     static const bool value = true;
00110   };
00111 
00113   template <typename ScalarT>
00114   struct IsScalarType< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00115     static const bool value = false;
00116   };
00117 
00119   template <typename ScalarT>
00120   struct Value< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00121     typedef typename ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> >::type value_type;
00122     static const value_type& eval(const FlopCounterPack::ScalarFlopCounter<ScalarT>& x) { 
00123       return x.val(); }
00124   };
00125 
00127   template <typename ScalarT>
00128   struct ScalarValue< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00129     typedef typename ValueType< FlopCounterPack::ScalarFlopCounter<ScalarT> >::type value_type;
00130     typedef typename ScalarType< FlopCounterPack::ScalarFlopCounter<ScalarT> >::type scalar_type;
00131     static const scalar_type& eval(const FlopCounterPack::ScalarFlopCounter<ScalarT>& x) { 
00132       return ScalarValue<value_type>::eval(x.val()); }
00133   };
00134 
00136   template <typename ScalarT>
00137   struct StringName< FlopCounterPack::ScalarFlopCounter<ScalarT> > {
00138     static std::string eval() { 
00139       return std::string("Sacado::FlopCounterPack::ScalarFlopCounter< ") + 
00140   StringName<ScalarT>::eval() + " >"; }
00141   };
00142 
00143 } // namespace Sacado
00144 
00145 #endif // SACADO_SCALARFLOPCOUNTERTRAITS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:19:34 2011 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.6.3