00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef TABLES_EXPRFUNCNODE_H
00029 #define TABLES_EXPRFUNCNODE_H
00030
00031
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/tables/TaQL/ExprNodeRep.h>
00034 #include <casacore/casa/Quanta/MVAngle.h>
00035
00036 namespace casacore {
00037
00038
00039 class TableExprNodeSet;
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 class TableExprFuncNode : public TableExprNodeMulti
00077 {
00078 public:
00079
00080 enum FunctionType {
00081 piFUNC,
00082 eFUNC,
00083 cFUNC,
00084
00085
00086 near2FUNC,
00087 near3FUNC,
00088 nearabs2FUNC,
00089 nearabs3FUNC,
00090
00091 sinFUNC,
00092 sinhFUNC,
00093 cosFUNC,
00094 coshFUNC,
00095 expFUNC,
00096 logFUNC,
00097 log10FUNC,
00098 sqrtFUNC,
00099 powFUNC,
00100 conjFUNC,
00101
00102 squareFUNC,
00103 cubeFUNC,
00104 minFUNC,
00105 maxFUNC,
00106
00107 normFUNC,
00108 absFUNC,
00109 argFUNC,
00110
00111 realFUNC,
00112 imagFUNC,
00113
00114 intFUNC,
00115
00116 asinFUNC,
00117 acosFUNC,
00118 atanFUNC,
00119 atan2FUNC,
00120 tanFUNC,
00121 tanhFUNC,
00122
00123 signFUNC,
00124 roundFUNC,
00125 floorFUNC,
00126 ceilFUNC,
00127 fmodFUNC,
00128
00129 complexFUNC,
00130
00131 arrsumFUNC,
00132 arrsumsFUNC,
00133 arrproductFUNC,
00134 arrproductsFUNC,
00135 arrsumsqrFUNC,
00136 arrsumsqrsFUNC,
00137
00138 arrminFUNC,
00139 arrminsFUNC,
00140 runminFUNC,
00141 boxminFUNC,
00142 arrmaxFUNC,
00143 arrmaxsFUNC,
00144 runmaxFUNC,
00145 boxmaxFUNC,
00146
00147 arrmeanFUNC,
00148 arrmeansFUNC,
00149 runmeanFUNC,
00150 boxmeanFUNC,
00151 arrvarianceFUNC,
00152 arrvariancesFUNC,
00153 runvarianceFUNC,
00154 boxvarianceFUNC,
00155 arrstddevFUNC,
00156 arrstddevsFUNC,
00157 runstddevFUNC,
00158 boxstddevFUNC,
00159 arravdevFUNC,
00160 arravdevsFUNC,
00161 runavdevFUNC,
00162 boxavdevFUNC,
00163 arrrmsFUNC,
00164 arrrmssFUNC,
00165 runrmsFUNC,
00166 boxrmsFUNC,
00167 arrmedianFUNC,
00168 arrmediansFUNC,
00169 runmedianFUNC,
00170 boxmedianFUNC,
00171 arrfractileFUNC,
00172 arrfractilesFUNC,
00173
00174 anyFUNC,
00175 anysFUNC,
00176 runanyFUNC,
00177 boxanyFUNC,
00178 allFUNC,
00179 allsFUNC,
00180 runallFUNC,
00181 boxallFUNC,
00182
00183 ntrueFUNC,
00184 ntruesFUNC,
00185 nfalseFUNC,
00186 nfalsesFUNC,
00187
00188 arrayFUNC,
00189 transposeFUNC,
00190 resizeFUNC,
00191 diagonalFUNC,
00192
00193 isnanFUNC,
00194 isinfFUNC,
00195 isfiniteFUNC,
00196
00197 isdefFUNC,
00198 isnullFUNC,
00199 iscolFUNC,
00200 iskeyFUNC,
00201
00202 ndimFUNC,
00203 nelemFUNC,
00204
00205 shapeFUNC,
00206
00207 strlengthFUNC,
00208 upcaseFUNC,
00209 downcaseFUNC,
00210 capitalizeFUNC,
00211 trimFUNC,
00212 ltrimFUNC,
00213 rtrimFUNC,
00214 substrFUNC,
00215 replaceFUNC,
00216 regexFUNC,
00217 patternFUNC,
00218 sqlpatternFUNC,
00219
00220 datetimeFUNC,
00221 mjdtodateFUNC,
00222 mjdFUNC,
00223 dateFUNC,
00224 timeFUNC,
00225 yearFUNC,
00226 monthFUNC,
00227 dayFUNC,
00228 cmonthFUNC,
00229 weekdayFUNC,
00230 cdowFUNC,
00231 weekFUNC,
00232 ctodFUNC,
00233 cdateFUNC,
00234 ctimeFUNC,
00235
00236 stringFUNC,
00237
00238 hmsFUNC,
00239
00240 dmsFUNC,
00241
00242 hdmsFUNC,
00243
00244 randFUNC,
00245
00246 rownrFUNC,
00247
00248 rowidFUNC,
00249
00250 iifFUNC,
00251
00252 angdistFUNC,
00253 angdistxFUNC,
00254
00255 conesFUNC,
00256 cones3FUNC,
00257 anyconeFUNC,
00258 anycone3FUNC,
00259 findconeFUNC,
00260 findcone3FUNC,
00261
00262 boolFUNC,
00263
00264 nullarrayFUNC,
00265 marrayFUNC,
00266 arrdataFUNC,
00267 arrmaskFUNC,
00268 negatemaskFUNC,
00269 replmaskedFUNC,
00270 replunmaskedFUNC,
00271 arrflatFUNC,
00272
00273 FirstAggrFunc,
00274 countallFUNC = FirstAggrFunc,
00275 gcountFUNC,
00276 gfirstFUNC,
00277 glastFUNC,
00278
00279 gminFUNC,
00280 gmaxFUNC,
00281 gsumFUNC,
00282 gproductFUNC,
00283 gsumsqrFUNC,
00284 gmeanFUNC,
00285 gvarianceFUNC,
00286 gstddevFUNC,
00287 grmsFUNC,
00288 ganyFUNC,
00289 gallFUNC,
00290 gntrueFUNC,
00291 gnfalseFUNC,
00292
00293 FirstAggrArrayFunc,
00294 gminsFUNC = FirstAggrArrayFunc,
00295 gmaxsFUNC,
00296 gsumsFUNC,
00297 gproductsFUNC,
00298 gsumsqrsFUNC,
00299 gmeansFUNC,
00300 gvariancesFUNC,
00301 gstddevsFUNC,
00302 grmssFUNC,
00303 ganysFUNC,
00304 gallsFUNC,
00305 gntruesFUNC,
00306 gnfalsesFUNC,
00307 LastAggrArrayFunc,
00308 ghistFUNC = LastAggrArrayFunc,
00309
00310 gaggrFUNC,
00311 growidFUNC,
00312 gmedianFUNC,
00313 gfractileFUNC,
00314 gexpridFUNC,
00315 NRFUNC
00316 };
00317
00318
00319 TableExprFuncNode (FunctionType, NodeDataType, ValueType,
00320 const TableExprNodeSet& source,
00321 const Table& = Table());
00322
00323
00324 ~TableExprFuncNode ();
00325
00326
00327
00328 Bool getBool (const TableExprId& id);
00329 Int64 getInt (const TableExprId& id);
00330 Double getDouble (const TableExprId& id);
00331 DComplex getDComplex (const TableExprId& id);
00332 String getString (const TableExprId& id);
00333 TaqlRegex getRegex (const TableExprId& id);
00334 MVTime getDate (const TableExprId& id);
00335
00336
00337
00338
00339
00340
00341 static NodeDataType checkOperands (Block<Int>& dtypeOper,
00342 ValueType& resVT,
00343 Block<Int>& vtypeOper,
00344 FunctionType,
00345 PtrBlock<TableExprNodeRep*>&);
00346
00347
00348
00349
00350 static Double fillUnits (TableExprNodeRep* node,
00351 PtrBlock<TableExprNodeRep*>& nodes,
00352 FunctionType func);
00353
00354
00355
00356
00357 static TableExprNodeRep* fillNode (TableExprFuncNode* thisNode,
00358 PtrBlock<TableExprNodeRep*>& nodes,
00359 const Block<Int>& dtypeOper);
00360
00361
00362
00363 static void fillChildNodes (TableExprFuncNode* thisNode,
00364 PtrBlock<TableExprNodeRep*>& nodes,
00365 const Block<Int>& dtypeOper);
00366
00367
00368 void setScale (Double scale)
00369 { scale_p = scale; }
00370
00371
00372 Double getScale() const
00373 { return scale_p; }
00374
00375
00376
00377 const PtrBlock<TableExprNodeRep*>& operands() const
00378 { return operands_p; }
00379 PtrBlock<TableExprNodeRep*>& rwOperands()
00380 { return operands_p; }
00381 FunctionType funcType() const
00382 { return funcType_p; }
00383 NodeDataType argDataType() const
00384 { return argDataType_p; }
00385
00386
00387
00388 static void getPrintFormat (String& fmt, Int& width, Int& prec,
00389 const PtrBlock<TableExprNodeRep*>& operands,
00390 const TableExprId& id);
00391
00392
00393
00394 static String stringDT (const MVTime& dt, Int prec, MVTime::formatTypes);
00395 static String stringDateTime (const MVTime& dt, Int prec);
00396 static String stringDate (const MVTime& dt);
00397 static String stringTime (const MVTime& dt, Int prec);
00398
00399
00400
00401
00402
00403
00404
00405 static String stringValue (Bool val, const String& fmt, Int width);
00406 static String stringValue (Int64 val, const String& fmt, Int width);
00407 static String stringValue (Double val, const String& fmt,
00408 Int width, Int prec,
00409 const std::pair<int,int>& mvFormat,
00410 const Unit& unit);
00411 static String stringValue (const DComplex& val, const String& fmt,
00412 Int width, Int prec);
00413 static String stringValue (const String& val, const String& fmt,
00414 Int width);
00415 static String stringValue (const MVTime& val, const String& fmt,
00416 Int width,
00417 const std::pair<int,int>& mvFormat);
00418
00419
00420
00421 static String stringAngle (double val, Int prec,
00422 MVAngle::formatTypes type);
00423 static String stringHMS (double val, Int prec);
00424 static String stringDMS (double val, Int prec);
00425
00426
00427
00428
00429 static std::pair<int,int> getMVFormat (const String& fmt);
00430
00431
00432 static double angdist (double ra1, double dec1, double ra2, double dec2)
00433 { return acos (sin(dec1)*sin(dec2) + cos(dec1)*cos(dec2)*cos(ra1-ra2)); }
00434
00435
00436 static Int64 string2Int (const String&);
00437 static Double string2Real (const String&);
00438 static DComplex string2Complex (const String&);
00439 static Bool string2Bool (const String&);
00440
00441 private:
00442
00443
00444 void tryToConst();
00445
00446
00447
00448 static const Unit& makeEqualUnits (PtrBlock<TableExprNodeRep*>& nodes,
00449 uInt starg, uInt endarg);
00450
00451
00452 FunctionType funcType_p;
00453 NodeDataType argDataType_p;
00454 Double scale_p;
00455
00456 Table table_p;
00457 };
00458
00459
00460 }
00461
00462 #endif