Sacado_trad_Traits.hpp

Go to the documentation of this file.
00001 // $Id: Sacado_trad_Traits.hpp,v 1.7 2007/07/25 15:59:07 dmgay Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/Sacado_trad_Traits.hpp,v $ 
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_TRAD_TRAITS_HPP
00033 #define SACADO_TRAD_TRAITS_HPP
00034 
00035 #include "Sacado_Traits.hpp"
00036 
00037 // Forward declarations
00038 namespace Sacado {
00039   namespace Rad {
00040     template <typename T> class ADvar;
00041     template <typename T> class ADvari;
00042   }
00043 }
00044 
00045 namespace Sacado {
00046 
00048   template <typename T>
00049   class Promote< Rad::ADvar<T>, Rad::ADvar<T> > {
00050   public:
00051 
00052     typedef Rad::ADvar<T> type;
00053   };
00054 
00056   template <typename L, typename R>
00057   class Promote< Rad::ADvar<L>, R > {
00058   public:
00059 
00060     typedef typename ValueType< Rad::ADvar<L> >::type value_type_l;
00061     typedef typename ValueType<R>::type value_type_r;
00062     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00063 
00064     typedef Rad::ADvar<value_type> type;
00065   };
00066 
00068   template <typename L, typename R>
00069   class Promote< L, Rad::ADvar<R> > {
00070   public:
00071 
00072     typedef typename ValueType<L>::type value_type_l;
00073     typedef typename ValueType< Rad::ADvar<R> >::type value_type_r;
00074     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00075 
00076     typedef Rad::ADvar<value_type> type;
00077   };
00078 
00080   template <typename T>
00081   struct ScalarType< Rad::ADvar<T> > {
00082     typedef T type;
00083   };
00084 
00086   template <typename T>
00087   struct ScalarType< Rad::ADvari<T> > {
00088     typedef T type;
00089   };
00090 
00092   template <typename T>
00093   struct ValueType< Rad::ADvar<T> > {
00094     typedef T type;
00095   };
00096 
00098   template <typename T>
00099   struct ValueType< Rad::ADvari<T> > {
00100     typedef T type;
00101   };
00102 
00104   template <typename T>
00105   struct ScalarValueType< Rad::ADvar<T> > {
00106     typedef typename ScalarValueType< T >::type type;
00107   };
00108 
00110   template <typename T>
00111   struct ScalarValueType< Rad::ADvari<T> > {
00112     typedef typename ScalarValueType< T >::type type;
00113   };
00114 
00116   template <typename T>
00117   struct IsADType< Rad::ADvar<T> > {
00118     static const bool value = true;
00119   };
00120 
00122   template <typename T>
00123   struct IsADType< Rad::ADvari<T> > {
00124     static const bool value = true;
00125   };
00126 
00128   template <typename T>
00129   struct IsScalarType< Rad::ADvar<T> > {
00130     static const bool value = false;
00131   };
00132 
00134   template <typename T>
00135   struct IsScalarType< Rad::ADvari<T> > {
00136     static const bool value = false;
00137   };
00138 
00140   template <typename T>
00141   struct Value< Rad::ADvar<T> > {
00142     typedef typename ValueType< Rad::ADvar<T> >::type value_type;
00143     static const value_type& eval(const Rad::ADvar<T>& x) { 
00144       return x.val(); }
00145   };
00146 
00148   template <typename T>
00149   struct Value< Rad::ADvari<T> > {
00150     typedef typename ValueType< Rad::ADvari<T> >::type value_type;
00151     static const value_type& eval(const Rad::ADvari<T>& x) { 
00152       return x.val(); }
00153   };
00154 
00156   template <typename T> 
00157   struct MarkConstant< Rad::ADvar<T> > {
00158     static void eval(Rad::ADvar<T>& x) { AD_Const(x); }
00159   };
00160 
00162   template <typename T> 
00163   struct MarkConstant< Rad::ADvari<T> > {
00164     static void eval(Rad::ADvari<T>& x) { AD_Const(x); }
00165   };
00166 
00167 } // namespace Sacado
00168 
00169 #endif // SACADO_TRAD_TRAITS_HPP

Generated on Wed May 12 21:59:07 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7