22 void casadi_nd_boor_eval(T1* ret, casadi_int n_dims,
const T1* all_knots,
const casadi_int* offset,
const casadi_int* all_degree,
const casadi_int* strides,
const T1* c, casadi_int m,
const T1* all_x,
const casadi_int* lookup_mode, casadi_int* iw, T1* w) {
23 casadi_int n_iter, k, i, pivot;
24 casadi_int *boor_offset, *starts, *index, *coeff_offset;
25 T1 *cumprod, *all_boor;
27 boor_offset = iw; iw+=n_dims+1;
28 starts = iw; iw+=n_dims;
29 index = iw; iw+=n_dims;
32 cumprod = w; w+= n_dims+1;
37 coeff_offset[n_dims] = 0;
40 for (k=0;k<n_dims;++k) {
44 casadi_int degree, n_knots, n_b, L, start;
45 boor = all_boor+boor_offset[k];
47 degree = all_degree[k];
48 knots = all_knots + offset[k];
49 n_knots = offset[k+1]-offset[k];
50 n_b = n_knots-degree-1;
53 L = casadi_low(x, knots+degree, n_knots-2*degree, lookup_mode[k]);
56 if (start>n_b-degree-1) start = n_b-degree-1;
60 casadi_clear(boor, 2*degree+1);
61 if (x>=knots[0] && x<=knots[n_knots-1]) {
63 casadi_fill(boor, degree+1, 1.0);
64 }
else if (x==knots[n_knots-1]) {
66 }
else if (knots[L+degree]==x) {
72 casadi_de_boor(x, knots+start, 2*degree+2, degree, boor);
75 boor_offset[k+1] = boor_offset[k] + degree+1;
78 casadi_clear_casadi_int(index, n_dims);
81 for (pivot=n_dims-1;pivot>=0;--pivot) {
82 cumprod[pivot] = (*(all_boor+boor_offset[pivot]))*cumprod[pivot+1];
83 coeff_offset[pivot] = starts[pivot]*strides[pivot]+coeff_offset[pivot+1];
86 for (k=0;k<n_iter;++k) {
89 for (i=0;i<m;++i) ret[i] += c[coeff_offset[0]+i]*cumprod[0];
97 while (index[pivot]==boor_offset[pivot+1]-boor_offset[pivot]) {
99 if (pivot==n_dims-1)
break;
106 cumprod[pivot] = (*(all_boor+boor_offset[pivot]+index[pivot]))*cumprod[pivot+1];
108 coeff_offset[pivot] = (starts[pivot]+index[pivot])*strides[pivot]+coeff_offset[pivot+1];
114 cumprod[0] = (*(all_boor+index[0]))*cumprod[1];
117 coeff_offset[0] = (starts[0]+index[0])*m+coeff_offset[1];