Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | List of all members
JMATH::JPolynome Struct Reference

Polynome function object. More...

#include <JPolynome.hh>

Inheritance diagram for JMATH::JPolynome:
JMATH::JPolynome_t std::vector< double > JMATH::JMath< JPolynome_t > JLANG::JEquals< JFirst_t, JSecond_t >

Public Member Functions

 JPolynome ()
 Default constructor. More...
 
 JPolynome (const JPolynome_t &polynome)
 Copy constructor. More...
 
template<class T >
 JPolynome (T __begin, T __end)
 Constructor. More...
 
template<class... Args>
 JPolynome (const Args &...args)
 Initialise constructor. More...
 
template<class... Args>
JPolynomeset (const Args &...args)
 Set values. More...
 
double getValue (const double x) const
 Function value. More...
 
double getDerivative (const double x) const
 Derivative value. More...
 
double getIntegral (const double x) const
 Integral value. More...
 
double operator() (const double x) const
 Function value. More...
 
JPolynome getDerivative () const
 Get derivative function. More...
 
JPolynome getIntegral () const
 get integral function. More...
 
JPolynome_t getGradient (const double x) const
 Get gradient. More...
 
bool equals (const JPolynome_t &P, const double eps=std::numeric_limits< double >::min()) const
 Equality. More...
 
JPolynome_tadd (const JPolynome_t &polynome)
 Add polynome. More...
 
JPolynome_tsub (const JPolynome_t &polynome)
 Subtract polynome. More...
 
JPolynome_tmul (const double factor)
 Scale polynome. More...
 
JPolynome_tmul (const JNullType &object)
 Multiply with object. More...
 

Private Member Functions

template<class... Args>
void __set__ (const double x, const Args &...args)
 Recursive method for setting values. More...
 
void __set__ () const
 Termination method for setting values. More...
 

Detailed Description

Polynome function object.

Evaluates function, derivative, integral and gradient values.

Definition at line 163 of file JPolynome.hh.

Constructor & Destructor Documentation

JMATH::JPolynome::JPolynome ( )
inline

Default constructor.

Definition at line 169 of file JPolynome.hh.

170  {}
JMATH::JPolynome::JPolynome ( const JPolynome_t polynome)
inline

Copy constructor.

Parameters
polynomepolynome

Definition at line 178 of file JPolynome.hh.

178  :
179  JPolynome_t(polynome)
180  {}
JPolynome_t()
Default constructor.
Definition: JPolynome.hh:36
template<class T >
JMATH::JPolynome::JPolynome ( T  __begin,
T  __end 
)
inline

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 190 of file JPolynome.hh.

192  {
193  for (T i = __begin; i != __end; ++i) {
194  push_back(*i);
195  }
196  }
do set_variable OUTPUT_DIRECTORY $WORKDIR T
template<class... Args>
JMATH::JPolynome::JPolynome ( const Args &...  args)
inline

Initialise constructor.

Parameters
argsvalues

Definition at line 205 of file JPolynome.hh.

206  {
207  set(args...);
208  }
JPolynome & set(const Args &...args)
Set values.
Definition: JPolynome.hh:217

Member Function Documentation

template<class... Args>
JPolynome& JMATH::JPolynome::set ( const Args &...  args)
inline

Set values.

Parameters
argsvalues

Definition at line 217 of file JPolynome.hh.

218  {
219  clear();
220 
221  __set__(args...);
222 
223  return *this;
224  }
void __set__() const
Termination method for setting values.
Definition: JPolynome.hh:386
double JMATH::JPolynome::getValue ( const double  x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 233 of file JPolynome.hh.

234  {
235  double y = 0.0;
236  double z = 1.0;
237 
238  for (const_iterator i = begin(); i != end(); ++i, z *= x) {
239  y += (*i) * z;
240  }
241 
242  return y;
243  }
double JMATH::JPolynome::getDerivative ( const double  x) const
inline

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 252 of file JPolynome.hh.

253  {
254  double y = 0.0;
255 
256  if (!empty()) {
257 
258  double z = 1.0;
259  int n = 1;
260 
261  for (const_iterator i = begin(); ++i != end(); ++n, z *= x) {
262  y += (*i) * z * n;
263  }
264  }
265 
266  return y;
267  }
const int n
Definition: JPolint.hh:697
double JMATH::JPolynome::getIntegral ( const double  x) const
inline

Integral value.

Parameters
xabscissa value
Returns
integral value

Definition at line 276 of file JPolynome.hh.

277  {
278  double y = 0.0;
279  double z = x;
280  int n = 1;
281 
282  for (const_iterator i = begin(); i != end(); ++i, ++n, z *= x) {
283  y += (*i) * z / n;
284  }
285 
286  return y;
287  }
const int n
Definition: JPolint.hh:697
double JMATH::JPolynome::operator() ( const double  x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 296 of file JPolynome.hh.

297  {
298  return getValue(x);
299  }
double getValue(const double x) const
Function value.
Definition: JPolynome.hh:233
JPolynome JMATH::JPolynome::getDerivative ( ) const
inline

Get derivative function.

Returns
derivative function

Definition at line 307 of file JPolynome.hh.

308  {
309  JPolynome buffer;
310 
311  if (size() == 0u) {
312  } else if (size() == 1u) {
313 
314  buffer.push_back(0.0);
315 
316  } else {
317 
318  int n = 1;
319 
320  for (const_iterator i = begin(); ++i != end(); ++n) {
321  buffer.push_back(n * (*i));
322  }
323  }
324 
325  return buffer;
326  }
const int n
Definition: JPolint.hh:697
Polynome function object.
Definition: JPolynome.hh:163
double u[N+1]
Definition: JPolint.hh:776
JPolynome JMATH::JPolynome::getIntegral ( ) const
inline

get integral function.

Returns
integral function

Definition at line 334 of file JPolynome.hh.

335  {
336  JPolynome buffer(0.0);
337 
338  int n = 1;
339 
340  for (const_iterator i = begin(); i != end(); ++i, ++n) {
341  buffer.push_back((*i) / (double) n);
342  }
343 
344  return buffer;
345  }
const int n
Definition: JPolint.hh:697
Polynome function object.
Definition: JPolynome.hh:163
JPolynome_t JMATH::JPolynome::getGradient ( const double  x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 354 of file JPolynome.hh.

355  {
356  JPolynome_t buffer;
357 
358  double z = 1.0;
359 
360  for (const_iterator i = begin(); i != end(); ++i, z *= x) {
361  buffer.push_back(z); // d(f)/d(x_i)
362  }
363 
364  return buffer;
365  }
Polynome model.
Definition: JPolynome.hh:28
template<class... Args>
void JMATH::JPolynome::__set__ ( const double  x,
const Args &...  args 
)
inlineprivate

Recursive method for setting values.

Parameters
xnext value
argsremaining values

Definition at line 375 of file JPolynome.hh.

376  {
377  this->push_back(x);
378 
379  __set__(args...);
380  }
void __set__() const
Termination method for setting values.
Definition: JPolynome.hh:386
void JMATH::JPolynome::__set__ ( ) const
inlineprivate

Termination method for setting values.

Definition at line 386 of file JPolynome.hh.

387  {}
bool JMATH::JPolynome_t::equals ( const JPolynome_t P,
const double  eps = std::numeric_limits<double>::min() 
) const
inlineinherited

Equality.

Parameters
Ppolynome
epsnumerical precision
Returns
true if polynomes identical; else false

Definition at line 47 of file JPolynome.hh.

49  {
50  if (this->size() == P.size()) {
51 
52  for (const_iterator p = this->begin(), q = P.begin(); p != this->end(); ++p, ++q) {
53  if (fabs(*p - *q) > eps) {
54  return false;
55  }
56  }
57 
58  return true;
59 
60  } else {
61 
62  return false;
63  }
64  }
JPolynome_t& JMATH::JPolynome_t::add ( const JPolynome_t polynome)
inlineinherited

Add polynome.

Parameters
polynomepolynome
Returns
this polynome

Definition at line 73 of file JPolynome.hh.

74  {
75  while (this->size() < polynome.size()) {
76  this->push_back(0.0);
77  }
78 
79  for (size_t i = 0; i != this->size(); ++i) {
80  (*this)[i] += polynome[i];
81  }
82 
83  return *this;
84  }
JPolynome_t& JMATH::JPolynome_t::sub ( const JPolynome_t polynome)
inlineinherited

Subtract polynome.

Parameters
polynomepolynome
Returns
this polynome

Definition at line 93 of file JPolynome.hh.

94  {
95  while (this->size() < polynome.size()) {
96  this->push_back(0.0);
97  }
98 
99  for (size_t i = 0; i != this->size(); ++i) {
100  (*this)[i] -= polynome[i];
101  }
102 
103  return *this;
104  }
JPolynome_t& JMATH::JPolynome_t::mul ( const double  factor)
inlineinherited

Scale polynome.

Parameters
factormultiplication factor
Returns
this polynome

Definition at line 113 of file JPolynome.hh.

114  {
115  for (iterator i = begin(); i != end(); ++i) {
116  (*i) *= factor;
117  }
118 
119  return *this;
120  }
JPolynome_t & JMATH::JMath< JPolynome_t , JNullType >::mul ( const JNullType object)
inlineinherited

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 354 of file JMath.hh.

355  {
356  return static_cast<JFirst_t&>(*this) = JFirst_t().mul(static_cast<const JFirst_t&>(*this), object);
357  }

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