MathFunc.h
Go to the documentation of this file.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 SCIMATH_MATHFUNC_H
00029 #define SCIMATH_MATHFUNC_H
00030
00031
00032
00033
00034
00035 #include <casacore/casa/aips.h>
00036 #include <casacore/casa/BasicMath/Math.h>
00037 #include <casacore/casa/BasicSL/Constants.h>
00038 #include <casacore/casa/Exceptions/Error.h>
00039 #include <casacore/casa/Arrays/Vector.h>
00040 #include <casacore/casa/BasicSL/String.h>
00041
00042 namespace casacore {
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class MathFuncError : public AipsError
00053 {
00054 public:
00055 MathFuncError() : AipsError("MathFuncError") {}
00056 MathFuncError(const Char *m) : AipsError(m) {}
00057 MathFuncError(const String &m) : AipsError(m) {}
00058
00059 virtual ~MathFuncError() throw() {}
00060 };
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 extern "C" {
00074 Int sphfn(Int *, Int *, Int *, float *, float *, Int *);
00075 }
00076
00077
00078 float sphfn(Int ialf, Int im, float eta);
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 enum FUNCTYPE { UNARY, GAUSSIAN, KB, MOD_KB, SINC, SPHEROIDAL, EXP_SINC };
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 struct FuncId { String name; Vector<double> args;};
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 template<class T>
00153 class MathFunc {
00154 public:
00155
00156
00157
00158 MathFunc(FUNCTYPE);
00159
00160 MathFunc(FUNCTYPE, T cutoff, T arg1 = 1.0e+30, T arg2 = 1.0e+30,
00161 T arg3 = 1.0e+30);
00162 MathFunc(String &, Vector<double> &);
00163 MathFunc(const MathFunc<T>&);
00164 MathFunc(MathFunc<T> *);
00165
00166
00167
00168
00169 virtual ~MathFunc();
00170
00171
00172
00173
00174
00175
00176 MathFunc<T>& operator=(const MathFunc<T>&);
00177
00178
00179
00180
00181 virtual T sup_value() const;
00182
00183
00184
00185
00186 virtual T value(const T &a) const;
00187
00188
00189
00190
00191 static MathFunc<T> *newMathFunc(const MathFunc<T>&);
00192
00193
00194
00195
00196 virtual FuncId id() const;
00197
00198
00199
00200
00201
00202
00203
00204 static T defcutoff() {return defcutoff_p;}
00205
00206 static T defwidth() {return defwidth_p;}
00207
00208 static T defKBwidth() {return defKBwidth_p;}
00209
00210 static T defKBparm() {return defKBparm_p;}
00211
00212 static T defmodKBparm() {return defmodKBparm_p;}
00213
00214 static T defSphcutoff() {return defSphcutoff_p;}
00215
00216 static T defSincparm() {return defSincparm_p;}
00217
00218 static T defSphparm() {return defSphparm_p;}
00219
00220 static T defExpPower() {return defExpPower_p;}
00221
00222 static T defExpScale() {return defExpScale_p;}
00223
00224 protected:
00225
00226
00227
00228 virtual MathFunc<T> * clone() const;
00229
00230
00231
00232
00233 MathFunc();
00234
00235
00236
00237
00238 MathFunc<T> *object;
00239
00240 private:
00241 static T defcutoff_p;
00242 static T defwidth_p;
00243 static T defKBparm_p;
00244 static T defKBwidth_p;
00245 static T defmodKBparm_p;
00246 static T defSphcutoff_p;
00247 static T defSphparm_p;
00248 static T defSincparm_p;
00249 static T defExpPower_p;
00250 static T defExpScale_p;
00251 };
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 template<class T>
00266 class Unary: public MathFunc<T>
00267 {
00268 public:
00269
00270
00271
00272 Unary( T cut = MathFunc<T>::defcutoff());
00273
00274
00275
00276
00277 Unary(const Unary<T>&);
00278
00279 Unary<T>& operator=(const Unary<T>&);
00280
00281 T sup_value() const{ return sup_width;}
00282
00283 T value(const T &) const;
00284
00285
00286
00287
00288 FuncId id() const;
00289
00290 private:
00291 MathFunc<T> * clone() const;
00292
00293 T sup_width;
00294 };
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 template<class T>
00305 class GaussianConv: public MathFunc<T>
00306 {
00307 public:
00308
00309
00310
00311 GaussianConv( T cut = MathFunc<T>::defcutoff(),
00312 T wparm = MathFunc<T>::defwidth());
00313
00314
00315
00316
00317 GaussianConv(const GaussianConv<T>&);
00318
00319 GaussianConv<T>& operator=(const GaussianConv<T>&);
00320
00321 T sup_value() const{ return sup_width;}
00322
00323 T value(const T &) const;
00324
00325
00326
00327
00328 FuncId id() const;
00329
00330 private:
00331 MathFunc<T> * clone() const;
00332
00333 T sup_width, fw2;
00334 const T ln16;
00335 };
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 template<class T>
00346 class KB_Conv: public MathFunc<T>
00347 {
00348 public:
00349
00350
00351 KB_Conv(T cut = MathFunc<T>::defcutoff(),
00352 T wparm = MathFunc<T>::defKBwidth(),
00353 T kbparm = MathFunc<T>::defKBparm());
00354
00355
00356 KB_Conv(const KB_Conv<T> &);
00357
00358 KB_Conv<T>& operator=(const KB_Conv<T>&);
00359
00360 T sup_value() const { return sup_width;}
00361
00362 T value(const T &) const;
00363
00364
00365
00366
00367 FuncId id() const;
00368
00369 private:
00370 MathFunc<T> * clone() const;
00371
00372 T kbparm, fw, sup_width;
00373 };
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 template<class T>
00385 class Mod_KB_Conv: public MathFunc<T>
00386 {
00387 public:
00388
00389 Mod_KB_Conv (T cut = MathFunc<T>::defcutoff(),
00390 T wparm = MathFunc<T>::defKBwidth(),
00391 T kbparm = MathFunc<T>::defKBparm(),
00392 T gwparm = MathFunc<T>::defmodKBparm());
00393
00394
00395 Mod_KB_Conv(const Mod_KB_Conv<T>&);
00396
00397 Mod_KB_Conv<T>& operator=(const Mod_KB_Conv<T>&);
00398
00399 T sup_value() const { return sup_width;}
00400
00401 T value(const T &) const;
00402
00403
00404
00405
00406 FuncId id() const;
00407
00408 private:
00409 MathFunc<T>* clone() const;
00410
00411 T kbparm, gw2, sup_width, widthparm;
00412 const T ln16;
00413 };
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423 template<class T>
00424 class Sinc_Conv: public MathFunc<T>
00425 {
00426 public:
00427
00428 Sinc_Conv(T cut = MathFunc<T>::defSphcutoff(),
00429 T sincparm = MathFunc<T>::defSincparm());
00430
00431 Sinc_Conv(const Sinc_Conv<T>&);
00432
00433 Sinc_Conv<T>& operator=(const Sinc_Conv<T>&);
00434
00435 T sup_value() const { return sup_width;}
00436
00437 T value(const T &) const;
00438
00439
00440
00441
00442 FuncId id() const;
00443
00444 private:
00445 MathFunc<T> * clone() const;
00446
00447 T Sinc_parm, sup_width;
00448 };
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458 template<class T>
00459 class Sph_Conv: public MathFunc<T>
00460
00461
00462
00463 {
00464 public:
00465
00466 Sph_Conv(T cut = MathFunc<T>::defSphcutoff(),
00467 T Sphparm = MathFunc<T>::defSphparm());
00468
00469 Sph_Conv(const Sph_Conv<T>&);
00470
00471 Sph_Conv<T>& operator=(const Sph_Conv<T>&);
00472
00473 T sup_value() const { return sup_width;}
00474
00475 float value(const float &) const;
00476
00477
00478
00479
00480 FuncId id() const;
00481
00482 private:
00483 MathFunc<T> * clone() const;
00484
00485 T sup_width, sphparm;
00486 };
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504 template<class T>
00505 class ExpSincConv: public MathFunc<T>
00506 {
00507 public:
00508
00509
00510
00511 ExpSincConv ( T cut = MathFunc<T>::defcutoff(),
00512 T sincparm = MathFunc<T>::defSincparm(),
00513 T exppow = MathFunc<T>::defExpPower(),
00514 T expscale = MathFunc<T>::defExpScale());
00515
00516 ExpSincConv (const ExpSincConv<T>&);
00517
00518
00519 ExpSincConv<T>& operator=(const ExpSincConv<T>&);
00520
00521
00522 T sup_value() const { return sup_width; }
00523
00524
00525 T value(const T &) const;
00526
00527
00528
00529
00530 FuncId id() const;
00531 private:
00532 MathFunc<T> * clone() const;
00533
00534 T sup_width, scale, exponent, sincpByPi;
00535 };
00536
00537
00538
00539 }
00540
00541 #ifndef CASACORE_NO_AUTO_TEMPLATES
00542 #include <casacore/scimath/Mathematics/MathFunc.tcc>
00543 #endif //# CASACORE_NO_AUTO_TEMPLATES
00544 #endif //AIPS_MATHFUNC_H