Beispiel #1
0
void KCtree::sampleCtr(KMpoint c)		// sample a point
{
    initBasicGlobals(dim, n_pts, pts);		// initialize globals
    // TODO: bb_save check is just for debugging.
    KMorthRect bb_save(dim, bnd_box);		// save bounding box
    root->sampleCtr(c, bnd_box);		// start at root
    for (int i = 0; i < dim; i++) {		// check that bnd_box unchanged
	assert(bb_save.lo[i] == bnd_box.lo[i] &&
	       bb_save.hi[i] == bnd_box.hi[i]);
    }
}
Beispiel #2
0
static void initDistGlobals(		// initialize distortion globals
    KMfilterCenters& ctrs)			// the centers
{
    initBasicGlobals(ctrs.getDim(), ctrs.getNPts(), ctrs.getDataPts());
    kcKCtrs	= ctrs.getK();
    kcCenters	= ctrs.getCtrPts();		// get ptrs to KMcenter arrays
    kcWeights	= ctrs.getWeights(false);
    kcSums	= ctrs.getSums(false);
    kcSumSqs	= ctrs.getSumSqs(false);
    kcDists	= ctrs.getDists(false);
    kcBoxMidpt  = kmAllocPt(kcDim);

    for (int j = 0; j < kcKCtrs; j++) {		// initialize sums
	kcWeights[j] = 0;
	kcSumSqs[j] = 0;
	for (int d = 0; d < kcDim; d++) {
    	    kcSums[j][d] = 0;
	}
    }
}
Beispiel #3
0
KCtree::KCtree(			// construct from point array
    KMdataArray		pa,		// point array (with at least n pts)
    int			n,		// number of points
    int			dd,		// dimension
    int			n_max,		// maximum number of points (optional)
    KMpoint		bb_lo,		// bounding box low point (optional)
    KMpoint		bb_hi) :	// bounding box high point (optional)
    bnd_box(dd)				// create initial bounding box
{
    // set up the basic stuff
    skeletonTree(pa, n, dd, n_max, bb_lo, bb_hi, NULL);
    initBasicGlobals(dd, n, pa);	// initialize globals

    root = buildKcTree(pa, pidx, n, dd, bnd_box);

    int ignoreMe1;			// ignore results of call
    KMpoint ignoreMe2;
    double ignoreMe3;
    // compute sums
    root->makeSums(ignoreMe1, ignoreMe2, ignoreMe3);
    assert(ignoreMe1 == n);		// should be all the points
}