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