18 double _statistics[10];
28 res = 0.5*(x[p[n/2-1]] + x[p[n/2]]);
53 return rand()/(
real) RAND_MAX;
66 if (n <= 0)
return NULL;
68 for (i = 0; i < n; i++) p[i] = i;
85 for (i = 0; i < n; i++) y[i] = y[i] - x[i];
91 for (i = 0; i < n; i++) y[i] = x[i] - y[i];
97 for (i = 0; i < n; i++) y[i] = x[i] + y[i];
104 for (i = 0; i < n; i++) res += x[i]*y[i];
111 for (i = 0; i < n; i++) y[i] = x[i] + beta*y[i];
118 for (i = 0; i < n; i++) x[i] = x[i] + beta*y[i];
125 for (i = 0; i < n; i++) {
126 if (i > 0) printf(
",");
138 for (i = 0; i < m; i++) {
139 assert(p[i] < n && p[i] >= 0);
149 if (!*u) *u =
MALLOC(
sizeof(
float)*m);
151 for (i = 0; i < m; i++) {
152 assert(p[i] < n && p[i] >= 0);
163 if ((ss1)[0] > (ss2)[0]){
165 }
else if ((ss1)[0] < (ss2)[0]){
176 if ((ss1)[0] > (ss2)[0]){
178 }
else if ((ss1)[0] < (ss2)[0]){
188 if ((ss1)[0] > (ss2)[0]){
190 }
else if ((ss1)[0] < (ss2)[0]){
201 if ((ss1)[0] > (ss2)[0]){
203 }
else if ((ss1)[0] < (ss2)[0]){
224 if (!*p) *p =
MALLOC(
sizeof(
int)*n);
227 for (i = 0; i < n; i++) {
238 for (i = 0; i < n; i++) (*p)[i] = (
int) u[2*i+1];
278 for (k = 0; k < dim; k++) dist += (x[i*dim+k] - x[j*dim + k])*(x[i*dim+k] - x[j*dim + k]);
286 for (k = 0; k < dim; k++) dist += (x[i*dim+k] - x[j*dim + k])*(x[i*dim+k] - x[j*dim + k]);
295 for (i = 0; i < dim; i++) dist += (p1[i] - p2[i])*(p1[i] - p2[i]);
302 for (i = strlen(s); i >= 0; i--) {
303 if (first && s[i] ==
'.') {
307 if (s[i] ==
'/')
return (
char*) &(s[i+1]);
313 real min[3],
max[3], min0[3], ratio = 1;
316 for (i = 0; i < dim; i++) {
321 for (i = 0; i < n; i++){
322 for (k = 0; k < dim; k++) {
323 min[k] =
MIN(x[i*dim+k], min[k]);
324 max[k] =
MAX(x[i*dim+k], max[k]);
328 if (max[0] - min[0] != 0) {
329 ratio = (xmax-
xmin)/(max[0] - min[0]);
331 if (max[1] - min[1] != 0) {
332 ratio =
MIN(ratio, (ymax-ymin)/(max[1] - min[1]));
338 for (i = 0; i < n; i++){
339 for (k = 0; k < dim; k++) {
340 x[i*dim+k] = min0[k] + (x[i*dim+k] - min[k])*ratio;
348 while (*s && *s -
'0' >= 0 && *s -
'0' <= 9) {
356 char *p = to_convert;
359 val = strtoul(to_convert, &p, 10);
void s1(graph_t *, node_t *)
real * vector_saxpy(int n, real *x, real *y, real beta)
int excute_system_command(char *s1, char *s2)
real point_distance(real *p1, real *p2, int dim)
int comp_ascend(const void *s1, const void *s2)
void vector_take(int n, real *v, int m, int *p, real **u)
int comp_descend_int(const void *s1, const void *s2)
void vector_float_take(int n, float *v, int m, int *p, float **u)
int comp_descend(const void *s1, const void *s2)
real * vector_add_to(int n, real *x, real *y)
real distance(real *x, int dim, int i, int j)
real * vector_saxpy2(int n, real *x, real *y, real beta)
real * vector_subtract_to(int n, real *x, real *y)
int * random_permutation(int n)
char * strip_dir(char *s)
int validQ_int_string(char *to_convert, int *v)
int comp_ascend_int(const void *s1, const void *s2)
real vector_product(int n, real *x, real *y)
void vector_ordering(int n, real *v, int **p, int ascending)
void vector_sort_real(int n, real *v, int ascending)
real vector_median(int n, real *x)
void vector_sort_int(int n, int *v, int ascending)
real vector_percentile(int n, real *x, real y)
double dist(Site *s, Site *t)
real * vector_subtract_from(int n, real *x, real *y)
real distance_cropped(real *x, int dim, int i, int j)
void vector_print(char *s, int n, real *x)
int excute_system_command3(char *s1, char *s2, char *s3)