00001 // $Id: Sacado_Tay_TaylorTraits.hpp,v 1.1 2007/06/29 22:18:33 etphipp Exp $ 00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/Sacado_Tay_TaylorTraits.hpp,v $ 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 T 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 ScalarValueType< Tay::Taylor<T> > { 00093 typedef typename ScalarValueType< T >::type type; 00094 }; 00095 00097 template <typename T> 00098 struct IsADType< Tay::Taylor<T> > { 00099 static const bool value = true; 00100 }; 00101 00103 template <typename T> 00104 struct IsScalarType< Tay::Taylor<T> > { 00105 static const bool value = false; 00106 }; 00107 00109 template <typename T> 00110 struct Value< Tay::Taylor<T> > { 00111 typedef typename ValueType< Tay::Taylor<T> >::type value_type; 00112 static const value_type& eval(const Tay::Taylor<T>& x) { 00113 return x.val(); } 00114 }; 00115 00116 } // namespace Sacado 00117 00118 #endif // SACADO_TAYLOR_SIMPLETAYLORTRAITS_HPP
1.4.7