|
4 | 4 | namespace ModuleBase |
5 | 5 | { |
6 | 6 |
|
7 | | - |
8 | | -// |
9 | | -//DESCRIPTION: |
10 | | -// A class to treat Cardinal B-spline interpolation. |
11 | | -// qianrui created 2021-09-14 |
12 | | -//MATH: |
13 | | -// Only uniform nodes are considered: xm-x[m-1]=Dx(>= 0) for control node: X={x0,x1,...,xm}; |
14 | | -// Any function p(x) can be written by |
15 | | -// p(x)=\sum_i{ci*M_ik(x)} (k->infinity), |
16 | | -// where M_ik is the i-th k-order Cardinal B-spline base function |
17 | | -// and ci is undetermined coefficient. |
18 | | -// M_i0 = H(x-xi)-H(x-x[i+1]), H(x): step function |
19 | | -// x-xi x[i+k+1]-x |
20 | | -// M_ik(x)= ---------*M_i(k-1)(x)+ ----------------*M_[i+1][k-1](x) ( xi <= x <= x[i+1] ) |
21 | | -// x[i+k]-xi x[i+k+1]-x[i+1] |
22 | | -// For uniform nodes: M_[i+1]k(x+Dx)=M_ik(x) |
23 | | -// If we define Bk[n] stores M_ik(x+n*Dx) for x in (xi,xi+Dx): |
24 | | -// x+n*Dx-xi xi+(k-n+1)*Dx-x |
25 | | -// Bk[n] = -----------*B(k-1)[n] + -----------------*B(k-1)[n-1] |
26 | | -// k*Dx k*Dx |
27 | | -//USAGE: |
28 | | -// ModuleBase::Bspline bp; |
29 | | -// bp.init(10,0.7,2); //Dx = 0.7, xi = 2 |
30 | | -// bp.getbslpine(0.5); //x = 0.5 |
31 | | -// cout<<bp.bspline_ele(3)<<endl; //print M_ik[xi+3*Dx+x]: M_i[10](4.6) |
32 | | -// |
| 7 | +/** |
| 8 | + * @brief A class to treat Cardinal B-spline interpolation. |
| 9 | + * |
| 10 | + * @author qianrui created 2021-09-14 |
| 11 | + * @details see: J. Chem. Phys. 103, 8577 (1995). |
| 12 | + * Math: |
| 13 | + * Only uniform nodes are considered: xm-x[m-1]=Dx(>= 0) for control node: X={x0,x1,...,xm}; |
| 14 | + * Any function p(x) can be written by |
| 15 | + * p(x)=\sum_i{ci*M_ik(x)} (k->infinity), |
| 16 | + * where M_ik is the i-th k-order Cardinal B-spline base function |
| 17 | + * and ci is undetermined coefficient. |
| 18 | + * M_i0 = H(x-xi)-H(x-x[i+1]), H(x): step function |
| 19 | + * x-xi x[i+k+1]-x |
| 20 | + * M_ik(x)= ---------*M_i(k-1)(x)+ ----------------*M_[i+1][k-1](x) ( xi <= x <= x[i+1] ) |
| 21 | + * x[i+k]-xi x[i+k+1]-x[i+1] |
| 22 | + * For uniform nodes: M_[i+1]k(x+Dx)=M_ik(x) |
| 23 | + * If we define Bk[n] stores M_ik(x+n*Dx) for x in (xi,xi+Dx): |
| 24 | + * x+n*Dx-xi xi+(k-n+1)*Dx-x |
| 25 | + * Bk[n] = -----------*B(k-1)[n] + -----------------*B(k-1)[n-1] |
| 26 | + * k*Dx k*Dx |
| 27 | + * USAGE: |
| 28 | + * ModuleBase::Bspline bp; |
| 29 | + * bp.init(10,0.7,2); //Dx = 0.7, xi = 2 |
| 30 | + * bp.getbslpine(0.5); //x = 0.5 |
| 31 | + * cout<<bp.bezier_ele(3)<<endl; //print M_ik[xi+3*Dx+x]: M_i[10](4.6) |
| 32 | + * |
| 33 | + */ |
33 | 34 | class Bspline |
34 | 35 | { |
35 | | - private: |
36 | | - int norder; // the order of bezier base; norder >= 0 |
37 | | - double Dx; //Dx: the interval of control node |
38 | | - double xi; // xi: the starting point |
39 | | - double *bezier; //bezier[n] = Bk[n] |
| 36 | + private: |
| 37 | + int norder; // the order of bezier base; norder >= 0 |
| 38 | + double Dx; // Dx: the interval of control node |
| 39 | + double xi; // xi: the starting point |
| 40 | + double *bezier; // bezier[n] = Bk[n] |
40 | 41 |
|
41 | | - public: |
42 | | - Bspline(); |
43 | | - ~Bspline(); |
| 42 | + public: |
| 43 | + Bspline(); |
| 44 | + ~Bspline(); |
44 | 45 |
|
45 | | - //Init norder, Dx, xi |
46 | | - void init(int norderin, double Dxin, double xiin); |
| 46 | + void init(int norderin, double Dxin, double xiin); |
47 | 47 |
|
48 | | - //delete[] bezier |
49 | | - void cleanp(); |
| 48 | + // Get the result of i-th bezier base functions for different input x+xi+n*Dx. |
| 49 | + // x should be in [0,Dx] |
| 50 | + // n-th result is stored in bezier[n]; |
| 51 | + void getbspline(double x); |
50 | 52 |
|
51 | | - //Get the result of i-th bezier base functions for different input x+xi+n*Dx. |
52 | | - //x should be in [0,Dx] |
53 | | - //n-th result is stored in bezier[n]; |
54 | | - void getbslpine(double x); |
55 | | - |
56 | | - //get the element of bezier |
57 | | - double bezier_ele(int n); |
| 53 | + // get the element of bezier |
| 54 | + double bezier_ele(int n); |
58 | 55 | }; |
59 | | -} |
| 56 | +} // namespace ModuleBase |
60 | 57 | #endif |
0 commit comments