AcouSTO  version 2.0

◆ evalR_Rfs()

static void evalR_Rfs ( double *  pts,
unsigned  dim,
double *  p,
const double *  c,
const double *  r 
)
static

Evaluate the integration points for all 2^n points (+/-r,...+/-r)

A Gray-code ordering is used to minimize the number of coordinate updates in p, although this doesn't matter as much now that we are saving all pts.

348 {
349  unsigned i;
350  unsigned signs = 0; /* 0/1 bit = +/- for corresponding element of r[] */
351 
352  /* We start with the point where r is ADDed in every coordinate
353  (this implies signs=0). */
354  for (i = 0; i < dim; ++i)
355  p[i] = c[i] + r[i];
356 
357  /* Loop through the points in Gray-code ordering */
358  for (i = 0;; ++i) {
359  unsigned mask, d;
360 
361  memcpy(pts, p, sizeof(double) * dim); pts += dim;
362 
363  d = ls0(i); /* which coordinate to flip */
364  if (d >= dim)
365  break;
366 
367  /* flip the d-th bit and add/subtract r[d] */
368  mask = 1U << d;
369  signs ^= mask;
370  p[d] = (signs & mask) ? c[d] - r[d] : c[d] + r[d];
371  }
372 }
static unsigned ls0(unsigned n)
Definition: cubature.c:308