|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // $Id$ 00002 // $Source$ 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_LFAD_LOGICALSPARSETRAITS_HPP 00033 #define SACADO_LFAD_LOGICALSPARSETRAITS_HPP 00034 00035 #include "Sacado_Traits.hpp" 00036 00037 // Forward declarations 00038 namespace Sacado { 00039 namespace LFad { 00040 template <typename T1, typename T2> class LogicalSparse; 00041 } 00042 } 00043 00044 namespace Sacado { 00045 00047 template <typename ValT, typename LogT> 00048 struct Promote< LFad::LogicalSparse<ValT,LogT>, 00049 LFad::LogicalSparse<ValT,LogT> > { 00050 typedef LFad::LogicalSparse<ValT,LogT> type; 00051 }; 00052 00054 template <typename ValT, typename LogT, typename R> 00055 struct Promote< LFad::LogicalSparse<ValT,LogT>, R > { 00056 typedef typename ValueType< LFad::LogicalSparse<ValT,LogT> >::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 LFad::LogicalSparse<value_type,LogT> type; 00061 }; 00062 00064 template <typename L, typename ValT, typename LogT> 00065 struct Promote< L, LFad::LogicalSparse<ValT, LogT> > { 00066 public: 00067 00068 typedef typename ValueType<L>::type value_type_l; 00069 typedef typename ValueType< LFad::LogicalSparse<ValT,LogT> >::type value_type_r; 00070 typedef typename Promote<value_type_l,value_type_r>::type value_type; 00071 00072 typedef LFad::LogicalSparse<value_type,LogT> type; 00073 }; 00074 00076 template <typename ValT, typename LogT> 00077 struct ScalarType< LFad::LogicalSparse<ValT,LogT> > { 00078 typedef typename ScalarType< typename LFad::LogicalSparse<ValT,LogT>::value_type >::type type; 00079 }; 00080 00082 template <typename ValT, typename LogT> 00083 struct ValueType< LFad::LogicalSparse<ValT,LogT> > { 00084 typedef typename LFad::LogicalSparse<ValT,LogT>::value_type type; 00085 }; 00086 00088 template <typename ValT, typename LogT> 00089 struct IsADType< LFad::LogicalSparse<ValT,LogT> > { 00090 static const bool value = true; 00091 }; 00092 00094 template <typename ValT, typename LogT> 00095 struct IsScalarType< LFad::LogicalSparse<ValT,LogT> > { 00096 static const bool value = false; 00097 }; 00098 00100 template <typename ValT, typename LogT> 00101 struct Value< LFad::LogicalSparse<ValT,LogT> > { 00102 typedef typename ValueType< LFad::LogicalSparse<ValT,LogT> >::type value_type; 00103 static const value_type& eval(const LFad::LogicalSparse<ValT,LogT>& x) { 00104 return x.val(); } 00105 }; 00106 00108 template <typename ValT, typename LogT> 00109 struct ScalarValue< LFad::LogicalSparse<ValT,LogT> > { 00110 typedef typename ValueType< LFad::LogicalSparse<ValT,LogT> >::type value_type; 00111 typedef typename ScalarType< LFad::LogicalSparse<ValT,LogT> >::type scalar_type; 00112 static const scalar_type& eval(const LFad::LogicalSparse<ValT,LogT>& x) { 00113 return ScalarValue<value_type>::eval(x.val()); } 00114 }; 00115 00117 template <typename ValT, typename LogT> 00118 struct StringName< LFad::LogicalSparse<ValT,LogT> > { 00119 static std::string eval() { 00120 return std::string("Sacado::LFad::LoginalSparse< ") + 00121 StringName<ValT>::eval() + ", " + 00122 StringName<LogT>::eval() + " >"; } 00123 }; 00124 00126 template <typename ValT, typename LogT> 00127 struct IsEqual< LFad::LogicalSparse<ValT,LogT> > { 00128 static bool eval(const LFad::LogicalSparse<ValT,LogT>& x, 00129 const LFad::LogicalSparse<ValT,LogT>& y) { 00130 return x.isEqualTo(y); 00131 } 00132 }; 00133 00135 template <typename ValT, typename LogT> 00136 struct IsStaticallySized< LFad::LogicalSparse<ValT,LogT> > { 00137 static const bool value = false; 00138 }; 00139 00140 } // namespace Sacado 00141 00142 // Define Teuchos traits classes 00143 #ifdef HAVE_SACADO_TEUCHOS 00144 #include "Teuchos_PromotionTraits.hpp" 00145 #include "Teuchos_ScalarTraits.hpp" 00146 #include "Sacado_Fad_ScalarTraitsImp.hpp" 00147 #include "Teuchos_SerializationTraits.hpp" 00148 00149 namespace Teuchos { 00150 00152 template <typename ValT, typename LogT> 00153 struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>, 00154 Sacado::LFad::LogicalSparse<ValT,LogT> > { 00155 typedef typename Sacado::Promote< Sacado::LFad::LogicalSparse<ValT,LogT>, 00156 Sacado::LFad::LogicalSparse<ValT,LogT> >::type 00157 promote; 00158 }; 00159 00161 template <typename ValT, typename LogT, typename R> 00162 struct PromotionTraits< Sacado::LFad::LogicalSparse<ValT,LogT>, R > { 00163 typedef typename Sacado::Promote< Sacado::LFad::LogicalSparse<ValT,LogT>, R >::type 00164 promote; 00165 }; 00166 00168 template <typename L, typename ValT, typename LogT> 00169 struct PromotionTraits< L, Sacado::LFad::LogicalSparse<ValT,LogT> > { 00170 public: 00171 typedef typename Sacado::Promote< L, Sacado::LFad::LogicalSparse<ValT,LogT> >::type 00172 promote; 00173 }; 00174 00175 // 00176 // These specialization implementations don't work for LFad because 00177 // the value type (e.g., double) is different from the dx() type (e.g., bool) 00178 // 00179 00180 // //! Specializtion of %Teuchos::ScalarTraits 00181 // template <typename ValT, typename LogT> 00182 // struct ScalarTraits< Sacado::LFad::LogicalSparse<ValT,LogT> > : 00183 // public Sacado::Fad::ScalarTraitsImp< Sacado::LFad::LogicalSparse<ValT,LogT> > 00184 // {}; 00185 00186 // //! Specialization of %Teuchos::SerializationTraits 00187 // template <typename Ordinal, typename ValT, typename LogT> 00188 // struct SerializationTraits<Ordinal, Sacado::LFad::LogicalSparse<ValT,LogT> > : 00189 // public Sacado::Fad::SerializationTraitsImp< Ordinal, 00190 // Sacado::LFad::LogicalSparse<ValT,LogT> > 00191 // {}; 00192 } 00193 #endif // HAVE_SACADO_TEUCHOS 00194 00195 #endif // SACADO_LFAD_LOGICALSPARSETRAITS_HPP
1.7.4