20 #ifndef _FOURIER_FUNCTION_H_
21 #define _FOURIER_FUNCTION_H_
23 #include "mbsim/functions/function.h"
24 #include "mbsim/utils/utils.h"
30 template<
typename Ret,
typename Arg>
36 FourierFunction(
double f_,
const fmatvec::VecV &a_,
const fmatvec::VecV &b_,
double a0_=0,
bool amplitudePhaseAngleForm_=
false) : f(f_), a0(a0_), a(a_), b(b_), amplitudePhaseAngleForm(amplitudePhaseAngleForm_) { }
37 Ret operator()(
const Arg& t_) {
40 double Om = 2.*M_PI*f;
41 for(
int i=0; i<a.size(); i++) {
44 y += a(i)*cos(phi)+b(i)*sin(phi);
48 typename B::DRetDArg parDer(
const Arg &t_) {
51 double Om = 2.*M_PI*f;
52 for(
int i=0; i<a.size(); i++) {
55 yd += k*Om*(b(i)*cos(phi)-a(i)*sin(phi));
59 Ret parDerParDer(
const double &t_) {
62 double Om = 2.*M_PI*f;
63 for(
int i=0; i<a.size(); i++) {
66 ydd -= pow(k*Om,2)*(a(i)*cos(phi)+b(i)*sin(phi));
70 void initializeUsingXML(xercesc::DOMElement * element) {
71 xercesc::DOMElement *e=MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"frequency");
72 f=Element::getDouble(e);
73 e=MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"a0");
74 if(e) a0=Element::getDouble(e);
75 e = MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"a");
77 a = Element::getVec(e);
78 e = MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"b");
79 b = Element::getVec(e);
81 e = MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"ab");
83 fmatvec::MatV xy = Element::getMat(e);
84 assert(xy.cols() == 2);
88 e = MBXMLUtils::E(element)->getFirstElementChildNamed(MBSIM%
"amplitudePhaseAngleForm");
89 if(e) amplitudePhaseAngleForm = Element::getBool(e);
94 if(amplitudePhaseAngleForm) {
95 for(
int i=0; i<a.size(); i++) {
107 bool amplitudePhaseAngleForm;
void init(Element::InitStage stage)
plots time series header
Definition: fourier_function.h:91
Definition: fourier_function.h:28
InitStage
The stages of the initialization.
Definition: element.h:97
Definition: planar_contour.h:31
Definition: element.h:100