-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsplineEPsize.h
More file actions
79 lines (72 loc) · 2.15 KB
/
Copy pathsplineEPsize.h
File metadata and controls
79 lines (72 loc) · 2.15 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
class splineEPSize{
public:
int tk_l;//number of time points in *tk
int nsplines;//number of splines
int n_free;
int ndim;
int degree;//spline degree
double *tk;//time points
int *Tk;//time points in *tk where spline values are set
double *fv, *dv;//time points, splineepsize value, derivative value of slpineepsize value
double **spline;//cubic spline: four coefficients for each interval
double alpha;
double max_t;
splineEPSize(int nsplines_arg,int pointsperinterval, int ppl_arg,double maxt_arg){
// fprintf(stderr,"tk:%d intNum:%d nlast:%d\n",tk_l_arg,intNum_arg,nlast_arg);
//constructor
alpha=0.1;
max_t=maxt_arg;
nsplines=nsplines_arg;
tk_l = ppl_arg+nsplines*pointsperinterval+nsplines+1;
fprintf(stderr,"\t-> Allocating tk with tk_l:%d in spline\n",tk_l);
degree=3;
tk = new double[tk_l];
Tk = new int[nsplines+1];
fv = new double[nsplines+1];
dv = new double[nsplines+1];
spline = new double *[nsplines];
ndim=n_free = 2*(nsplines+1);
for(int i = 0; i < nsplines; i++)
spline[i] = new double[degree + 1];
void setTk(int n, double *t, double max_t, double alpha, double *inp_ti);
setTk(tk_l-1,tk,max_t,alpha,NULL);//<- rememer to subtract minus
for(int i=0;i<nsplines+1;i++){
Tk[i]=i*(pointsperinterval+1);
}
fprintf(stderr,"TK_L:%d NDIM:%d \n",tk_l,ndim);
}
void printAll(FILE *fp,double *epsize);
double Poly(int degree, double *coef, double x);
void convert(const double *,double *,int);
void computeEPSize(double *epsize);
void computeSpline();
void setfd(const double *ary){
for(int i=0;i<nsplines+1;i++)
fv[i]=ary[i];
for(int i=0;i<nsplines+1;i++)
dv[i]=ary[nsplines+1+i];
}
void getfd( double *ary){
for(int i=0;i<nsplines+1;i++)
ary[i]=fv[i];
for(int i=0;i<nsplines+1;i++)
ary[nsplines+1+i]=dv[i];
}
~splineEPSize(){
for(int i=0;i<nsplines;i++)
delete [] spline[i];
delete[] tk;
delete [] Tk;
delete [] fv;
delete [] dv;
delete [] spline;
}
void fillit(){
srand48(100);
for(int i=0;i<nsplines+1;i++){
fv[i]=1;
dv[i]=0;
}
}
private:
};