Sacado_Fad_SLFadTraits.hpp

Go to the documentation of this file.
00001 // $Id: Sacado_Fad_SLFadTraits.hpp,v 1.4 2007/02/22 22:09:33 dmgay Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/src/Sacado_Fad_SLFadTraits.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_FAD_SLFADTRAITS_HPP
00033 #define SACADO_FAD_SLFADTRAITS_HPP
00034 
00035 #include "Sacado_Traits.hpp"
00036 
00037 // Forward declarations
00038 namespace Sacado {
00039   namespace Fad {
00040     template <typename T1, int Num, typename T2> class SLFad;
00041   }
00042 }
00043 
00044 namespace Sacado {
00045 
00047   template <typename ValueT, int Num, typename ScalarT>
00048   struct Promote< Fad::SLFad<ValueT,Num,ScalarT>, 
00049       Fad::SLFad<ValueT,Num,ScalarT> > {
00050     typedef Fad::SLFad<ValueT,Num,ScalarT> type;
00051   };
00052 
00054   template <typename ValueT, int Num, typename ScalarT, typename R>
00055   struct Promote< Fad::SLFad<ValueT,Num,ScalarT>, R > {
00056     typedef typename ValueType< Fad::SLFad<ValueT,Num,ScalarT> >::type value_type_l;
00057     typedef typename ValueType<R>::type value_type_r;
00058     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00059 
00060     typedef Fad::SLFad<value_type,Num,ScalarT> type;
00061   };
00062 
00064   template <typename L, typename ValueT, int Num, typename ScalarT>
00065   struct Promote< L, Fad::SLFad<ValueT, Num, ScalarT> > {
00066   public:
00067 
00068     typedef typename ValueType<L>::type value_type_l;
00069     typedef typename ValueType< Fad::SLFad<ValueT,Num,ScalarT> >::type value_type_r;
00070     typedef typename Promote<value_type_l,value_type_r>::type value_type;
00071 
00072     typedef Fad::SLFad<value_type,Num,ScalarT> type;
00073   };
00074 
00076   template <typename ValueT, int Num, typename ScalarT>
00077   struct ScalarType< Fad::SLFad<ValueT,Num,ScalarT> > {
00078     typedef ScalarT type;
00079   };
00080 
00082   template <typename ValueT, int Num, typename ScalarT>
00083   struct ValueType< Fad::SLFad<ValueT,Num,ScalarT> > {
00084     typedef ValueT type;
00085   };
00086 
00088   template <typename ValueT, int Num, typename ScalarT>
00089   struct ScalarValueType< Fad::SLFad<ValueT,Num,ScalarT> > {
00090     typedef typename ScalarValueType< ValueT >::type type;
00091   };
00092 
00094   template <typename ValueT, int Num, typename ScalarT>
00095   struct IsADType< Fad::SLFad<ValueT,Num,ScalarT> > {
00096     static const bool value = true;
00097   };
00098 
00100   template <typename ValueT, int Num, typename ScalarT>
00101   struct IsScalarType< Fad::SLFad<ValueT,Num,ScalarT> > {
00102     static const bool value = false;
00103   };
00104 
00106   template <typename ValueT, int Num, typename ScalarT>
00107   struct Value< Fad::SLFad<ValueT,Num,ScalarT> > {
00108     typedef typename ValueType< Fad::SLFad<ValueT,Num,ScalarT> >::type value_type;
00109     static const value_type& eval(const Fad::SLFad<ValueT,Num,ScalarT>& x) { 
00110       return x.val(); }
00111   };
00112 
00113 } // namespace Sacado
00114 
00115 #endif // SACADO_FAD_SFADTRAITS_HPP

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