1 #ifndef __XIOS_OPERATOR_EXPR_HPP__
2 #define __XIOS_OPERATOR_EXPR_HPP__
18 typedef double (*functionScalar)(double);
19 typedef double (*functionScalarScalar)(double, double);
20 typedef double (*functionScalarScalarScalar)(double, double,double);
35 opScalar[string(
"neg")] = neg_s;
36 opScalar[string(
"cos")] = cos_s;
37 opScalar[string(
"sin")] = sin_s;
38 opScalar[string(
"tan")] = tan_s;
39 opScalar[string(
"exp")] = exp_s;
40 opScalar[string(
"log")] = log_s;
41 opScalar[string(
"log10")] = log10_s;
42 opScalar[string(
"sqrt")] = sqrt_s;
44 opScalarScalar[string(
"add")] = add_ss;
45 opScalarScalar[string(
"minus")] = minus_ss;
46 opScalarScalar[string(
"mult")] = mult_ss;
47 opScalarScalar[string(
"div")] = div_ss;
48 opScalarScalar[string(
"pow")] = pow_ss;
49 opScalarScalar[string(
"eq")] = eq_ss;
50 opScalarScalar[string(
"lt")] = lt_ss;
51 opScalarScalar[string(
"gt")] = gt_ss;
52 opScalarScalar[string(
"le")] = le_ss;
53 opScalarScalar[string(
"ge")] = ge_ss;
54 opScalarScalar[string(
"ne")] = ne_ss;
55 opScalarScalarScalar[string(
"cond")] = cond_sss;
57 opField[string(
"neg")] = neg_f;
58 opField[string(
"cos")] = cos_f;
59 opField[string(
"sin")] = sin_f;
60 opField[string(
"tan")] = tan_f;
61 opField[string(
"exp")] = exp_f;
62 opField[string(
"log")] = log_f;
63 opField[string(
"log10")] = log10_f;
64 opField[string(
"sqrt")] = sqrt_f;
66 opFieldField[string(
"add")] = add_ff;
67 opFieldField[string(
"minus")] = minus_ff;
68 opFieldField[string(
"mult")] = mult_ff;
69 opFieldField[string(
"div")] = div_ff;
70 opFieldField[string(
"pow")] = pow_ff;
71 opFieldField[string(
"eq")] = eq_ff;
72 opFieldField[string(
"lt")] = lt_ff;
73 opFieldField[string(
"gt")] = gt_ff;
74 opFieldField[string(
"le")] = le_ff;
75 opFieldField[string(
"ge")] = ge_ff;
76 opFieldField[string(
"ne")] = ne_ff;
78 opFieldScalar[string(
"add")] = add_fs;
79 opFieldScalar[string(
"minus")] = minus_fs;
80 opFieldScalar[string(
"mult")] = mult_fs;
81 opFieldScalar[string(
"div")] = div_fs;
82 opFieldScalar[string(
"pow")] = pow_fs;
83 opFieldScalar[string(
"eq")] = eq_fs;
84 opFieldScalar[string(
"lt")] = lt_fs;
85 opFieldScalar[string(
"gt")] = gt_fs;
86 opFieldScalar[string(
"le")] = le_fs;
87 opFieldScalar[string(
"ge")] = ge_fs;
88 opFieldScalar[string(
"ne")] = ne_fs;
90 opScalarField[string(
"add")] = add_sf;
91 opScalarField[string(
"minus")] = minus_sf;
92 opScalarField[string(
"mult")] = mult_sf;
93 opScalarField[string(
"div")] = div_sf;
94 opScalarField[string(
"eq")] = eq_sf;
95 opScalarField[string(
"lt")] = lt_sf;
96 opScalarField[string(
"gt")] = gt_sf;
97 opScalarField[string(
"le")] = le_sf;
98 opScalarField[string(
"ge")] = ge_sf;
99 opScalarField[string(
"ne")] = ne_sf;
101 opScalarScalarField[string(
"cond")] = cond_ssf;
102 opScalarFieldScalar[string(
"cond")] = cond_sfs;
103 opScalarFieldField[string(
"cond")] = cond_sff;
104 opFieldScalarScalar[string(
"cond")] = cond_fss;
105 opFieldScalarField[string(
"cond")] = cond_fsf;
106 opFieldFieldScalar[string(
"cond")] = cond_ffs;
107 opFieldFieldField[string(
"cond")] = cond_fff;
114 map<string,double (*)(double)>::iterator it;
115 it = opScalar.find(
id);
116 if (it == opScalar.end())
ERROR(
"functionScalar COperatorExpr::getOpScalar(const string& id)", <<
"unknown operator : " <<
id)
122 map<string,double (*)(double,double)>::iterator it;
123 it = opScalarScalar.find(
id);
124 if (it == opScalarScalar.end())
ERROR(
"functionScalarScalar COperatorExpr::getOpScalarScalar(const string& id)", <<
"unknown operator : " <<
id)
130 map<string,double (*)(double,double,double)>::iterator it;
131 it = opScalarScalarScalar.find(
id);
132 if (it == opScalarScalarScalar.end())
ERROR(
"functionScalarScalarScalar getOpScalarScalarScalar(const string& id)", <<
"unknown operator : " <<
id)
138 map<string,functionField>::iterator it;
139 it = opField.find(
id);
140 if (it == opField.end())
ERROR(
"functionField COperatorExpr::getOpField(const string& id)", <<
"unknown operator : " <<
id)
146 map<string,functionFieldField>::iterator it;
147 it = opFieldField.find(
id);
148 if (it == opFieldField.end())
ERROR(
"dfunctionFieldField COperatorExpr::getOpFieldField(const string& id)", <<
"unknown operator : " <<
id)
154 map<string,functionFieldScalar>::iterator it;
155 it = opFieldScalar.find(
id);
156 if (it == opFieldScalar.end())
ERROR(
"functionFieldScalar COperatorExpr::getOpFieldScalar(const string& id)", <<
"unknown operator : " <<
id)
162 map<string,functionScalarField>::iterator it;
163 it = opScalarField.find(
id);
164 if (it == opScalarField.end())
ERROR(
"functionScalarField COperatorExpr::getOpFieldField(const string& id)", <<
"unknown operator : " <<
id)
170 map<string,functionScalarScalarField>::iterator it;
171 it = opScalarScalarField.find(
id);
172 if (it == opScalarScalarField.end())
ERROR(
"functionScalarScalarField getOpScalarScalarField(const string& id)", <<
"unknown operator : " <<
id)
178 map<string,functionScalarFieldScalar>::iterator it;
179 it = opScalarFieldScalar.find(
id);
180 if (it == opScalarFieldScalar.end())
ERROR(
"functionScalarFieldScalar getOpScalarScalarField(const string& id)", <<
"unknown operator : " <<
id)
186 map<string,functionScalarFieldField>::iterator it;
187 it = opScalarFieldField.find(
id);
188 if (it == opScalarFieldField.end())
ERROR(
"functionScalarFieldField getOpScalarFieldField(const string& id)", <<
"unknown operator : " <<
id)
194 map<string,functionFieldScalarScalar>::iterator it;
195 it = opFieldScalarScalar.find(
id);
196 if (it == opFieldScalarScalar.end())
ERROR(
"functionFieldScalarScalar getOpFieldScalarScalar(const string& id)", <<
"unknown operator : " <<
id)
202 map<string,functionFieldScalarField>::iterator it;
203 it = opFieldScalarField.find(
id);
204 if (it == opFieldScalarField.end())
ERROR(
"functionFieldScalarField getOpFieldScalarField(const string& id)", <<
"unknown operator : " <<
id)
210 map<string,functionFieldFieldScalar>::iterator it;
211 it = opFieldFieldScalar.find(
id);
212 if (it == opFieldFieldScalar.end())
ERROR(
"functionFieldFieldScalar getOpFieldFieldScalar(const string& id)", <<
"unknown operator : " <<
id)
218 map<string,functionFieldFieldField>::iterator it;
219 it = opFieldFieldField.find(
id);
220 if (it == opFieldFieldField.end())
ERROR(
"functionFieldFieldField getOpFieldFieldField(const string& id)", <<
"unknown operator : " <<
id)
242 static inline double neg_s(
double x) {
return -x; }
243 static inline double cos_s(
double x) {
return std::cos(x); }
244 static inline double sin_s(
double x) {
return std::sin(x); }
245 static inline double tan_s(
double x) {
return std::tan(x); }
246 static inline double exp_s(
double x) {
return std::exp(x); }
247 static inline double log_s(
double x) {
return std::log(x); }
248 static inline double log10_s(
double x) {
return std::log10(x); }
249 static inline double sqrt_s(
double x) {
return std::sqrt(x); }
251 static inline double add_ss(
double x,
double y) {
return x + y; }
252 static inline double minus_ss(
double x,
double y) {
return x - y; }
253 static inline double mult_ss(
double x,
double y) {
return x * y; }
254 static inline double div_ss(
double x,
double y) {
return x / y; }
255 static inline double pow_ss(
double x,
double y) {
return std::pow(x,y); }
257 static inline double eq_ss(
double x,
double y)
261 if (xNan && yNan)
return true ;
262 else if (xNan)
return false ;
263 else if (yNan)
return false ;
267 static inline double lt_ss(
double x,
double y) {
return x < y; }
268 static inline double gt_ss(
double x,
double y) {
return x > y; }
269 static inline double le_ss(
double x,
double y) {
return x <= y; }
270 static inline double ge_ss(
double x,
double y) {
return x >= y; }
272 static inline double ne_ss(
double x,
double y)
276 if (xNan && yNan)
return false ;
277 else if (xNan)
return true ;
278 else if (yNan)
return true ;
314 Array<double,1>::const_iterator itx=x.begin(),itxe=x.end();
315 Array<double,1>::iterator itret=ret.begin() ;
319 else return Array<double,1>(x == y);
332 Array<double,1>::const_iterator itx=x.begin(),itxe=x.end();
333 Array<double,1>::iterator itret=ret.begin() ;
337 else return Array<double,1>(x != y);
350 Array<double,1>::const_iterator ity=y.begin(),itye=y.end();
351 Array<double,1>::iterator itret=ret.begin() ;
355 else return Array<double,1>(x == y);
367 Array<double,1>::const_iterator ity=y.begin(),itye=y.end();
368 Array<double,1>::iterator itret=ret.begin() ;
372 else return Array<double,1>(x != y);
374 static inline double cond_sss(
double x,
double y,
double z) {
return (x==0) ? z : y ; }
403 Array<double,1>::const_iterator itx=x.begin(),itxe=x.end();
404 Array<double,1>::iterator itret=ret.begin() ;
406 for(;itx!=itxe;++itx,++itret) *itret=( (*itx==0)?z:y) ;
413 Array<double,1>::const_iterator itx=x.begin(), itxe=x.end(), itz=z.begin();
414 Array<double,1>::iterator itret=ret.begin() ;
415 for(;itx!=itxe;++itx,++itz,++itret) *itret=( (*itx==0)?*itz:y) ;
422 Array<double,1>::const_iterator itx=x.begin(), itxe=x.end(), ity=y.begin() ;
423 Array<double,1>::iterator itret=ret.begin() ;
424 for(;itx!=itxe;++itx,++ity,++itret) *itret=( (*itx==0)?z:*ity) ;
431 Array<double,1>::const_iterator itx=x.begin(), itxe=x.end(), ity=y.begin(), itz=z.begin() ;
432 Array<double,1>::iterator itret=ret.begin() ;
433 for(;itx!=itxe;++itx,++ity,++itz,++itret) *itret=( (*itx==0)?*itz:*ity) ;
static double sin_s(double x)
static CArray< double, 1 > minus_sf(double x, const CArray< double, 1 > &y)
functionFieldScalar getOpFieldScalar(const string &id)
static CArray< double, 1 > cond_sff(double x, const CArray< double, 1 > &y, const CArray< double, 1 > &z)
static CArray< double, 1 > pow_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > cond_sfs(double x, const CArray< double, 1 > &y, double z)
static double gt_ss(double x, double y)
static double eq_ss(double x, double y)
static CArray< double, 1 > add_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > le_sf(double x, const CArray< double, 1 > &y)
static CArray< double, 1 > lt_sf(double x, const CArray< double, 1 > &y)
static double mult_ss(double x, double y)
static double log10_s(double x)
static double lt_ss(double x, double y)
functionFieldScalarScalar getOpFieldScalarScalar(const string &id)
static CArray< double, 1 > mult_sf(double x, const CArray< double, 1 > &y)
map< string, functionScalarFieldScalar > opScalarFieldScalar
map< string, functionFieldScalarField > opFieldScalarField
static double minus_ss(double x, double y)
functionScalarScalarField getOpScalarScalarField(const string &id)
static CArray< double, 1 > eq_sf(double x, const CArray< double, 1 > &y)
static CArray< double, 1 > gt_sf(double x, const CArray< double, 1 > &y)
static CArray< double, 1 > eq_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > mult_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > sqrt_f(const CArray< double, 1 > &x)
functionScalarFieldField getOpScalarFieldField(const string &id)
map< string, functionFieldField > opFieldField
COperatorExpr operatorExpr
static double cond_sss(double x, double y, double z)
static CArray< double, 1 > gt_fs(const CArray< double, 1 > &x, double y)
map< string, functionScalar > opScalar
functionScalarField getOpScalarField(const string &id)
static CArray< double, 1 > mult_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
functionScalarFieldScalar getOpScalarFieldScalar(const string &id)
static double exp_s(double x)
static CArray< double, 1 > ge_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > ne_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static double add_ss(double x, double y)
static CArray< double, 1 > minus_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static double div_ss(double x, double y)
static double tan_s(double x)
static CArray< double, 1 > lt_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static double log_s(double x)
static double ge_ss(double x, double y)
static double le_ss(double x, double y)
static CArray< double, 1 > log_f(const CArray< double, 1 > &x)
static CArray< double, 1 > cos_f(const CArray< double, 1 > &x)
map< string, functionScalarField > opScalarField
map< string, functionFieldScalarScalar > opFieldScalarScalar
static CArray< double, 1 > le_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > sin_f(const CArray< double, 1 > &x)
static CArray< double, 1 > cond_fss(const CArray< double, 1 > &x, double y, double z)
static CArray< double, 1 > minus_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > log10_f(const CArray< double, 1 > &x)
static CArray< double, 1 > ge_sf(double x, const CArray< double, 1 > &y)
functionField getOpField(const string &id)
map< string, functionFieldFieldField > opFieldFieldField
static CArray< double, 1 > gt_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
map< string, functionScalarScalarField > opScalarScalarField
map< string, functionFieldScalar > opFieldScalar
static double ne_ss(double x, double y)
static double cos_s(double x)
static CArray< double, 1 > exp_f(const CArray< double, 1 > &x)
static CArray< double, 1 > div_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > cond_fff(const CArray< double, 1 > &x, const CArray< double, 1 > &y, const CArray< double, 1 > &z)
static double neg_s(double x)
static CArray< double, 1 > ne_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > neg_f(const CArray< double, 1 > &x)
static CArray< double, 1 > div_sf(double x, const CArray< double, 1 > &y)
static CArray< double, 1 > ge_ff(const CArray< double, 1 > &x, const CArray< double, 1 > &y)
static CArray< double, 1 > le_fs(const CArray< double, 1 > &x, double y)
map< string, functionField > opField
map< string, functionScalarScalarScalar > opScalarScalarScalar
functionScalarScalarScalar getOpScalarScalarScalar(const string &id)
functionFieldFieldField getOpFieldFieldField(const string &id)
functionScalar getOpScalar(const string &id)
static CArray< double, 1 > lt_fs(const CArray< double, 1 > &x, double y)
map< string, functionFieldFieldScalar > opFieldFieldScalar
static double sqrt_s(double x)
map< string, functionScalarScalar > opScalarScalar
static double pow_ss(double x, double y)
static CArray< double, 1 > pow_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > add_fs(const CArray< double, 1 > &x, double y)
static CArray< double, 1 > tan_f(const CArray< double, 1 > &x)
static CArray< double, 1 > cond_fsf(const CArray< double, 1 > &x, double y, const CArray< double, 1 > &z)
static CArray< double, 1 > eq_fs(const CArray< double, 1 > &x, double y)
map< string, functionScalarFieldField > opScalarFieldField
functionScalarScalar getOpScalarScalar(const string &id)
functionFieldField getOpFieldField(const string &id)
static CArray< double, 1 > ne_sf(double x, const CArray< double, 1 > &y)
static CArray< double, 1 > div_fs(const CArray< double, 1 > &x, double y)
functionFieldFieldScalar getOpFieldFieldScalar(const string &id)
static CArray< double, 1 > cond_ssf(double x, double y, const CArray< double, 1 > &z)
static CArray< double, 1 > add_sf(double x, const CArray< double, 1 > &y)
functionFieldScalarField getOpFieldScalarField(const string &id)
static CArray< double, 1 > cond_ffs(const CArray< double, 1 > &x, const CArray< double, 1 > &y, double z)