wkmeans.c
PREC compute_rms1(const PREC *CX, const PREC *X, const PREC *W, const unsigned int *c, unsigned int dim, unsigned int npts)
{
  PREC sum = 0.0;
  PREC rms = 0.0;
  const PREC *px = X;
  for ( unsigned int i=0 ; i<npts ; i++, px+=dim)
    {
      const PREC *pcx = CX+c[i]*dim;
      PREC d = compute_distance(px, pcx, dim);
      rms += W[i]*d*d;	// DY: we just took sqrt, this is inefficient, need sqdist fn
      sum += W[i];
    }
  rms /= sum;
  rms = sqrt(rms);
  assert(rms>=0.0);
  return(rms);
}
/* This computes the within cluster root-mean-squared distance */
This computes the within cluster root-mean-squared distance
This computes the within cluster root - mean - squared distance
PREC compute_rms1(const PREC *CX, const PREC *X, const PREC *W, const unsigned int *c, unsigned int dim, unsigned int npts)
{
  PREC sum = 0.0;
  PREC rms = 0.0;
  const PREC *px = X;
  for ( unsigned int i=0 ; i<npts ; i++, px+=dim)
    {
      const PREC *pcx = CX+c[i]*dim;
      PREC d = compute_distance(px, pcx, dim);
      rms += W[i]*d*d;	
      sum += W[i];
    }
  rms /= sum;
  rms = sqrt(rms);
  assert(rms>=0.0);
  return(rms);
}
PREC compute_rms1 ( const PREC * CX , const PREC * X , const PREC * W , const unsigned int * c , unsigned int dim , unsigned int npts ) { PREC sum = 0.0 ; PREC rms = 0.0 ; const PREC * px = X ; for ( unsigned int i = 0 ; i < npts ; i ++ , px += dim ) { const PREC * pcx = CX + c [ i ] * dim ; PREC d = compute_distance ( px , pcx , dim ) ; rms += W [ i ] * d * d ; sum += W [ i ] ; } rms /= sum ; rms = sqrt ( rms ) ; assert ( rms >= 0.0 ) ; return ( rms ) ; }
This computes the within cluster root-mean-squared distance
This computes the within cluster root - mean - squared distance
// DY: we just took sqrt, this is inefficient, need sqdist fn