Sacado_Fad_DMFadTraits.hpp

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

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