|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
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 00129 template <typename ValueT, int Num> 00130 struct IsEqual< ELRCacheFad::SLFad<ValueT,Num> > { 00131 static bool eval(const ELRCacheFad::SLFad<ValueT,Num>& x, 00132 const ELRCacheFad::SLFad<ValueT,Num>& y) { 00133 return x.isEqualTo(y); 00134 } 00135 }; 00136 00138 template <typename ValueT, int Num> 00139 struct IsStaticallySized< ELRCacheFad::SLFad<ValueT,Num> > { 00140 static const bool value = true; 00141 }; 00142 00143 } // namespace Sacado 00144 00145 // Define Teuchos traits classes 00146 #ifdef HAVE_SACADO_TEUCHOS 00147 #include "Teuchos_PromotionTraits.hpp" 00148 #include "Teuchos_ScalarTraits.hpp" 00149 #include "Sacado_Fad_ScalarTraitsImp.hpp" 00150 00151 namespace Teuchos { 00152 00154 template <typename ValueT, int Num> 00155 struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, 00156 Sacado::ELRCacheFad::SLFad<ValueT,Num> > { 00157 typedef typename Sacado::Promote< Sacado::ELRCacheFad::SLFad<ValueT,Num>, 00158 Sacado::ELRCacheFad::SLFad<ValueT,Num> >::type 00159 promote; 00160 }; 00161 00163 template <typename ValueT, int Num, typename R> 00164 struct PromotionTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num>, R > { 00165 typedef typename Sacado::Promote< Sacado::ELRCacheFad::SLFad<ValueT,Num>, 00166 R >::type 00167 promote; 00168 }; 00169 00171 template <typename L, typename ValueT, int Num> 00172 struct PromotionTraits< L, Sacado::ELRCacheFad::SLFad<ValueT,Num> > { 00173 public: 00174 typedef typename Sacado::Promote< L, 00175 Sacado::ELRCacheFad::SLFad<ValueT,Num> >::type 00176 promote; 00177 }; 00178 00180 template <typename ValueT, int Num> 00181 struct ScalarTraits< Sacado::ELRCacheFad::SLFad<ValueT,Num> > : 00182 public Sacado::Fad::ScalarTraitsImp< Sacado::ELRCacheFad::SLFad<ValueT,Num> > 00183 {}; 00184 00186 template <typename Ordinal, typename ValueT, int Num> 00187 struct SerializationTraits<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > : 00188 public Sacado::Fad::SerializationTraitsImp< Ordinal, 00189 Sacado::ELRCacheFad::SLFad<ValueT,Num> > 00190 {}; 00191 00193 template <typename Ordinal, typename ValueT, int Num> 00194 struct ValueTypeSerializer<Ordinal, Sacado::ELRCacheFad::SLFad<ValueT,Num> > : 00195 public Sacado::Fad::SerializerImp< Ordinal, 00196 Sacado::ELRCacheFad::SLFad<ValueT,Num>, 00197 ValueTypeSerializer<Ordinal,ValueT> > 00198 { 00199 typedef Sacado::ELRCacheFad::SLFad<ValueT,Num> FadType; 00200 typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer; 00201 typedef Sacado::Fad::SerializerImp< Ordinal,FadType,ValueSerializer> Base; 00202 ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs, 00203 Ordinal sz = 0) : 00204 Base(vs, sz) {} 00205 }; 00206 } 00207 #endif // HAVE_SACADO_TEUCHOS 00208 00209 #endif // SACADO_ELRCACHEFAD_SLFADTRAITS_HPP
1.7.4