-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpolation.hpp
More file actions
94 lines (73 loc) · 2.32 KB
/
Copy pathinterpolation.hpp
File metadata and controls
94 lines (73 loc) · 2.32 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#if !defined(INTERPOLATION)
#define INTERPOLATION
#include <utility>
#include <vector>
#include <functional>
#include <cstdint>
// TODO: #include <stdfloat>
namespace nm {
const long double PRECISION = 1e-8;
enum classification {
zero,
one,
infinite,
// zero: no solution
// one: one solution
// infinite: many solutions
};
enum solver {
none, // unsolved
gauss,
// others
};
class SLE {
private:
std::size_t n;
std::vector<std::vector<long double> > A;
std::vector<std::uint32_t> pivots;
solver applied;
solver gauss();
protected:
void normalize();
std::uint32_t pivot(std::size_t column, std::size_t row = 0,
long double threshold = PRECISION);
// add solvers
void cramer();
void fourier();
void singular_value();
void lu();
void qr();
// square positive definite
void cholesky();
public:
SLE() {this->n = -1;};
SLE(std::vector<std::vector<long double> > matrix);
SLE(std::size_t nr, std::size_t nc);
~SLE() {};
void add_row(std::vector<long double> row);
classification solve(std::vector<long double> &x,
long double threshold = PRECISION, solver use = solver::gauss);
std::size_t rank();
std::vector<long double> eigenvalues();
// rank equals n
long double determinant();
SLE inverse();
};
} // system of linear equations
namespace nm {
template<typename T>
std::function<T(T)> polynomial(const std::vector<T> &coefficients);
template<typename T>
class Spline {
private:
std::vector<std::vector<T> > coefficients;
std::vector<std::pair<T, T> > bounds;
public:
// bounds is expected to be sorted
// coefficients and bounds correspond
Spline(std::vector<std::vector<T> > &coefficients,
std::vector<std::pair<T, T> > &bounds);
~Spline() {};
};
} // polynomials and spline
#endif // INTERPOLATION