PostGIS  2.1.10dev-r@@SVN_REVISION@@
static int nd_stats_value_index ( const ND_STATS stats,
int *  indexes 
)
static

Given a position in the n-d histogram (i,j,k) return the position in the 1-d values array.

Definition at line 343 of file gserialized_estimate.c.

References ND_STATS_T::ndims, and ND_STATS_T::size.

Referenced by compute_gserialized_stats_mode(), estimate_join_selectivity(), and estimate_selectivity().

344 {
345  int d;
346  int accum = 1, vdx = 0;
347 
348  /* Calculate the index into the 1-d values array that the (i,j,k,l) */
349  /* n-d histogram coordinate implies. */
350  /* index = x + y * sizex + z * sizex * sizey + m * sizex * sizey * sizez */
351  for ( d = 0; d < (int)(stats->ndims); d++ )
352  {
353  int size = (int)(stats->size[d]);
354  if ( indexes[d] < 0 || indexes[d] >= size )
355  {
356  POSTGIS_DEBUGF(3, " bad index at (%d, %d)", indexes[0], indexes[1]);
357  return -1;
358  }
359  vdx += indexes[d] * accum;
360  accum *= size;
361  }
362  return vdx;
363 }
float4 size[ND_DIMS]

Here is the caller graph for this function: