forked from NCAR/bspline
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
47 lines (37 loc) · 828 Bytes
/
main.cpp
File metadata and controls
47 lines (37 loc) · 828 Bytes
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
#include <iostream>
#include <vector>
#include <cmath>
#include "BSpline.h"
int main()
{
const int nx = 20;
std::vector<double> x(nx);
std::vector<double> y(nx);
const double pi = std::acos(-1.0);
for (int i = 0; i < nx; ++i)
{
x[i] = static_cast<double>(i) / (nx - 1);
y[i] = std::sin(2.0 * pi * x[i]);
}
double wl = 0.2;
int bc_type = 2;
int num_nodes = 20;
BSpline<double> spline(
x.data(),
nx,
y.data(),
wl,
bc_type,
num_nodes
);
for (int i = 0; i <= 10; ++i)
{
double u = static_cast<double>(i) / 10.0;
std::cout
<< "u = " << u
<< ", y = " << spline.evaluate(u)
<< ", dy = " << spline.slope(u)
<< std::endl;
}
return 0;
}