Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JMATH::JTrigonometric Class Reference

Trigonometric function object for sin and cos. More...

#include <JTrigonometric.hh>

Public Types

typedef double(*) pF(double)
 Type definition of pointer to trigonometric function.
 

Public Member Functions

 JTrigonometric (pF f1, const double factor=1.0)
 Constructor.
 
double getValue (const double x) const
 Function value.
 
double getDerivative (const double x) const
 Derivative value.
 
double getIntegral (const double x) const
 Integral value.
 
double operator() (const double x) const
 Function value.
 
JTrigonometric getDerivative () const
 Derivative function.
 
JTrigonometric getIntegral () const
 Integral function.
 

Protected Attributes

pF f1
 
double factor
 

Friends

std::istream & operator>> (std::istream &in, JTrigonometric &object)
 Read trigonometric from input.
 
std::ostream & operator<< (std::ostream &out, const JTrigonometric &object)
 Write trigonometric to output.
 

Detailed Description

Trigonometric function object for sin and cos.

Evaluation of function, derivative and integral values.

Definition at line 28 of file JTrigonometric.hh.

Member Typedef Documentation

◆ pF

double(*) JMATH::JTrigonometric::pF(double)

Type definition of pointer to trigonometric function.

Definition at line 33 of file JTrigonometric.hh.

Constructor & Destructor Documentation

◆ JTrigonometric()

JMATH::JTrigonometric::JTrigonometric ( pF f1,
const double factor = 1.0 )
inline

Constructor.

Parameters
f1pointer to function
factormultiplication factor

Definition at line 42 of file JTrigonometric.hh.

43 {
44 if (f1 != (double (*)(double)) sin && f1 != (double (*)(double)) cos) {
45 THROW(JException, "Invalid trigonometric function.");
46 }
47
48 this->f1 = f1;
49 this->factor = factor;
50 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.

Member Function Documentation

◆ getValue()

double JMATH::JTrigonometric::getValue ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 59 of file JTrigonometric.hh.

60 {
61 return factor * f1(x);
62 }

◆ getDerivative() [1/2]

double JMATH::JTrigonometric::getDerivative ( const double x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 71 of file JTrigonometric.hh.

72 {
73 return getDerivative().getValue(x);
74 }
JTrigonometric getDerivative() const
Derivative function.
double getValue(const double x) const
Function value.

◆ getIntegral() [1/2]

double JMATH::JTrigonometric::getIntegral ( const double x) const
inline

Integral value.

Parameters
xabscissa value
Returns
integral value

Definition at line 83 of file JTrigonometric.hh.

84 {
85 return getIntegral().getValue(x);
86 }
JTrigonometric getIntegral() const
Integral function.

◆ operator()()

double JMATH::JTrigonometric::operator() ( const double x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 95 of file JTrigonometric.hh.

96 {
97 return getValue(x);
98 }

◆ getDerivative() [2/2]

JTrigonometric JMATH::JTrigonometric::getDerivative ( ) const
inline

Derivative function.

Returns
derivative function

Definition at line 106 of file JTrigonometric.hh.

107 {
108 if (f1 == (double (*)(double)) sin)
109 return JTrigonometric(cos, +factor);
110 else if (f1 == (double (*)(double)) cos)
111 return JTrigonometric(sin, -factor);
112 else
113 THROW(JException, "Invalid trigonometric function.");
114 }
JTrigonometric(pF f1, const double factor=1.0)
Constructor.

◆ getIntegral() [2/2]

JTrigonometric JMATH::JTrigonometric::getIntegral ( ) const
inline

Integral function.

Returns
integral function

Definition at line 122 of file JTrigonometric.hh.

123 {
124 if (f1 == (double (*)(double)) sin)
125 return JTrigonometric(cos, -factor);
126 else if (f1 == (double (*)(double)) cos)
127 return JTrigonometric(sin, +factor);
128 else
129 THROW(JException, "Invalid trigonometric function.");
130 }

Friends And Related Symbol Documentation

◆ operator>>

std::istream & operator>> ( std::istream & in,
JTrigonometric & object )
friend

Read trigonometric from input.

Parameters
ininput stream
objecttrigonometric
Returns
input stream

Definition at line 140 of file JTrigonometric.hh.

141 {
142 std::string buffer;
143
144 if (in >> object.factor >> buffer) {
145 if (buffer == "sin")
146 object.f1 = sin;
147 else if (buffer == "cos")
148 object.f1 = cos;
149 else
150 THROW(JException, "Invalid trigonometric function.");
151 }
152
153 return in;
154 }

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const JTrigonometric & object )
friend

Write trigonometric to output.

Parameters
outoutput stream
objecttrigonometric
Returns
output stream

Definition at line 164 of file JTrigonometric.hh.

165 {
166 out << object.factor;
167
168 if (object.f1 == (double (*)(double)) sin)
169 out << ' ' << "sin";
170 else if (object.f1 == (double (*)(double)) cos)
171 out << ' ' << "cos";
172 else
173 THROW(JException, "Invalid trigonometric function.");
174
175 return out;
176 }

Member Data Documentation

◆ f1

pF JMATH::JTrigonometric::f1
protected

Definition at line 179 of file JTrigonometric.hh.

◆ factor

double JMATH::JTrigonometric::factor
protected

Definition at line 180 of file JTrigonometric.hh.


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