4 #include "local_proto.h"
15 double *a, eps, w, pw,
mean = 0, ssq = 0, *xcopy;
18 n2 = (int)floor((
double)n / 2);
21 if ((a = (
double *)
malloc(n2 *
sizeof(
double))) ==
NULL) {
22 fprintf(stderr,
"Memory error in royston\n");
25 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
26 fprintf(stderr,
"Memory error in royston\n");
31 for (i = 0; i < n; ++i) {
37 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
39 for (i = 0; i < n; ++i)
42 wcoef(a, n, n2, &eps, &ifault);
45 wext(xcopy, n, ssq, a, n2, eps, &w, &pw, &ifault);
47 fprintf(stderr,
"Error in wcoef()\n");
48 return (
double *)
NULL;
56 fprintf(stderr,
"Error in wcoef()\n");
57 return (
double *)
NULL;
void wext(double x[], int n, double ssq, double a[], int n2, double eps, double *w, double *pw, int *ifault)
void wcoef(double a[], int n, int n2, double *eps, int *ifault)
int Cdhc_dcmp(const void *i, const void *j)
float mean(IClass_statistics *statistics, int band)
Helper function for computing mean.
double * Cdhc_royston(double *x, int n)