/* See dg_spline.h */ /* Last edited on 2007-01-04 00:16:44 by stolfi */ #include #include #include #include /* INTERNAL PROTOTYPES */ /* IMPLEMENTATIONS */ void dg_tent_alloc_explicit_rep ( dg_dim_t d, dg_degree_t g, dg_node_t_t *root ) { int nCoefs = ipow(g+1, d); bz_Degrees gg; int i; for (i = 0; i < d; i++) { gg[i] = g; } auto void do_alloc(dg_node_t_t *t); void do_alloc(dg_node_t_t *t) { if (t != NULL) { double *c = (double *)notnull(malloc(nCoefs * sizeof(double))); int k; for (k = 0; k < nCoefs; k++) { c[k] = 0.0; } t->data = c; do_alloc(t->ch[0]); do_alloc(t->ch[1]); } } do_alloc(root); } void dg_tent_free_explicit_rep(dg_node_t_t *root) { if (root != NULL) { if (root->data != NULL) { free(root->data); } dg_tent_free_explicit_rep(root->ch[0]); dg_tent_free_explicit_rep(root->ch[1]); } } void dg_tent_flatten(dg_tent_vec_t *tv, double_vect_t *a, dg_node_t_t *root); /* Computes the dyadic spline which is the linear combination { SUM {a[i]*tv[i] : i = 0..tv.nel-1} } and stores its explicit Bézier representation in the leaves of tree {root}. Assumes that the grid dimension is {d} and that the tents have degree {g} and continuity {c}. Assumes also that the data pointer of each node points to a Bézier control point array of degree {g} and dimension {d}. */