4 #include "local_proto.h"
14 double *a, eps, w, pw,
mean = 0, ssq = 0, *xcopy;
17 n2 = (int)floor((
double)n / 2);
20 if ((a = (
double *)
malloc(n2 *
sizeof(
double))) ==
NULL) {
21 fprintf(stderr,
"Memory error in royston\n");
24 if ((xcopy = (
double *)
malloc(n *
sizeof(
double))) ==
NULL) {
25 fprintf(stderr,
"Memory error in royston\n");
30 for (i = 0; i < n; ++i) {
36 qsort(xcopy, n,
sizeof(
double),
Cdhc_dcmp);
38 for (i = 0; i < n; ++i)
41 wcoef(a, n, n2, &eps, &ifault);
44 wext(xcopy, n, ssq, a, n2, eps, &w, &pw, &ifault);
46 fprintf(stderr,
"Error in wcoef()\n");
47 return (
double *)
NULL;
55 fprintf(stderr,
"Error in wcoef()\n");
56 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)