22 casadi_int casadi_nd_boor_dual_eval(T1* val, casadi_int* nz, casadi_int n_dims,
const T1* all_knots,
const casadi_int* offset,
const casadi_int* all_degree,
const casadi_int* strides,
const T1* all_x,
const casadi_int* lookup_mode, casadi_int* iw, T1* w) {
23 casadi_int n_iter, k, pivot, nnz;
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;
42 for (k=0;k<n_dims;++k) {
46 casadi_int degree, n_knots, n_b, L, start;
47 boor = all_boor+boor_offset[k];
49 degree = all_degree[k];
50 knots = all_knots + offset[k];
51 n_knots = offset[k+1]-offset[k];
52 n_b = n_knots-degree-1;
55 L = casadi_low(x, knots+degree, n_knots-2*degree, lookup_mode[k]);
58 if (start>n_b-degree-1) start = n_b-degree-1;
62 casadi_clear(boor, 2*degree+1);
63 if (x>=knots[0] && x<=knots[n_knots-1]) {
65 casadi_fill(boor, degree+1, 1.0);
66 }
else if (x==knots[n_knots-1]) {
68 }
else if (knots[L+degree]==x) {
74 casadi_de_boor(x, knots+start, 2*degree+2, degree, boor);
77 boor_offset[k+1] = boor_offset[k] + degree+1;
80 casadi_clear_casadi_int(index, n_dims);
83 for (pivot=n_dims-1;pivot>=0;--pivot) {
84 cumprod[pivot] = (*(all_boor+boor_offset[pivot]))*cumprod[pivot+1];
85 coeff_offset[pivot] = starts[pivot]*strides[pivot]+coeff_offset[pivot+1];
88 for (k=0;k<n_iter;++k) {
92 nz[nnz] = coeff_offset[0];
93 val[nnz++] += cumprod[0];
101 while (index[pivot]==boor_offset[pivot+1]-boor_offset[pivot]) {
103 if (pivot==n_dims-1)
break;
110 cumprod[pivot] = (*(all_boor+boor_offset[pivot]+index[pivot]))*cumprod[pivot+1];
112 coeff_offset[pivot] = (starts[pivot]+index[pivot])*strides[pivot]+coeff_offset[pivot+1];
118 cumprod[0] = (*(all_boor+index[0]))*cumprod[1];
121 coeff_offset[0] = starts[0]+index[0]+coeff_offset[1];