Jpp
 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< JPolynome_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 array. 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 polynome. More...
 
void __set__ () const
 Termination method for setting polynome. More...
 

Detailed Description

Polynome function object.

Evaluates function, derivative, integral and gradient values.

Definition at line 161 of file JPolynome.hh.

Constructor & Destructor Documentation

JMATH::JPolynome::JPolynome ( )
inline

Default constructor.

Definition at line 167 of file JPolynome.hh.

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

Copy constructor.

Parameters
polynomepolynome

Definition at line 176 of file JPolynome.hh.

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

Constructor.

Parameters
__beginbegin of data
__endend of data

Definition at line 188 of file JPolynome.hh.

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

Initialise constructor.

Parameters
argsvalues

Definition at line 202 of file JPolynome.hh.

203  {
204  set(args...);
205  }
JPolynome & set(const Args &...args)
Set array.
Definition: JPolynome.hh:214

Member Function Documentation

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

Set array.

Parameters
argsvalues

Definition at line 214 of file JPolynome.hh.

215  {
216  clear();
217 
218  __set__(args...);
219 
220  return *this;
221  }
void __set__() const
Termination method for setting polynome.
Definition: JPolynome.hh:383
double JMATH::JPolynome::getValue ( const double  x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 230 of file JPolynome.hh.

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

Derivative value.

Parameters
xabscissa value
Returns
derivative value

Definition at line 249 of file JPolynome.hh.

250  {
251  double y = 0.0;
252 
253  if (!empty()) {
254 
255  double z = 1.0;
256  int n = 1;
257 
258  for (const_iterator i = begin(); ++i != end(); ++n, z *= x) {
259  y += (*i) * z * n;
260  }
261  }
262 
263  return y;
264  }
alias put_queue eval echo n
Definition: qlib.csh:19
double JMATH::JPolynome::getIntegral ( const double  x) const
inline

Integral value.

Parameters
xabscissa value
Returns
integral value

Definition at line 273 of file JPolynome.hh.

274  {
275  double y = 0.0;
276  double z = x;
277  int n = 1;
278 
279  for (const_iterator i = begin(); i != end(); ++i, ++n, z *= x) {
280  y += (*i) * z / n;
281  }
282 
283  return y;
284  }
alias put_queue eval echo n
Definition: qlib.csh:19
double JMATH::JPolynome::operator() ( const double  x) const
inline

Function value.

Parameters
xabscissa value
Returns
function value

Definition at line 293 of file JPolynome.hh.

294  {
295  return getValue(x);
296  }
double getValue(const double x) const
Function value.
Definition: JPolynome.hh:230
JPolynome JMATH::JPolynome::getDerivative ( ) const
inline

Get derivative function.

Returns
derivative function

Definition at line 304 of file JPolynome.hh.

305  {
306  JPolynome buffer;
307 
308  if (size() == 0u) {
309  } else if (size() == 1u) {
310 
311  buffer.push_back(0.0);
312 
313  } else {
314 
315  int n = 1;
316 
317  for (const_iterator i = begin(); ++i != end(); ++n) {
318  buffer.push_back(n * (*i));
319  }
320  }
321 
322  return buffer;
323  }
alias put_queue eval echo n
Definition: qlib.csh:19
Polynome function object.
Definition: JPolynome.hh:161
double u[N+1]
Definition: JPolint.hh:706
JPolynome JMATH::JPolynome::getIntegral ( ) const
inline

get integral function.

Returns
integral function

Definition at line 331 of file JPolynome.hh.

332  {
333  JPolynome buffer(0.0);
334 
335  int n = 1;
336 
337  for (const_iterator i = begin(); i != end(); ++i, ++n) {
338  buffer.push_back((*i) / (double) n);
339  }
340 
341  return buffer;
342  }
alias put_queue eval echo n
Definition: qlib.csh:19
Polynome function object.
Definition: JPolynome.hh:161
JPolynome_t JMATH::JPolynome::getGradient ( const double  x) const
inline

Get gradient.

Parameters
xabscissa value
Returns
gradient

Definition at line 351 of file JPolynome.hh.

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

Recursive method for setting polynome.

Parameters
xnext value
argsremaining values

Definition at line 372 of file JPolynome.hh.

373  {
374  this->push_back(x);
375 
376  __set__(args...);
377  }
void __set__() const
Termination method for setting polynome.
Definition: JPolynome.hh:383
void JMATH::JPolynome::__set__ ( ) const
inlineprivate

Termination method for setting polynome.

Definition at line 383 of file JPolynome.hh.

384  {}
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 45 of file JPolynome.hh.

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

Add polynome.

Parameters
polynomepolynome
Returns
this polynome

Definition at line 71 of file JPolynome.hh.

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

Subtract polynome.

Parameters
polynomepolynome
Returns
this polynome

Definition at line 91 of file JPolynome.hh.

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

Scale polynome.

Parameters
factormultiplication factor
Returns
this polynome

Definition at line 111 of file JPolynome.hh.

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

Multiply with object.

Parameters
objectobject
Returns
result object

Definition at line 273 of file JMath.hh.

274  {
275  return static_cast<JFirst_t&>(*this) = JCalculator<JFirst_t>::calculator.mul(static_cast<const JFirst_t&>(*this), object);
276  }
Auxiliary class for arithmetic operations on objects.
Definition: JCalculator.hh:18

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