4 #include <grass/gmath.h>
6 static int egcmp(
const void *pa,
const void *pb);
16 buff = (
double *)G_malloc(bands * (bands + 1) *
sizeof(double));
17 tmp = (
double **)G_malloc(bands *
sizeof(
double *));
18 for (i = 0; i < bands; i++)
19 tmp[i] = &buff[i * (bands + 1)];
22 for (i = 0; i < bands; i++) {
23 for (j = 0; j < bands; j++)
24 tmp[i][j + 1] = z[j][i];
29 qsort(tmp, bands,
sizeof(
double *), egcmp);
32 for (i = 0; i < bands; i++) {
33 for (j = 0; j < bands; j++)
34 z[j][i] = tmp[i][j + 1];
47 static int egcmp(
const void *pa,
const void *pb)
49 const double *a = *(
const double *
const *)pa;
50 const double *
b = *(
const double *
const *)pb;
void G_free(void *buf)
Free allocated memory.