Sacado_ELRCacheFad_SLFadTraits.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 // @HEADER
00031 
00032 #ifndef SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
00033 #define SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
00034 
00035 #include "Sacado_Traits.hpp"
00036 #include <sstream>
00037 
00038 // Forward declarations
00039 namespace Sacado {
00040   namespace ELRCacheFad {
00041     template <typename T, int Num> class SLFad;
00042   }
00043 }
00044 
00045 namespace Sacado {
00046 
00048   template <typename ValueT, int Num>
00049   struct Promote< ELRCacheFad::SLFad<ValueT,Num>, 
00050       ELRCacheFad::SLFad<ValueT,Num> > {
00051     typedef ELRCacheFad::SLFad<ValueT,Num> type;
00052   };
00053 
00055   template <typename ValueT, int Num, typename R>
00056   struct Promote< ELRCacheFad::SLFad<ValueT,Num>, R > {
00057     typedef typename ValueType< ELRCacheFad::SLFad<ValueT,Num> >::type value_type_l;
00058     typedef typename ValueType<R>::type value_type_r;
00059     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00060 
00061     typedef ELRCacheFad::SLFad<value_type,Num> type;
00062   };
00063 
00065   template <typename L, typename ValueT, int Num>
00066   struct Promote< L, ELRCacheFad::SLFad<ValueT, Num> > {
00067   public:
00068 
00069     typedef typename ValueType<L>::type value_type_l;
00070     typedef typename ValueType< ELRCacheFad::SLFad<ValueT,Num> >::type value_type_r;
00071     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00072 
00073     typedef ELRCacheFad::SLFad<value_type,Num> type;
00074   };
00075 
00077   template <typename ValueT, int Num>
00078   struct ScalarType< ELRCacheFad::SLFad<ValueT,Num> > {
00079     typedef typename ELRCacheFad::SLFad<ValueT,Num>::ScalarT type;
00080   };
00081 
00083   template <typename ValueT, int Num>
00084   struct ValueType< ELRCacheFad::SLFad<ValueT,Num> > {
00085     typedef ValueT type;
00086   };
00087 
00089   template <typename ValueT, int Num>
00090   struct IsADType< ELRCacheFad::SLFad<ValueT,Num> > {
00091     static const bool value = true;
00092   };
00093 
00095   template <typename ValueT, int Num>
00096   struct IsScalarType< ELRCacheFad::SLFad<ValueT,Num> > {
00097     static const bool value = false;
00098   };
00099 
00101   template <typename ValueT, int Num>
00102   struct Value< ELRCacheFad::SLFad<ValueT,Num> > {
00103     typedef typename ValueType< ELRCacheFad::SLFad<ValueT,Num> >::type value_type;
00104     static const value_type& eval(const ELRCacheFad::SLFad<ValueT,Num>& x) { 
00105       return x.val(); }
00106   };
00107 
00109   template <typename ValueT, int Num>
00110   struct ScalarValue< ELRCacheFad::SLFad<ValueT,Num> > {
00111     typedef typename ValueType< ELRCacheFad::SLFad<ValueT,Num> >::type value_type;
00112     typedef typename ScalarType< ELRCacheFad::SLFad<ValueT,Num> >::type scalar_type;
00113     static const scalar_type& eval(const ELRCacheFad::SLFad<ValueT,Num>& x) { 
00114       return ScalarValue<value_type>::eval(x.val()); }
00115   };
00116 
00118   template <typename ValueT, int Num>
00119   struct StringName< ELRCacheFad::SLFad<ValueT,Num> > {
00120     static std::string eval() { 
00121       std::stringstream ss;
00122       ss << "Sacado::ELRCacheFad::SLFad< " 
00123    << StringName<ValueT>::eval() << ", " << Num << " >";
00124       return ss.str(); 
00125     }
00126   };
00127 
00128 } // namespace Sacado
00129 
00130 // Define Teuchos traits classes
00131 #ifdef HAVE_SACADO_TEUCHOS
00132 #include "Teuchos_PromotionTraits.hpp"
00133 #include "Teuchos_ScalarTraits.hpp"
00134 #include "Sacado_Fad_ScalarTraitsImp.hpp"
00135 
00136 namespace Teuchos {
00137 
00139   template <typename ValueT, int Num>
00140   struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, 
00141         Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
00142     typedef typename Sacado::Promote< Sacado::ELRCacheFad::SLFad<ValueT,Num>,
00143               Sacado::ELRCacheFad::SLFad<ValueT,Num> >::type
00144     promote;
00145   };
00146 
00148   template <typename ValueT, int Num, typename R>
00149   struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, R > {
00150     typedef typename Sacado::Promote< Sacado::ELRCacheFad::SLFad<ValueT,Num>,
00151               R >::type 
00152     promote;
00153   };
00154 
00156   template <typename L, typename ValueT, int Num>
00157   struct PromotionTraits< L, Sacado::ELRCacheFad::SLFad<ValueT,Num> > {
00158   public:
00159     typedef typename Sacado::Promote< L, 
00160               Sacado::ELRCacheFad::SLFad<ValueT,Num> >::type 
00161     promote;
00162   };
00163 
00165   template <typename ValueT, int Num>
00166   struct ScalarTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num> > :
00167     public Sacado::Fad::ScalarTraitsImp< Sacado::ELRCacheFad::SLFad<ValueT,Num> >
00168   {};
00169 }
00170 #endif // HAVE_SACADO_TEUCHOS
00171 
00172 #endif // SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:19:31 2011 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.6.3