|
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_TAYLOR_DTAYLORTRAITS_HPP 00033 #define SACADO_TAYLOR_DTAYLORTRAITS_HPP 00034 00035 #include "Sacado_Traits.hpp" 00036 00037 // Forward declarations 00038 namespace Sacado { 00039 namespace Tay { 00040 template <typename T> class CacheTaylor; 00041 } 00042 } 00043 00044 namespace Sacado { 00045 00047 template <typename T> 00048 class Promote< Tay::CacheTaylor<T>, Tay::CacheTaylor<T> > { 00049 public: 00050 00051 typedef Tay::CacheTaylor<T> type; 00052 }; 00053 00055 template <typename L, typename R> 00056 class Promote< Tay::CacheTaylor<L>, R > { 00057 public: 00058 00059 typedef typename ValueType< Tay::CacheTaylor<L> >::type value_type_l; 00060 typedef typename ValueType<R>::type value_type_r; 00061 typedef typename Promote<value_type_l,value_type_r>::type value_type; 00062 00063 typedef Tay::CacheTaylor<value_type> type; 00064 }; 00065 00067 template <typename L, typename R> 00068 class Promote< L, Tay::CacheTaylor<R> > { 00069 public: 00070 00071 typedef typename ValueType<L>::type value_type_l; 00072 typedef typename ValueType< Tay::CacheTaylor<R> >::type value_type_r; 00073 typedef typename Promote<value_type_l,value_type_r>::type value_type; 00074 00075 typedef Tay::CacheTaylor<value_type> type; 00076 }; 00077 00079 template <typename T> 00080 struct ScalarType< Tay::CacheTaylor<T> > { 00081 typedef typename ScalarType<T>::type type; 00082 }; 00083 00085 template <typename T> 00086 struct ValueType< Tay::CacheTaylor<T> > { 00087 typedef T type; 00088 }; 00089 00091 template <typename T> 00092 struct IsADType< Tay::CacheTaylor<T> > { 00093 static const bool value = true; 00094 }; 00095 00097 template <typename T> 00098 struct IsScalarType< Tay::CacheTaylor<T> > { 00099 static const bool value = false; 00100 }; 00101 00103 template <typename T> 00104 struct Value< Tay::CacheTaylor<T> > { 00105 typedef typename ValueType< Tay::CacheTaylor<T> >::type value_type; 00106 static const value_type& eval(const Tay::CacheTaylor<T>& x) { 00107 return x.val(); } 00108 }; 00109 00111 template <typename T> 00112 struct ScalarValue< Tay::CacheTaylor<T> > { 00113 typedef typename ValueType< Tay::CacheTaylor<T> >::type value_type; 00114 typedef typename ScalarType< Tay::CacheTaylor<T> >::type scalar_type; 00115 static const scalar_type& eval(const Tay::CacheTaylor<T>& x) { 00116 return ScalarValue<value_type>::eval(x.val()); } 00117 }; 00118 00120 template <typename T> 00121 struct StringName< Tay::CacheTaylor<T> > { 00122 static std::string eval() { 00123 return std::string("Sacado::Tay::CacheTaylor< ") + 00124 StringName<T>::eval() + " >"; } 00125 }; 00126 00128 template <typename T> 00129 struct IsEqual< Tay::CacheTaylor<T> > { 00130 static bool eval(const Tay::CacheTaylor<T>& x, 00131 const Tay::CacheTaylor<T>& y) { 00132 return x.isEqualTo(y); 00133 } 00134 }; 00135 00137 template <typename T> 00138 struct IsStaticallySized< Tay::CacheTaylor<T> > { 00139 static const bool value = false; 00140 }; 00141 00142 } // namespace Sacado 00143 00144 // Define Teuchos traits classes 00145 #ifdef HAVE_SACADO_TEUCHOS 00146 #include "Teuchos_PromotionTraits.hpp" 00147 #include "Teuchos_ScalarTraits.hpp" 00148 #include "Sacado_Tay_ScalarTraitsImp.hpp" 00149 #include "Teuchos_SerializationTraits.hpp" 00150 00151 namespace Teuchos { 00152 00154 template <typename ValueT> 00155 struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>, 00156 Sacado::Tay::CacheTaylor<ValueT> > { 00157 typedef typename Sacado::Promote< Sacado::Tay::CacheTaylor<ValueT>, 00158 Sacado::Tay::CacheTaylor<ValueT> >::type 00159 promote; 00160 }; 00161 00163 template <typename ValueT, typename R> 00164 struct PromotionTraits< Sacado::Tay::CacheTaylor<ValueT>, R > { 00165 typedef typename Sacado::Promote< Sacado::Tay::CacheTaylor<ValueT>, R >::type 00166 promote; 00167 }; 00168 00170 template <typename L, typename ValueT> 00171 struct PromotionTraits< L, Sacado::Tay::CacheTaylor<ValueT> > { 00172 public: 00173 typedef typename Sacado::Promote< L, Sacado::Tay::CacheTaylor<ValueT> >::type 00174 promote; 00175 }; 00176 00178 template <typename ValueT> 00179 struct ScalarTraits< Sacado::Tay::CacheTaylor<ValueT> > : 00180 public Sacado::Tay::ScalarTraitsImp< Sacado::Tay::CacheTaylor<ValueT> > 00181 {}; 00182 00184 template <typename Ordinal, typename ValueT> 00185 struct SerializationTraits<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > : 00186 public Sacado::Tay::SerializationTraitsImp< Ordinal, 00187 Sacado::Tay::CacheTaylor<ValueT> > 00188 {}; 00189 00191 template <typename Ordinal, typename ValueT> 00192 struct ValueTypeSerializer<Ordinal, Sacado::Tay::CacheTaylor<ValueT> > : 00193 public Sacado::Tay::SerializerImp< Ordinal, 00194 Sacado::Tay::CacheTaylor<ValueT>, 00195 ValueTypeSerializer<Ordinal,ValueT> > 00196 { 00197 typedef Sacado::Tay::CacheTaylor<ValueT> TayType; 00198 typedef ValueTypeSerializer<Ordinal,ValueT> ValueSerializer; 00199 typedef Sacado::Tay::SerializerImp< Ordinal,TayType,ValueSerializer> Base; 00200 ValueTypeSerializer(const Teuchos::RCP<const ValueSerializer>& vs, 00201 Ordinal sz = 0) : 00202 Base(vs, sz) {} 00203 }; 00204 } 00205 #endif // HAVE_SACADO_TEUCHOS 00206 00207 #endif // SACADO_TAYLOR_DTAYLORTRAITS_HPP
1.7.4