-
Notifications
You must be signed in to change notification settings - Fork 17
/
Polynom.hpp
77 lines (62 loc) · 1.4 KB
/
Polynom.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef LEPH_POLYNOM_HPP
#define LEPH_POLYNOM_HPP
#include <cstdlib>
#include <vector>
#include <iostream>
namespace Leph {
/**
* Polynom
*
* Simple one dimentional
* polynom class for spline
* generation
*/
class Polynom
{
public:
/**
* Default and inital degree initialization
*/
Polynom();
Polynom(unsigned int degree);
/**
* Access to coefficient
* indexed from constant to
* higher degree
*/
const std::vector<double>& getCoefs() const;
std::vector<double>& getCoefs();
/**
* Access to coefficient
*/
const double& operator()(size_t index) const;
double& operator()(size_t index);
/**
* Return polynom degree
* -1 mean empty polynom
*/
size_t degree() const;
/**
* Polynom evaluation, its first and
* second derivative at given x
*/
double pos(double x) const;
double vel(double x) const;
double acc(double x) const;
/**
* Some useful operators
*/
void operator*=(double coef);
void operator+=(const Polynom& p);
private:
/**
* Polynom coeficients
*/
std::vector<double> _coefs;
};
/**
* Print operator
*/
std::ostream& operator<<(std::ostream& os, const Polynom& p);
}
#endif