Sacado_Tay_TaylorTraits.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 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 
00127 } // namespace Sacado
00128 
00129 #endif // SACADO_TAYLOR_SIMPLETAYLORTRAITS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:19:36 2011 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.6.3