Debian Codegraph @

extern/bs.h

raw symbols SCIP
1 #ifndef BS_H
2 #define BS_H
3
4 //-----------------------------------------------------------------------------
5 // Error codes
6 //-----------------------------------------------------------------------------
7
8 typedef enum {
9 BS_OK = 0,
10 BS_OUTOFMEMORY = 1,
11 BS_DOMAINERROR = 2,
12 BS_NOTMONOTONIC = 3,
13 BS_SIZEMISMATCH = 4,
14 BS_BCSIZEMISMATCH = 5,
15 BS_TOOFEWPOINTS = 6,
16 } bs_errorcode;
17
18
19 //-----------------------------------------------------------------------------
20 // Input data types
21 //-----------------------------------------------------------------------------
22
23 typedef struct {
24 double *data;
25 int size;
26 int stride;
27 } bs_array;
28
29 typedef struct {
30 double *data;
31 int sizes[2];
32 int strides[2];
33 } bs_array2d;
34
35 typedef struct {
36 double min; // inclusive
37 double max; // inclusive
38 } bs_range;
39
40 //-----------------------------------------------------------------------------
41 // Boundary conditions
42 //-----------------------------------------------------------------------------
43
44 typedef enum {BS_DERIV1, BS_DERIV2, BS_NOTAKNOT} bs_bctype;
45
46 typedef struct {
47 bs_bctype type;
48 double value;
49 } bs_bc;
50
51 typedef struct {
52 bs_bc left;
53 bs_bc right;
54 } bs_bcs;
55
56 // array boundary conditions for spline2d.
57 typedef struct {
58 bs_bctype type;
59 double *data;
60 int size;
61 int stride;
62 } bs_bcarray;
63
64 typedef struct {
65 bs_bcarray left;
66 bs_bcarray right;
67 } bs_bcarray_pair;
68
69 //-----------------------------------------------------------------------------
70 // out-of-domain behavior ("extension")
71 //-----------------------------------------------------------------------------
72
73 typedef enum {BS_EXTRAPOLATE, BS_CONSTANT, BS_VALUE, BS_RAISE} bs_exttype;
74
75 typedef struct {
76 bs_exttype type;
77 double value;
78 } bs_ext;
79
80 typedef struct {
81 bs_ext left;
82 bs_ext right;
83 } bs_exts;
84
85 //-----------------------------------------------------------------------------
86 // 1-d splines
87 //-----------------------------------------------------------------------------
88
89 typedef struct {
90 double *knots;
91 double *consts;
92 double *coeffs;
93 int n;
94 bs_exts exts;
95 } bs_spline1d;
96
97 bs_errorcode bs_spline1d_create(bs_array x, bs_array y, bs_bcs bcs,
98 bs_exts exts, bs_spline1d **out);
99 bs_errorcode bs_spline1d_eval(bs_spline1d *spline, bs_array x, bs_array out);
100 void bs_spline1d_free(bs_spline1d *spline);
101
102
103 typedef struct {
104 bs_range x;
105 double didx;
106 double *coeffs;
107 int n;
108 bs_exts exts;
109 } bs_uspline1d;
110
111 bs_errorcode bs_uspline1d_create(bs_range x, bs_array y,
112 bs_bcs bcs, bs_exts exts, bs_uspline1d **out);
113 bs_errorcode bs_uspline1d_eval(bs_uspline1d *spline, bs_array x, bs_array out);
114 void bs_uspline1d_free(bs_uspline1d *spline);
115
116
117 //-----------------------------------------------------------------------------
118 // 2-d splines
119 //-----------------------------------------------------------------------------
120
121 typedef struct {
122 double *xknots;
123 double *xconsts;
124 double *yknots;
125 double *yconsts;
126 double *coeffs;
127 int nx;
128 int ny;
129 bs_exts xexts;
130 bs_exts yexts;
131 } bs_spline2d;
132
133 bs_errorcode bs_spline2d_create(bs_array x, bs_array y, bs_array2d z,
134 bs_bcarray_pair xbcs, bs_bcarray_pair ybcs,
135 bs_exts xexts, bs_exts yexts,
136 bs_spline2d **out);
137 bs_errorcode bs_spline2d_eval(bs_spline2d *spline, bs_array x, bs_array y, bs_array2d out);
138 void bs_spline2d_free(bs_spline2d *spline);
139
140
141 #endif