18 const int FourierFuncType = 1;
19 const int PolyFuncType = 2;
20 const int ArrheniusFuncType = 3;
21 const int GaussianFuncType = 4;
22 const int SumFuncType = 20;
23 const int DiffFuncType = 25;
24 const int ProdFuncType = 30;
25 const int RatioFuncType = 40;
26 const int PeriodicFuncType = 50;
27 const int CompositeFuncType = 60;
28 const int TimesConstantFuncType = 70;
29 const int PlusConstantFuncType = 80;
30 const int SinFuncType = 100;
31 const int CosFuncType = 102;
32 const int ExpFuncType = 104;
33 const int PowFuncType = 106;
34 const int ConstFuncType = 110;
65 virtual int ID()
const;
71 virtual doublereal
eval(doublereal t)
const;
90 virtual doublereal isProportional(
Func1& other);
92 virtual std::string write(std::string arg)
const;
99 void setC(doublereal c);
108 virtual int order()
const;
111 Func1& func1_dup()
const;
114 Func1& func2_dup()
const;
116 Func1* parent()
const;
119 void setParent(
Func1* p);
134 Func1& newTimesConstFunction(
Func1& f1, doublereal c);
135 Func1& newPlusConstFunction(
Func1& f1, doublereal c);
145 Sin1(doublereal omega = 1.0) :
156 Sin1& operator=(
const Sin1& right) {
157 if (&right ==
this) {
160 Func1::operator=(right);
166 return (
Func1&) *nfunc;
169 virtual std::string write(std::string arg)
const;
171 virtual int ID()
const {
175 virtual doublereal
eval(doublereal t)
const {
186 Cos1(doublereal omega = 1.0) :
195 Cos1& operator=(
const Cos1& right) {
196 if (&right ==
this) {
199 Func1::operator=(right);
205 return (
Func1&) *nfunc;
207 virtual std::string write(std::string arg)
const;
208 virtual int ID()
const {
211 virtual doublereal
eval(doublereal t)
const {
223 Exp1(doublereal A = 1.0) :
232 Exp1& operator=(
const Exp1& right) {
233 if (&right ==
this) {
236 Func1::operator=(right);
239 virtual std::string write(std::string arg)
const;
240 virtual int ID()
const {
244 return *(
new Exp1(m_c));
246 virtual doublereal
eval(doublereal t)
const {
268 Pow1& operator=(
const Pow1& right) {
269 if (&right ==
this) {
272 Func1::operator=(right);
275 virtual std::string write(std::string arg)
const;
276 virtual int ID()
const {
280 return *(
new Pow1(m_c));
282 virtual doublereal
eval(doublereal t)
const {
309 if (&right ==
this) {
312 Func1::operator=(right);
316 virtual std::string write(std::string arg)
const;
317 virtual int ID()
const {
318 return ConstFuncType;
320 virtual doublereal
eval(doublereal t)
const {
324 return *(
new Const1(m_c));
345 m_f1->setParent(
this);
346 m_f2->setParent(
this);
356 *
this = Sum1::operator=(b);
359 Sum1& operator=(
const Sum1& right) {
360 if (&right ==
this) {
363 Func1::operator=(right);
366 m_f1->setParent(
this);
367 m_f2->setParent(
this);
372 virtual int ID()
const {
376 virtual doublereal
eval(doublereal t)
const {
377 return m_f1->
eval(t) + m_f2->
eval(t);
383 Func1& dup = newSumFunction(f1d, f2d);
390 Func1& d = newSumFunction(d1, d2);
397 virtual std::string write(std::string arg)
const;
410 m_f1->setParent(
this);
411 m_f2->setParent(
this);
421 *
this = Diff1::operator=(b);
425 if (&right ==
this) {
428 Func1::operator=(right);
431 m_f1->setParent(
this);
432 m_f2->setParent(
this);
437 virtual int ID()
const {
441 virtual doublereal
eval(doublereal t)
const {
442 return m_f1->
eval(t) - m_f2->
eval(t);
448 Func1& dup = newDiffFunction(f1d, f2d);
459 virtual std::string write(std::string arg)
const;
474 m_f1->setParent(
this);
475 m_f2->setParent(
this);
485 *
this = Product1::operator=(b);
489 if (&right ==
this) {
492 Func1::operator=(right);
495 m_f1->setParent(
this);
496 m_f2->setParent(
this);
501 virtual int ID()
const {
508 Func1& dup = newProdFunction(f1d, f2d);
512 virtual std::string write(std::string arg)
const;
514 virtual doublereal
eval(doublereal t)
const {
515 return m_f1->
eval(t) * m_f2->
eval(t);
521 Func1& s = newSumFunction(a1, a2);
541 m_f1->setParent(
this);
550 *
this = TimesConstant1::operator=(b);
554 if (&right ==
this) {
557 Func1::operator=(right);
559 m_f1->setParent(
this);
563 virtual int ID()
const {
564 return TimesConstantFuncType;
575 return (other.
c()/
c());
581 virtual doublereal isProportional(Func1& other) {
589 virtual doublereal
eval(doublereal t)
const {
590 return m_f1->
eval(t) * m_c;
595 Func1* d = &newTimesConstFunction(f1d, m_c);
599 virtual std::string write(std::string arg)
const;
617 m_f1->setParent(
this);
626 *
this = PlusConstant1::operator=(b);
630 if (&right ==
this) {
633 Func1::operator=(right);
635 m_f1->setParent(
this);
640 virtual int ID()
const {
641 return PlusConstantFuncType;
650 virtual doublereal
eval(doublereal t)
const {
651 return m_f1->
eval(t) + m_c;
657 virtual std::string write(std::string arg)
const;
677 m_f1->setParent(
this);
678 m_f2->setParent(
this);
688 *
this = Ratio1::operator=(b);
692 if (&right ==
this) {
695 Func1::operator=(right);
698 m_f1->setParent(
this);
699 m_f2->setParent(
this);
704 virtual int ID()
const {
705 return RatioFuncType;
708 virtual doublereal
eval(doublereal t)
const {
709 return m_f1->
eval(t) / m_f2->
eval(t);
715 Func1& dup = newRatioFunction(f1d, f2d);
722 Func1& s = newDiffFunction(a1, a2);
724 Func1& r = newRatioFunction(s, p);
728 virtual std::string write(std::string arg)
const;
747 m_f1->setParent(
this);
748 m_f2->setParent(
this);
758 *
this = Composite1::operator=(b);
762 if (&right ==
this) {
765 Func1::operator=(right);
768 m_f1->setParent(
this);
769 m_f2->setParent(
this);
774 virtual int ID()
const {
775 return CompositeFuncType;
778 virtual doublereal
eval(doublereal t)
const {
785 Func1& dup = newCompositeFunction(f1d, f2d);
794 Func1* p = &newProdFunction(*d3, *d2);
798 virtual std::string write(std::string arg)
const;
825 Gaussian(
double A,
double t0,
double fwhm) :
829 m_tau = fwhm/(2.0*std::sqrt(std::log(2.0)));
836 *
this = Gaussian::operator=(b);
840 if (&right ==
this) {
843 Func1::operator=(right);
853 return *((
Func1*)np);
856 virtual doublereal
eval(doublereal t)
const {
857 doublereal x = (t - m_t0)/m_tau;
858 return m_A * std::exp(-x*x);
862 doublereal m_A, m_t0, m_tau;
873 Poly1(
size_t n, doublereal*
c) :
877 std::copy(c, c+m_n, m_cpoly.begin());
885 *
this = Poly1::operator=(b);
889 if (&right ==
this) {
892 Func1::operator=(right);
893 m_cpoly = right.m_cpoly;
902 return *((
Func1*)np);
905 virtual doublereal
eval(doublereal t)
const {
906 doublereal r = m_cpoly[m_n-1];
907 for (
size_t n = 1; n < m_n; n++) {
909 r += m_cpoly[m_n - n - 1];
931 Fourier1(
size_t n, doublereal omega, doublereal a0,
932 doublereal* a, doublereal* b) :
939 std::copy(a, a+n, m_ccos.begin());
940 std::copy(b, b+n, m_csin.begin());
947 *
this = Fourier1::operator=(b);
951 if (&right ==
this) {
954 Func1::operator=(right);
955 m_omega = right.m_omega;
956 m_a0_2 = right.m_a0_2;
957 m_ccos = right.m_ccos;
958 m_csin = right.m_csin;
966 return *((
Func1*)np);
969 virtual doublereal
eval(doublereal t)
const {
971 doublereal sum = m_a0_2;
972 for (n = 0; n < m_n; n++) {
974 sum += m_ccos[n]*std::cos(m_omega*nn*t)
975 + m_csin[n]*std::sin(m_omega*nn*t);
982 doublereal m_omega, m_a0_2;
1002 for (
size_t i = 0; i < n; i++) {
1015 *
this = Arrhenius1::operator=(b);
1019 if (&right ==
this) {
1022 Func1::operator=(right);
1033 return *((
Func1*)np);
1036 virtual doublereal
eval(doublereal t)
const {
1037 doublereal sum = 0.0;
1038 for (
size_t n = 0; n < m_n; n++) {
1039 sum += m_A[n]*std::pow(t,m_b[n])*std::exp(-m_E[n]/t);
1064 *
this = Periodic1::operator=(b);
1068 if (&right ==
this) {
1071 Func1::operator=(right);
1078 return *((
Func1*)np);
1085 virtual doublereal
eval(doublereal t)
const {
1086 int np = int(t/m_c);
1087 doublereal time = t - np*m_c;
1088 return m_func->
eval(time);