|
Sacado Package Browser (Single Doxygen Collection) Version of the Day
|
00001 // @HEADER 00002 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00003 // 00004 // Sacado Package 00005 // Copyright (2006) Sandia Corporation 00006 // 00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00008 // the U.S. Government retains certain rights in this software. 00009 // 00010 // This library is free software]; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation]; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY]; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library]; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps 00025 // (etphipp@sandia.gov). 00026 // 00027 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00028 // @HEADER 00029 00030 #include "fad_expr_funcs.hpp" 00031 00032 using std::sin; 00033 00034 template <typename T> 00035 void ExprFuncs::mult<T,1>::operator()(const T x[], T& y) const { 00036 y = 00037 x[0]*x[1]; 00038 } 00039 00040 template <typename T> 00041 void ExprFuncs::mult<T,2>::operator()(const T x[], T& y) const { 00042 y = 00043 x[0]*x[1]*x[2]; 00044 } 00045 00046 template <typename T> 00047 void ExprFuncs::mult<T,3>::operator()(const T x[], T& y) const { 00048 y = 00049 x[0]*x[1]*x[2]*x[3]; 00050 } 00051 00052 template <typename T> 00053 void ExprFuncs::mult<T,4>::operator()(const T x[], T& y) const { 00054 y = 00055 x[0]*x[1]*x[2]*x[3]*x[4]; 00056 } 00057 00058 template <typename T> 00059 void ExprFuncs::mult<T,5>::operator()(const T x[], T& y) const { 00060 y = 00061 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]; 00062 } 00063 00064 template <typename T> 00065 void ExprFuncs::mult<T,10>::operator()(const T x[], T& y) const { 00066 y = 00067 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]* 00068 x[8]*x[9]*x[10]; 00069 } 00070 00071 template <typename T> 00072 void ExprFuncs::mult<T,15>::operator()(const T x[], T& y) const { 00073 y = 00074 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]* 00075 x[8]*x[9]*x[10]*x[11]*x[12]*x[13]*x[14]*x[15]; 00076 } 00077 00078 template <typename T> 00079 void ExprFuncs::mult<T,20>::operator()(const T x[], T& y) const { 00080 y = 00081 x[0]*x[1]*x[2]*x[3]*x[4]*x[5]*x[6]*x[7]* 00082 x[8]*x[9]*x[10]*x[11]*x[12]*x[13]*x[14]*x[15]* 00083 x[16]*x[17]*x[18]*x[19]* x[20]; 00084 } 00085 00086 template <typename T> 00087 void ExprFuncs::nest<T,1>::operator()(const T x[], T& y) const { 00088 y = sin(x[0]); 00089 } 00090 00091 template <typename T> 00092 void ExprFuncs::nest<T,2>::operator()(const T x[], T& y) const { 00093 y = sin(sin(x[0])); 00094 } 00095 00096 template <typename T> 00097 void ExprFuncs::nest<T,3>::operator()(const T x[], T& y) const { 00098 y = sin(sin(sin(x[0]))); 00099 } 00100 00101 template <typename T> 00102 void ExprFuncs::nest<T,4>::operator()(const T x[], T& y) const { 00103 y = sin(sin(sin(sin(x[0])))); 00104 } 00105 00106 template <typename T> 00107 void ExprFuncs::nest<T,5>::operator()(const T x[], T& y) const { 00108 y = sin(sin(sin(sin(sin(x[0]))))); 00109 } 00110 00111 template <typename T> 00112 void ExprFuncs::nest<T,10>::operator()(const T x[], T& y) const { 00113 y = sin(sin(sin(sin(sin( 00114 sin(sin(sin(sin(sin(x[0])))))))))); 00115 } 00116 00117 template <typename T> 00118 void ExprFuncs::nest<T,15>::operator()(const T x[], T& y) const { 00119 y = sin(sin(sin(sin(sin( 00120 sin(sin(sin(sin(sin( 00121 sin(sin(sin(sin(sin(x[0]))))))))))))))); 00122 } 00123 00124 template <typename T> 00125 void ExprFuncs::nest<T,20>::operator()(const T x[], T& y) const { 00126 y = sin(sin(sin(sin(sin( 00127 sin(sin(sin(sin(sin( 00128 sin(sin(sin(sin(sin( 00129 sin(sin(sin(sin(sin(x[0])))))))))))))))))))); 00130 } 00131 00132 template <typename T> 00133 void ExprFuncs::add<T,1>::operator()(const T x[], T& y) const { 00134 y = 00135 x[0]+x[1]; 00136 } 00137 00138 template <typename T> 00139 void ExprFuncs::add<T,2>::operator()(const T x[], T& y) const { 00140 y = 00141 x[0]+x[1]+x[2]; 00142 } 00143 00144 template <typename T> 00145 void ExprFuncs::add<T,3>::operator()(const T x[], T& y) const { 00146 y = 00147 x[0]+x[1]+x[2]+x[3]; 00148 } 00149 00150 template <typename T> 00151 void ExprFuncs::add<T,4>::operator()(const T x[], T& y) const { 00152 y = 00153 x[0]+x[1]+x[2]+x[3]+x[4]; 00154 } 00155 00156 template <typename T> 00157 void ExprFuncs::add<T,5>::operator()(const T x[], T& y) const { 00158 y = 00159 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]; 00160 } 00161 00162 template <typename T> 00163 void ExprFuncs::add<T,10>::operator()(const T x[], T& y) const { 00164 y = 00165 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+ 00166 x[8]+x[9]+x[10]; 00167 } 00168 00169 template <typename T> 00170 void ExprFuncs::add<T,15>::operator()(const T x[], T& y) const { 00171 y = 00172 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+ 00173 x[8]+x[9]+x[10]+x[11]+x[12]+x[13]+x[14]+x[15]; 00174 } 00175 00176 template <typename T> 00177 void ExprFuncs::add<T,20>::operator()(const T x[], T& y) const { 00178 y = 00179 x[0]+x[1]+x[2]+x[3]+x[4]+x[5]+x[6]+x[7]+ 00180 x[8]+x[9]+x[10]+x[11]+x[12]+x[13]+x[14]+x[15]+ 00181 x[16]+x[17]+x[18]+x[19]+x[20]; 00182 } 00183 00184 const char* ExprFuncs::mult_names[ExprFuncs::nfunc] = { 00185 "mult1", 00186 "mult2", 00187 "mult3", 00188 "mult4", 00189 "mult5", 00190 "mult10", 00191 "mult15", 00192 "mult20" 00193 }; 00194 00195 const char* ExprFuncs::nest_names[ExprFuncs::nfunc] = { 00196 "nest1", 00197 "nest2", 00198 "nest3", 00199 "nest4", 00200 "nest5", 00201 "nest10", 00202 "nest15", 00203 "nest20" 00204 }; 00205 00206 const char* ExprFuncs::add_names[ExprFuncs::nfunc] = { 00207 "add1", 00208 "add2", 00209 "add3", 00210 "add4", 00211 "add5", 00212 "add10", 00213 "add15", 00214 "add20" 00215 }; 00216 00217 #define INSTANTIATE_FUNCS(TYPE) \ 00218 template struct ExprFuncs::mult< TYPE,1>; \ 00219 template struct ExprFuncs::mult< TYPE,2>; \ 00220 template struct ExprFuncs::mult< TYPE,3>; \ 00221 template struct ExprFuncs::mult< TYPE,4>; \ 00222 template struct ExprFuncs::mult< TYPE,5>; \ 00223 template struct ExprFuncs::mult< TYPE,10>; \ 00224 template struct ExprFuncs::mult< TYPE,15>; \ 00225 template struct ExprFuncs::mult< TYPE,20>; \ 00226 \ 00227 template struct ExprFuncs::nest< TYPE,1>; \ 00228 template struct ExprFuncs::nest< TYPE,2>; \ 00229 template struct ExprFuncs::nest< TYPE,3>; \ 00230 template struct ExprFuncs::nest< TYPE,4>; \ 00231 template struct ExprFuncs::nest< TYPE,5>; \ 00232 template struct ExprFuncs::nest< TYPE,10>; \ 00233 template struct ExprFuncs::nest< TYPE,15>; \ 00234 template struct ExprFuncs::nest< TYPE,20>; \ 00235 \ 00236 template struct ExprFuncs::add< TYPE,1>; \ 00237 template struct ExprFuncs::add< TYPE,2>; \ 00238 template struct ExprFuncs::add< TYPE,3>; \ 00239 template struct ExprFuncs::add< TYPE,4>; \ 00240 template struct ExprFuncs::add< TYPE,5>; \ 00241 template struct ExprFuncs::add< TYPE,10>; \ 00242 template struct ExprFuncs::add< TYPE,15>; \ 00243 template struct ExprFuncs::add< TYPE,20>; 00244 00245 INSTANTIATE_FUNCS(double) 00246 INSTANTIATE_FUNCS(Sacado::Fad::DFad<double>) 00247 INSTANTIATE_FUNCS(Sacado::ELRFad::DFad<double>) 00248 INSTANTIATE_FUNCS(Sacado::CacheFad::DFad<double>) 00249 INSTANTIATE_FUNCS(Sacado::ELRCacheFad::DFad<double>) 00250 INSTANTIATE_FUNCS(Sacado::Fad::SimpleFad<double>) 00251 #ifdef HAVE_ADOLC 00252 INSTANTIATE_FUNCS(adouble) 00253 #endif 00254 00255 #undef INSTANTIATE_FUNCS
1.7.4