ProteoWizard
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ParametrizedCosine Class Reference
Inheritance diagram for ParametrizedCosine:
pwiz::frequency::ParametrizedFunction< double >

Public Member Functions

virtual unsigned int parameterCount () const
 
virtual double operator() (double x, const ublas::vector< double > &p) const
 
virtual ublas::vector< double > dp (double x, const ublas::vector< double > &p) const
 
virtual ublas::matrix< double > dp2 (double x, const ublas::vector< double > &p) const
 
- Public Member Functions inherited from pwiz::frequency::ParametrizedFunction< double >
virtual ~ParametrizedFunction ()
 

Private Member Functions

void preprocess (double x, const ublas::vector< double > &p) const
 

Private Attributes

double x_
 
double A_
 
double B_
 
double sinBx_
 
double cosBx_
 

Detailed Description

Definition at line 92 of file ParametrizedFunctionTest.cpp.

Member Function Documentation

◆ parameterCount()

virtual unsigned int ParametrizedCosine::parameterCount ( ) const
inlinevirtual

Implements pwiz::frequency::ParametrizedFunction< double >.

Definition at line 98 of file ParametrizedFunctionTest.cpp.

98{return 2;}

Referenced by preprocess().

◆ operator()()

virtual double ParametrizedCosine::operator() ( double  x,
const ublas::vector< double > &  p 
) const
inlinevirtual

Implements pwiz::frequency::ParametrizedFunction< double >.

Definition at line 100 of file ParametrizedFunctionTest.cpp.

101 {
102 preprocess(x,p);
103 return A_*cosBx_;
104 }
KernelTraitsBase< Kernel >::space_type::abscissa_type x
void preprocess(double x, const ublas::vector< double > &p) const

References A_, cosBx_, preprocess(), and x.

◆ dp()

virtual ublas::vector< double > ParametrizedCosine::dp ( double  x,
const ublas::vector< double > &  p 
) const
inlinevirtual

Implements pwiz::frequency::ParametrizedFunction< double >.

Definition at line 107 of file ParametrizedFunctionTest.cpp.

108 {
109 preprocess(x,p);
110 ublas::vector<double> v(2);
111 v(0) = cosBx_; // dF/dA
112 v(1) = -A_*x_*sinBx_; // dF/dB
113 return v;
114 }

References A_, cosBx_, preprocess(), sinBx_, x, and x_.

◆ dp2()

virtual ublas::matrix< double > ParametrizedCosine::dp2 ( double  x,
const ublas::vector< double > &  p 
) const
inlinevirtual

Implements pwiz::frequency::ParametrizedFunction< double >.

Definition at line 117 of file ParametrizedFunctionTest.cpp.

118 {
119 preprocess(x,p);
120 ublas::matrix<double> m(2,2);
121 m(0,0) = 0; // d2F/dA2
122 m(1,0) = m(0,1) = -x_*sinBx_; // d2F/dAdB
123 m(1,1) = -A_*x_*x_*cosBx_; // d2F/dB2
124 return m;
125 }

References A_, cosBx_, preprocess(), sinBx_, x, and x_.

◆ preprocess()

void ParametrizedCosine::preprocess ( double  x,
const ublas::vector< double > &  p 
) const
inlineprivate

Definition at line 130 of file ParametrizedFunctionTest.cpp.

131 {
132 // check parameter size
133 if (p.size() != parameterCount())
134 throw logic_error("[Parabola] Wrong parameter size.");
135
136 // cache arguments and do expensive calculations
137 if (x!=x_ || p(0)!=A_ || p(1)!=B_)
138 {
139 x_ = x;
140 A_ = p(0);
141 B_ = p(1);
142 sinBx_ = sin(B_*x);
143 cosBx_ = cos(B_*x);
144 }
145 else
146 {
147 //if (os_) *os_ << "cache hit!\n";
148 }
149 }
virtual unsigned int parameterCount() const

References A_, B_, cosBx_, parameterCount(), sinBx_, x, and x_.

Referenced by dp(), dp2(), and operator()().

Member Data Documentation

◆ x_

double ParametrizedCosine::x_
mutableprivate

Definition at line 152 of file ParametrizedFunctionTest.cpp.

Referenced by dp(), dp2(), and preprocess().

◆ A_

double ParametrizedCosine::A_
mutableprivate

Definition at line 153 of file ParametrizedFunctionTest.cpp.

Referenced by dp(), dp2(), operator()(), and preprocess().

◆ B_

double ParametrizedCosine::B_
mutableprivate

Definition at line 154 of file ParametrizedFunctionTest.cpp.

Referenced by preprocess().

◆ sinBx_

double ParametrizedCosine::sinBx_
mutableprivate

Definition at line 155 of file ParametrizedFunctionTest.cpp.

Referenced by dp(), dp2(), and preprocess().

◆ cosBx_

double ParametrizedCosine::cosBx_
mutableprivate

Definition at line 156 of file ParametrizedFunctionTest.cpp.

Referenced by dp(), dp2(), operator()(), and preprocess().


The documentation for this class was generated from the following file: