4 #include "local_proto.h" 16 double *a, eps, w, pw,
mean = 0, ssq = 0, *xcopy;
19 n2 = (int)floor((
double)n / 2);
22 if ((a = (
double *)
malloc(n2 *
sizeof(
double))) ==
NULL) {
23 fprintf(stderr,
"Memory error in royston\n");
26 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
27 fprintf(stderr,
"Memory error in royston\n");
32 for (i = 0; i < n; ++i) {
38 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
40 for (i = 0; i < n; ++i)
41 ssq += (mean - x[i]) * (mean - x[i]);
43 wcoef(a, n, n2, &eps, &ifault);
46 wext(xcopy, n, ssq, a, n2, eps, &w, &pw, &ifault);
48 fprintf(stderr,
"Error in wcoef()\n");
49 return (
double *)
NULL;
57 fprintf(stderr,
"Error in wcoef()\n");
58 return (
double *)
NULL;
void wext(double x[], int n, double ssq, double a[], int n2, double eps, double *w, double *pw, int *ifault)
double * Cdhc_royston(double *x, int n)
int Cdhc_dcmp(const void *i, const void *j)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
void wcoef(double a[], int n, int n2, double *eps, int *ifault)