13 #define lob_bnd_setup PREFIXED_NAME(lob_bnd_setup)
14 #define lob_bnd_lin_1 PREFIXED_NAME(lob_bnd_lin_1)
15 #define lob_bnd_lin_2 PREFIXED_NAME(lob_bnd_lin_2)
16 #define lob_bnd_lin_3 PREFIXED_NAME(lob_bnd_lin_3)
17 #define lob_bnd_1 PREFIXED_NAME(lob_bnd_1 )
18 #define lob_bnd_2 PREFIXED_NAME(lob_bnd_2 )
19 #define lob_bnd_3 PREFIXED_NAME(lob_bnd_3 )
71 #define PI 3.1415926535897932384626433832795028841971693993751058209749445923
75 unsigned nm = n*m,
i,j;
89 for(i=n;
i;) --i, Q[2*i]=Q[i]/2, Q[2*i+1] = 3*Q[2*i]*z[i];
93 h[0] = -1, h[m-1] = 1;
94 for(j=1;j<m-1;++j) h[j] = cos((m-1-j)*
PI/(m-1));
99 lb[(i*m+ 0)*2+1]=lb[(i*m+ 0)*2+0]=(i== 0?1:0),
100 lb[(i*m+m-1)*2+1]=lb[(i*m+m-1)*2+0]=(i==n-1?1:0);
102 lag(pl,gll_data,n,1,(h[0]+h[1])/2);
104 double x = h[j], xl = (x+h[j-1])/2, xr = (x+h[j+1])/2;
105 lag(pr,gll_data,n,1,xr);
106 lag(p ,gll_data,n,0,x );
108 double lo,up, cl = pl[
i] + (x-xl)*dl[i],
cr = pr[i] + (x-xr)*dr[
i];
109 if(cl<
cr) lo=cl,up=
cr;
else lo=
cr,up=cl;
110 if(p[i]<lo) lo=p[
i];
if(up<p[i]) up=p[
i];
111 lb[(i*m+j)*2+0] = lo, lb[(i*m+j)*2+1] = up;
113 memcpy(pl,pr,2*n*
sizeof(
double));
119 lbnp[4*i+0]=lbnp[4*i+1]=lbnp[4*i+2]=lbnp[4*i+3]=0;
120 if((f=lb[2*i+0])<0) lbnp[4*i+0]=f;
else lbnp[4*i+1]=f;
121 if((f=lb[2*i+1])<0) lbnp[4*i+2]=f;
else lbnp[4*i+3]=f;
130 const double *
restrict lb,
unsigned n,
unsigned m,
135 for(i=0;i<
n;++
i) a0 += Q[2*i]*u[i], a1 += Q[2*i+1]*u[i];
136 for(j=0;j<m;++j) b[2*j+1] = b[2*j+0] = a0 + a1*h[j];
138 double w = u[
i] - (a0 + a1*z[
i]);
140 for(j=0;j<m;++j) b[2*j+0]+=w*lb[0], b[2*j+1]+=w*lb[1], lb+=2;
142 for(j=0;j<m;++j) b[2*j+0]+=w*lb[1], b[2*j+1]+=w*lb[0], lb+=2;
149 const double *
restrict lbnp,
unsigned n,
unsigned m,
156 for(i=0;i<
mr;++
i) a[2*i+1]=a[2*i+0]=0;
158 double t, q0 = Q[2*j], q1 = Q[2*j+1];
159 for(i=0;i<
mr;++
i) t=(br[0]+br[1])/2, br+=2, a[2*
i]+=q0*t, a[2*i+1]+=q1*t;
162 double a0=a[2*
i],a1=a[2*i+1];
163 for(k=0;k<m;++k) b[1]=b[0]=a0+a1*h[k], b+=2;
166 for(j=0;j<
n;++j,lbnp+=4*m) {
170 double t = a[2*
i] + a[2*i+1]*zj;
171 double w0 = *br++ - t;
172 double w1 = *br++ - t;
175 *b++ += w0 * lbnp[4*k+1] + w1 * lbnp[4*k+0],
176 *b++ += w1 * lbnp[4*k+3] + w0 * lbnp[4*k+2];
179 *b++ += w0 * lbnp[4*k+3] + w1 * lbnp[4*k+2],
180 *b++ += w1 * lbnp[4*k+1] + w0 * lbnp[4*k+0];
183 *b++ += w0 * lbnp[4*k+3] + w1 * lbnp[4*k+0],
184 *b++ += w1 * lbnp[4*k+3] + w0 * lbnp[4*k+0];
190 const double *
restrict lob_bnd_data,
unsigned n,
unsigned m,
193 const double *
z=lob_bnd_data, *
Q=z+
n, *h=Q+2*
n, *lb=h+m;
194 for(;un;--un, u+=
n, b+=2*m)
lob_bnd_fst(b, z,Q,h,lb,n,m, u);
200 const double *lob_bnd_data_r,
unsigned nr,
unsigned mr,
201 const double *lob_bnd_data_s,
unsigned ns,
unsigned ms,
204 unsigned mrs = mr*ms;
205 const double *
zr=lob_bnd_data_r,*Qr=zr+
nr,*hr=Qr+2*
nr,*lb_r=hr+
mr;
206 const double *
zs=lob_bnd_data_s,*
Qs=zs+
ns,*hs=Qs+2*
ns,*lbnp_s=hs+ms+2*ns*ms;
207 double *a =
work, *br = a+2*
mr;
208 for(;un;--un, b+=2*mrs) {
209 double *br_;
unsigned i;
210 for(i=0,br_=br;i<
ns;++
i,br_+=2*
mr,u+=
nr)
219 const double *lob_bnd_data_r,
unsigned nr,
unsigned mr,
220 const double *lob_bnd_data_s,
unsigned ns,
unsigned ms,
221 const double *lob_bnd_data_t,
unsigned nt,
unsigned mt,
224 unsigned nst=ns*nt, mrst=mr*ms*mt, mrs=mr*ms, mr_ns=mr*
ns;
225 const double *
zr=lob_bnd_data_r,*Qr=zr+
nr,*hr=Qr+2*
nr,*lb_r=hr+
mr;
226 const double *
zs=lob_bnd_data_s,*
Qs=zs+
ns,*hs=Qs+2*
ns,*lbnp_s=hs+ms+2*ns*ms;
227 const double *
zt=lob_bnd_data_t,*Qt=zt+nt,*ht=Qt+2*nt,*lbnp_t=ht+mt+2*nt*mt;
228 double *a =
work, *bs = a+2*mr*ms;
229 for(;un;--un, b+=2*mrst) {
230 double *br_, *bs_;
unsigned i;
231 for(i=0,br_=b;i<nst;++
i,br_+=2*
mr,u+=
nr)
233 for(i=0,br_=b,bs_=bs;i<nt;++
i,br_+=2*mr_ns,bs_+=2*mrs)
234 lob_bnd_ext(bs_, zs,Qs,hs,lbnp_s,ns,ms, br_,mr, a);
242 bnd.
min = b[0], bnd.
max = b[1];
243 for(--m,b+=2;m;--m,b+=2)
251 const double *
restrict lob_bnd_data,
unsigned n,
unsigned m,
261 const double *lob_bnd_data_r,
unsigned nr,
unsigned mr,
262 const double *lob_bnd_data_s,
unsigned ns,
unsigned ms,
267 lob_bnd_data_s,
ns,ms, u,1,
work+2*m);
274 const double *lob_bnd_data_r,
unsigned nr,
unsigned mr,
275 const double *lob_bnd_data_s,
unsigned ns,
unsigned ms,
276 const double *lob_bnd_data_t,
unsigned nt,
unsigned mt,
279 unsigned m =
mr*ms*mt;
281 lob_bnd_data_s,
ns,ms,
282 lob_bnd_data_t,nt,mt, u,1,
work+2*m);
#define tmalloc(type, count)
static const unsigned mr[D]
void lagrange_fun(double *restrict p, double *restrict data, unsigned n, int d, double x)
static void lob_bnd_fst(double *restrict b, const double *restrict z, const double *restrict Q, const double *restrict h, const double *restrict lb, unsigned n, unsigned m, const double *restrict u)
static struct dbl_range minmax(const double *restrict b, unsigned m)
static const unsigned nr[3]
static double work[TNR *NS]
establishes some macros to establish naming conventions
static void lob_bnd_ext(double *restrict b_, const double *restrict z, const double *restrict Q, const double *restrict h, const double *restrict lbnp, unsigned n, unsigned m, const double *restrict br_, unsigned mr, double *restrict a)
static double z[NR *NS *NT *N]