|
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_ELRFAD_GENERALFADEXPR_HPP 00033 #define SACADO_ELRFAD_GENERALFADEXPR_HPP 00034 00035 #include "Sacado_ELRFad_GeneralFad.hpp" 00036 00037 namespace Sacado { 00038 00039 namespace ELRFad { 00040 00042 00047 template <typename T, typename Storage> 00048 class Expr< GeneralFad<T,Storage> > : public GeneralFad<T,Storage> { 00049 00050 public: 00051 00053 typedef T value_type; 00054 00056 typedef GeneralFad<T,Storage> base_expr_type; 00057 00059 static const int num_args = 1; 00060 00062 static const bool is_linear = true; 00063 00065 Expr() : 00066 GeneralFad<T,Storage>() {} 00067 00069 00072 Expr(const T & x) : 00073 GeneralFad<T,Storage>(x) {} 00074 00076 00079 Expr(const int sz, const T & x) : 00080 GeneralFad<T,Storage>(sz,x) {} 00081 00083 00088 Expr(const int sz, const int i, const T & x) : 00089 GeneralFad<T,Storage>(sz,i,x) {} 00090 00092 Expr(const Expr& x) : 00093 GeneralFad<T,Storage>(x) {} 00094 00096 template <typename S> Expr(const Expr<S>& x) : 00097 GeneralFad<T,Storage>(x) {} 00098 00100 ~Expr() {} 00101 00103 void computePartials(const T& bar, T partials[]) const { 00104 partials[0] = bar; 00105 } 00106 00108 void getTangents(int i, T dots[]) const { 00109 if (i<this->size()) 00110 dots[0] = this->fastAccessDx(i); 00111 else 00112 dots[0] = 0.0; 00113 } 00114 00116 template <int Arg> 00117 bool isActive() const { return this->size() > 0; } 00118 00120 bool isActive2(int j) const { return this->size() > 0; } 00121 00123 bool isLinear() const { return true; } 00124 00126 template <int Arg> 00127 const T& getTangent(int i) const { return this->fastAccessDx(i); } 00128 00130 const T* getDx(int j) const { return this->dx(); } 00131 00132 const base_expr_type& getArg(int j) const { return *this; } 00133 00134 int numActiveArgs() const { 00135 return this->size() > 0 ? 1 : 0; 00136 } 00137 00139 void computeActivePartials(const T& bar, T *partials) const { 00140 if (this->size() > 0) 00141 partials[0] = bar; 00142 } 00143 00144 }; // class Expr<GeneralFad> 00145 00147 template <typename T, typename S> 00148 struct ExprPromote< GeneralFad<T,S>, T > { 00149 typedef GeneralFad<T,S> type; 00150 }; 00151 00153 template <typename T, typename S> 00154 struct ExprPromote< T, GeneralFad<T,S> > { 00155 typedef GeneralFad<T,S> type; 00156 }; 00157 00158 } // namespace ELRFad 00159 00160 } // namespace Sacado 00161 00162 #include "Sacado_ELRFad_Ops.hpp" 00163 00164 #endif // SACADO_ELRFAD_GENERALFADEXPR_HPP
1.7.4