Doxygen Source Code Documentation
ranks.c File Reference
Go to the source code of this file.
Data Structures | |
struct | node |
Typedefs | |
typedef node | node |
Functions | |
void | list_print (node *n, int *count) |
void | list_delete (node **n) |
void | node_insert (node **n, float r) |
void | node_addvalue (node **head, float r) |
float | node_get_rank (node *head, float r) |
float | node_get_value (node *head, int rank) |
float | node_get_median (node *head, int n) |
float * | rank_array (int n, float *xarray) |
float * | rank_darray (int n, double *darray) |
Typedef Documentation
|
|
Function Documentation
|
Definition at line 56 of file ranks.c. References free. Referenced by calc_shift(), calc_stat(), rank_array(), and rank_darray().
00057 { 00058 if ((*n)->next != NULL) 00059 list_delete (&((*n)->next)); 00060 free (*n); 00061 *n = NULL; 00062 } |
|
Definition at line 34 of file ranks.c. References node::d, node::fval, i, and node::next. Referenced by calc_shift().
|
|
Definition at line 88 of file ranks.c. References node::d, node::fval, node::next, node_insert(), and r. Referenced by calc_shift(), calc_stat(), rank_array(), and rank_darray().
00089 { 00090 node ** lastptr; 00091 node * ptr; 00092 00093 00094 if (*head == NULL) node_insert (head, r); 00095 else 00096 { 00097 lastptr = head; 00098 ptr = *head; 00099 00100 while ( (ptr->fval < r) && (ptr->next != NULL) ) 00101 { 00102 lastptr = &(ptr->next); 00103 ptr = ptr->next; 00104 } 00105 00106 if (ptr->fval > r) 00107 node_insert (lastptr, r); 00108 else 00109 if (ptr->fval == r) 00110 ptr->d += 1; 00111 else 00112 node_insert (&(ptr->next), r); 00113 } 00114 } |
|
Definition at line 169 of file ranks.c. References node_get_value(). Referenced by calc_shift().
00170 { 00171 float median; 00172 00173 00174 if (n % 2) 00175 median = node_get_value(head, n/2 + 1); 00176 else 00177 median = 0.5 * (node_get_value(head, n/2) + 00178 node_get_value(head, n/2 + 1)); 00179 00180 return (median); 00181 } |
|
Definition at line 122 of file ranks.c. References node::d, node::fval, node::next, and r. Referenced by calc_stat(), rank_array(), and rank_darray().
|
|
Definition at line 146 of file ranks.c. References node::d, node::fval, and node::next. Referenced by node_get_median().
|
|
Definition at line 70 of file ranks.c. Referenced by node_addvalue().
|
|
Definition at line 191 of file ranks.c. References i, list_delete(), malloc, MTEST, node_addvalue(), and node_get_rank(). Referenced by calc_stat().
00196 { 00197 int i; /* array index */ 00198 node * xhead = NULL; /* pointer to list of sorted values */ 00199 float * rarray = NULL; /* array of ranks */ 00200 00201 00202 /*----- Allocate memory for array of ranks -----*/ 00203 rarray = (float *) malloc (sizeof(float) * n); MTEST (rarray); 00204 00205 00206 /*----- Enter and sort original data -----*/ 00207 for (i = 0; i < n; i++) 00208 node_addvalue (&xhead, xarray[i]); 00209 00210 00211 /*----- Get ranks of data -----*/ 00212 for (i = 0; i < n; i++) 00213 rarray[i] = node_get_rank (xhead, xarray[i]); 00214 00215 00216 /*----- Deallocate memory -----*/ 00217 list_delete (&xhead); 00218 00219 00220 /*----- Return array of ranks -----*/ 00221 return (rarray); 00222 } |
|
Definition at line 232 of file ranks.c. References i, list_delete(), malloc, MTEST, node_addvalue(), and node_get_rank(). Referenced by init_delay(), init_regression_analysis(), and regression_analysis().
00237 { 00238 int i; /* array index */ 00239 node * xhead = NULL; /* pointer to list of sorted values */ 00240 float * rarray = NULL; /* array of ranks */ 00241 00242 00243 /*----- Allocate memory for array of ranks -----*/ 00244 rarray = (float *) malloc (sizeof(float) * n); MTEST (rarray); 00245 00246 00247 /*----- Enter and sort original data -----*/ 00248 for (i = 0; i < n; i++) 00249 node_addvalue (&xhead, (float) darray[i]); 00250 00251 00252 /*----- Get ranks of data -----*/ 00253 for (i = 0; i < n; i++) 00254 rarray[i] = node_get_rank (xhead, (float) darray[i]); 00255 00256 00257 /*----- Deallocate memory -----*/ 00258 list_delete (&xhead); 00259 00260 00261 /*----- Return array of ranks -----*/ 00262 return (rarray); 00263 } |