... | ... |
@@ -57,9 +57,9 @@ void malloc_gene_data(GENE_DATA* pdata) |
57 | 57 |
int nrow=pdata->nrow; |
58 | 58 |
int ncol=pdata->ncol; |
59 | 59 |
|
60 |
- pdata->id=(char**)Calloc(nrow,char*); |
|
61 |
- pdata->d=(float**)Calloc(nrow,float*); |
|
62 |
- pdata->L=(int*)Calloc(ncol,int); |
|
60 |
+ pdata->id=(char**)R_Calloc(nrow,char*); |
|
61 |
+ pdata->d=(float**)R_Calloc(nrow,float*); |
|
62 |
+ pdata->L=(int*)R_Calloc(ncol,int); |
|
63 | 63 |
|
64 | 64 |
/*initialization*/ |
65 | 65 |
memset(pdata->L,0,sizeof(int)*ncol); |
... | ... |
@@ -67,8 +67,8 @@ void malloc_gene_data(GENE_DATA* pdata) |
67 | 67 |
pdata->L[i]=0; |
68 | 68 |
|
69 | 69 |
for (i=0; i<nrow; i++) { |
70 |
- pdata->id[i] = (char *) Calloc(MAX_ID,char); |
|
71 |
- pdata->d[i]=(float *) Calloc(ncol,float); |
|
70 |
+ pdata->id[i] = (char *) R_Calloc(MAX_ID,char); |
|
71 |
+ pdata->d[i]=(float *) R_Calloc(ncol,float); |
|
72 | 72 |
} |
73 | 73 |
} |
74 | 74 |
|
... | ... |
@@ -80,12 +80,12 @@ void free_gene_data(GENE_DATA* pdata) |
80 | 80 |
{ |
81 | 81 |
int i; |
82 | 82 |
for (i=0; i<pdata->nrow; i++) { |
83 |
- Free(pdata->d[i]); |
|
84 |
- Free(pdata->id[i]); |
|
83 |
+ R_Free(pdata->d[i]); |
|
84 |
+ R_Free(pdata->id[i]); |
|
85 | 85 |
} |
86 |
- Free(pdata->L); |
|
87 |
- Free(pdata->d); |
|
88 |
- Free(pdata->id); |
|
86 |
+ R_Free(pdata->L); |
|
87 |
+ R_Free(pdata->d); |
|
88 |
+ R_Free(pdata->id); |
|
89 | 89 |
} |
90 | 90 |
|
91 | 91 |
/********************************************************************************/ |
... | ... |
@@ -142,11 +142,11 @@ void get1pvalue(GENE_DATA* pdata,int* L,float* T,float* P, |
142 | 142 |
int nrow=pdata->nrow; |
143 | 143 |
int B=(*func_first_sample)(NULL); |
144 | 144 |
/*allocate the space and initialziation*/ |
145 |
- bT=(float*)Calloc(nrow,float); |
|
146 |
- bL=(int*)Calloc(ncol,int); |
|
147 |
- count=(float*)Calloc(nrow,float); |
|
145 |
+ bT=(float*)R_Calloc(nrow,float); |
|
146 |
+ bL=(int*)R_Calloc(ncol,int); |
|
147 |
+ count=(float*)R_Calloc(nrow,float); |
|
148 | 148 |
memset(count,0,sizeof(float)*nrow); |
149 |
- total=(int*)Calloc(nrow,int); |
|
149 |
+ total=(int*)R_Calloc(nrow,int); |
|
150 | 150 |
memset(total,0,sizeof(int)*nrow); |
151 | 151 |
|
152 | 152 |
/*comuter the original one first*/ |
... | ... |
@@ -184,10 +184,10 @@ void get1pvalue(GENE_DATA* pdata,int* L,float* T,float* P, |
184 | 184 |
} |
185 | 185 |
|
186 | 186 |
/*free the spaces*/ |
187 |
- Free(bT); |
|
188 |
- Free(count); |
|
189 |
- Free(total); |
|
190 |
- Free(bL); |
|
187 |
+ R_Free(bT); |
|
188 |
+ R_Free(count); |
|
189 |
+ R_Free(total); |
|
190 |
+ R_Free(bL); |
|
191 | 191 |
} |
192 | 192 |
|
193 | 193 |
/********************************************************************************/ |
... | ... |
@@ -203,8 +203,8 @@ void sort_gene_data(GENE_DATA* pdata,int*R) |
203 | 203 |
int i,nrow=pdata->nrow; |
204 | 204 |
char** old_id; /*the old addresses of the gene id*/ |
205 | 205 |
float** old_d; /*th old addresses of the gene data*/ |
206 |
- old_d=(float**)Calloc(nrow,float*); |
|
207 |
- old_id=(char**)Calloc(nrow,char*); |
|
206 |
+ old_d=(float**)R_Calloc(nrow,float*); |
|
207 |
+ old_id=(char**)R_Calloc(nrow,char*); |
|
208 | 208 |
/*store the original pointers from pdata*/ |
209 | 209 |
for(i=0;i<nrow;i++) |
210 | 210 |
{ |
... | ... |
@@ -217,8 +217,8 @@ void sort_gene_data(GENE_DATA* pdata,int*R) |
217 | 217 |
pdata->d[i]=old_d[R[i]]; |
218 | 218 |
pdata->id[i]=old_id[R[i]]; |
219 | 219 |
} |
220 |
- Free(old_id); |
|
221 |
- Free(old_d); |
|
220 |
+ R_Free(old_id); |
|
221 |
+ R_Free(old_d); |
|
222 | 222 |
} |
223 | 223 |
/********************************************************************************/ |
224 | 224 |
/* sort_vector */ |
... | ... |
@@ -231,12 +231,12 @@ void sort_vector(float* V,int*R,int n) |
231 | 231 |
{ |
232 | 232 |
float* old_V; |
233 | 233 |
int i; |
234 |
- old_V=(float*)Calloc(n,float); |
|
234 |
+ old_V=(float*)R_Calloc(n,float); |
|
235 | 235 |
for(i=0;i<n;i++) |
236 | 236 |
old_V[i]=V[i]; |
237 | 237 |
for(i=0;i<n;i++) |
238 | 238 |
V[i]=old_V[R[i]]; |
239 |
- Free(old_V); |
|
239 |
+ R_Free(old_V); |
|
240 | 240 |
} |
241 | 241 |
/********************************************************************************/ |
242 | 242 |
/* get_all_samples_P */ |
... | ... |
@@ -261,8 +261,8 @@ void get_all_samples_P(float* V, int n,float* P,float na, |
261 | 261 |
|
262 | 262 |
B=(*func_first_sample)(NULL); |
263 | 263 |
/*allocate the spaces*/ |
264 |
- L=(int*)Calloc(n,int); |
|
265 |
- R=(int*)Calloc(B,int); |
|
264 |
+ L=(int*)R_Calloc(n,int); |
|
265 |
+ R=(int*)R_Calloc(B,int); |
|
266 | 266 |
|
267 | 267 |
/*compute all the test_stat*/ |
268 | 268 |
(*func_first_sample)(L); |
... | ... |
@@ -306,8 +306,8 @@ void get_all_samples_P(float* V, int n,float* P,float na, |
306 | 306 |
P[R[b]]=NA_FLOAT; |
307 | 307 |
|
308 | 308 |
/*free the space*/ |
309 |
- Free(L); |
|
310 |
- Free(R); |
|
309 |
+ R_Free(L); |
|
310 |
+ R_Free(R); |
|
311 | 311 |
} |
312 | 312 |
|
313 | 313 |
/*get all the samples of T and they're also ordered.It's used only for diagonsis*/ |
... | ... |
@@ -319,8 +319,8 @@ void get_all_samples_T(float* V, int n,float* T,float na, |
319 | 319 |
|
320 | 320 |
B=(*func_first_sample)(NULL); |
321 | 321 |
/*allocate the spaces*/ |
322 |
- L=(int*)Calloc(n,int); |
|
323 |
- R=(int*)Calloc(B,int); |
|
322 |
+ L=(int*)R_Calloc(n,int); |
|
323 |
+ R=(int*)R_Calloc(B,int); |
|
324 | 324 |
|
325 | 325 |
/*compute all the test_stat*/ |
326 | 326 |
(*func_first_sample)(L); |
... | ... |
@@ -336,8 +336,8 @@ void get_all_samples_T(float* V, int n,float* T,float na, |
336 | 336 |
} |
337 | 337 |
if(myDEBUG) |
338 | 338 |
print_farray(stderr,T,B); |
339 |
- Free(L); |
|
340 |
- Free(R); |
|
339 |
+ R_Free(L); |
|
340 |
+ R_Free(R); |
|
341 | 341 |
} |
342 | 342 |
|
343 | 343 |
void adj_pvalue_quick(GENE_DATA* pdata,float*T, float* P, |
... | ... |
@@ -353,10 +353,10 @@ void adj_pvalue_quick(GENE_DATA* pdata,float*T, float* P, |
353 | 353 |
|
354 | 354 |
/*allocate the space*/ |
355 | 355 |
B=(*func_first_sample)(NULL); |
356 |
- L=(int*)Calloc(ncol,int); |
|
357 |
- R=(int*)Calloc(nrow,int); |
|
358 |
- all_P=(float*)Calloc(B,float); |
|
359 |
- all_Q=(float*)Calloc(B,float); |
|
356 |
+ L=(int*)R_Calloc(ncol,int); |
|
357 |
+ R=(int*)R_Calloc(nrow,int); |
|
358 |
+ all_P=(float*)R_Calloc(B,float); |
|
359 |
+ all_Q=(float*)R_Calloc(B,float); |
|
360 | 360 |
|
361 | 361 |
/*get the original unadjusted p-values first |
362 | 362 |
we'll use the normalized t-statistics*/ |
... | ... |
@@ -435,10 +435,10 @@ void adj_pvalue_quick(GENE_DATA* pdata,float*T, float* P, |
435 | 435 |
Adj_Lower[i]=Adj_Lower[i-1]; |
436 | 436 |
|
437 | 437 |
/*free the spaces*/ |
438 |
- Free(L); |
|
439 |
- Free(R); |
|
440 |
- Free(all_P); |
|
441 |
- Free(all_Q); |
|
438 |
+ R_Free(L); |
|
439 |
+ R_Free(R); |
|
440 |
+ R_Free(all_P); |
|
441 |
+ R_Free(all_Q); |
|
442 | 442 |
} |
443 | 443 |
|
444 | 444 |
/********************************************************************************/ |
... | ... |
@@ -478,18 +478,18 @@ void adj_by_T(GENE_DATA* pdata,float* T,float* P,float*Adj_P, |
478 | 478 |
int nrow=pdata->nrow; |
479 | 479 |
int B=(*func_first_sample)(NULL); |
480 | 480 |
/*allocate the space and initialziation*/ |
481 |
- bT=(float*)Calloc(nrow,float); |
|
482 |
- bL=(int*)Calloc(ncol,int); |
|
483 |
- count1=(float*)Calloc(nrow,float); |
|
481 |
+ bT=(float*)R_Calloc(nrow,float); |
|
482 |
+ bL=(int*)R_Calloc(ncol,int); |
|
483 |
+ count1=(float*)R_Calloc(nrow,float); |
|
484 | 484 |
memset(count1,0,sizeof(float)*nrow); |
485 |
- total1=(int*)Calloc(nrow,int); |
|
485 |
+ total1=(int*)R_Calloc(nrow,int); |
|
486 | 486 |
memset(total1,0,sizeof(int)*nrow); |
487 |
- count2=(float*)Calloc(nrow,float); |
|
487 |
+ count2=(float*)R_Calloc(nrow,float); |
|
488 | 488 |
memset(count2,0,sizeof(float)*nrow); |
489 |
- total2=(int*)Calloc(nrow,int); |
|
489 |
+ total2=(int*)R_Calloc(nrow,int); |
|
490 | 490 |
memset(total2,0,sizeof(int)*nrow); |
491 | 491 |
|
492 |
- R=(int*)Calloc(nrow,int); |
|
492 |
+ R=(int*)R_Calloc(nrow,int); |
|
493 | 493 |
/*comuter the original t-statfirst*/ |
494 | 494 |
|
495 | 495 |
compute_test_stat(pdata,pdata->L,T,func_stat,extra); |
... | ... |
@@ -567,13 +567,13 @@ void adj_by_T(GENE_DATA* pdata,float* T,float* P,float*Adj_P, |
567 | 567 |
if(Adj_P[i]<Adj_P[i-1]) |
568 | 568 |
Adj_P[i]=Adj_P[i-1]; |
569 | 569 |
/*free the spaces*/ |
570 |
- Free(bT); |
|
571 |
- Free(count1); |
|
572 |
- Free(total1); |
|
573 |
- Free(count2); |
|
574 |
- Free(total2); |
|
575 |
- Free(bL); |
|
576 |
- Free(R); |
|
570 |
+ R_Free(bT); |
|
571 |
+ R_Free(count1); |
|
572 |
+ R_Free(total1); |
|
573 |
+ R_Free(count2); |
|
574 |
+ R_Free(total2); |
|
575 |
+ R_Free(bL); |
|
576 |
+ R_Free(R); |
|
577 | 577 |
} |
578 | 578 |
void set_seed_sampling(long int seed){ |
579 | 579 |
g_random_seed=seed; |
... | ... |
@@ -45,14 +45,14 @@ void create_sampling_pairt(int n,int*L,int B) |
45 | 45 |
} |
46 | 46 |
else{ |
47 | 47 |
int* myL; |
48 |
- myL=(int*)Calloc(n,int); |
|
48 |
+ myL=(int*)R_Calloc(n,int); |
|
49 | 49 |
l_B=B; |
50 | 50 |
l_is_random=1; |
51 | 51 |
/*fprintf(stderr,"\nWe're doing %d random permutations\n",l_B);*/ |
52 | 52 |
Rprintf("\nWe're doing %d random permutations\n",l_B); |
53 | 53 |
set_seed(g_random_seed); |
54 | 54 |
|
55 |
- l_all_samples=(unsigned int*)Calloc(l_B*l_sz,int); |
|
55 |
+ l_all_samples=(unsigned int*)R_Calloc(l_B*l_sz,int); |
|
56 | 56 |
/*setting the first sample as the original data*/ |
57 | 57 |
set_binpermu(L,0,n,l_sz,l_len,l_B,l_all_samples); |
58 | 58 |
/*the extra as a buffer*/ |
... | ... |
@@ -68,7 +68,7 @@ void create_sampling_pairt(int n,int*L,int B) |
68 | 68 |
} |
69 | 69 |
set_binpermu(myL,i,n,l_sz,l_len,l_B,l_all_samples); |
70 | 70 |
} |
71 |
- Free(myL); |
|
71 |
+ R_Free(myL); |
|
72 | 72 |
if(myDEBUG) |
73 | 73 |
{ |
74 | 74 |
fprintf(stderr,"the samples are\n"); |
... | ... |
@@ -82,7 +82,7 @@ void delete_sampling_pairt() |
82 | 82 |
{ |
83 | 83 |
if(l_is_random){ |
84 | 84 |
if(l_B!=0){ |
85 |
- Free(l_all_samples); |
|
85 |
+ R_Free(l_all_samples); |
|
86 | 86 |
l_all_samples=NULL; |
87 | 87 |
} |
88 | 88 |
} |
... | ... |
@@ -17,14 +17,14 @@ void create_sampling_pairt_fixed(int n,int*L,int B) |
17 | 17 |
fprintf(stderr,"B needs to be positive\n"); |
18 | 18 |
return;/*exit(0)*/; |
19 | 19 |
} |
20 |
- l_L=(int*)Calloc(n, int); |
|
20 |
+ l_L=(int*)R_Calloc(n, int); |
|
21 | 21 |
memcpy(l_L,L,sizeof(int)*n); |
22 | 22 |
} |
23 | 23 |
|
24 | 24 |
|
25 | 25 |
void delete_sampling_pairt_fixed() |
26 | 26 |
{ |
27 |
- Free(l_L); |
|
27 |
+ R_Free(l_L); |
|
28 | 28 |
l_L=NULL; |
29 | 29 |
} |
30 | 30 |
int first_sample_pairt_fixed(int *L) |
... | ... |
@@ -78,9 +78,9 @@ void create_sampling(int n,int*L,int B) |
78 | 78 |
/*reintiailize the permu_array*/ |
79 | 79 |
delete_permu_array(&l_pa); |
80 | 80 |
init_permu_array(&l_pa,L,n,B); |
81 |
- permun=(int*)Calloc(l_pa.n,int); |
|
82 |
- ordern=(int*)Calloc(l_pa.n,int); |
|
83 |
- myL=(int*)Calloc(l_pa.n,int); |
|
81 |
+ permun=(int*)R_Calloc(l_pa.n,int); |
|
82 |
+ ordern=(int*)R_Calloc(l_pa.n,int); |
|
83 |
+ myL=(int*)R_Calloc(l_pa.n,int); |
|
84 | 84 |
for(i=0;i<n;i++){ |
85 | 85 |
ordern[i]=i; |
86 | 86 |
} |
... | ... |
@@ -94,9 +94,9 @@ void create_sampling(int n,int*L,int B) |
94 | 94 |
sample2label(n,l_pa.k,l_pa.nk,permun,myL); |
95 | 95 |
set_permu(&l_pa,i,myL); |
96 | 96 |
} |
97 |
- Free(myL); |
|
98 |
- Free(ordern); |
|
99 |
- Free(permun); |
|
97 |
+ R_Free(myL); |
|
98 |
+ R_Free(ordern); |
|
99 |
+ R_Free(permun); |
|
100 | 100 |
} |
101 | 101 |
} |
102 | 102 |
void delete_sampling() |
... | ... |
@@ -153,7 +153,7 @@ static int init_permu_array(PERMU_ARRAY* pa, int *L,int n, int B) |
153 | 153 |
(pa->k)++; |
154 | 154 |
|
155 | 155 |
/*compue nk*/ |
156 |
- pa->nk=(int*)Calloc(pa->k,int); |
|
156 |
+ pa->nk=(int*)R_Calloc(pa->k,int); |
|
157 | 157 |
memset(pa->nk,0,sizeof(int)*pa->k); |
158 | 158 |
for(i=0;i<n;i++) |
159 | 159 |
pa->nk[L[i]]++; |
... | ... |
@@ -163,7 +163,7 @@ static int init_permu_array(PERMU_ARRAY* pa, int *L,int n, int B) |
163 | 163 |
pa->len=floor(log(imax+1.0)/log(pa->k)); |
164 | 164 |
pa->sz=ceil(n/(pa->len*1.0)); |
165 | 165 |
/*allocate the space for v*/ |
166 |
- pa->v=(unsigned int*)Calloc(B*pa->sz,int); |
|
166 |
+ pa->v=(unsigned int*)R_Calloc(B*pa->sz,int); |
|
167 | 167 |
return 1; |
168 | 168 |
} |
169 | 169 |
|
... | ... |
@@ -212,10 +212,10 @@ static int set_permu(PERMU_ARRAY* pa, int h,int *L) |
212 | 212 |
} |
213 | 213 |
static void delete_permu_array(PERMU_ARRAY* pa) |
214 | 214 |
{ |
215 |
- Free(pa->nk); |
|
215 |
+ R_Free(pa->nk); |
|
216 | 216 |
pa->nk=NULL; |
217 | 217 |
if(pa->B!=0){ |
218 |
- Free(pa->v); |
|
218 |
+ R_Free(pa->v); |
|
219 | 219 |
pa->v=NULL; |
220 | 220 |
} |
221 | 221 |
} |
... | ... |
@@ -23,7 +23,7 @@ void create_sampling_fixed(int n,int*L,int B) |
23 | 23 |
fprintf(stderr,"B needs to be positive\n"); |
24 | 24 |
return;/*exit(0)*/; |
25 | 25 |
} |
26 |
- l_L=(int*)Calloc(n,int); |
|
26 |
+ l_L=(int*)R_Calloc(n,int); |
|
27 | 27 |
memcpy(l_L,L,sizeof(int)*n); |
28 | 28 |
|
29 | 29 |
k=0; |
... | ... |
@@ -32,26 +32,26 @@ void create_sampling_fixed(int n,int*L,int B) |
32 | 32 |
k=L[i]; |
33 | 33 |
k++; |
34 | 34 |
l_k=k; |
35 |
- l_nk=(int*)Calloc(k,int); |
|
35 |
+ l_nk=(int*)R_Calloc(k,int); |
|
36 | 36 |
memset(l_nk,0,sizeof(int)*k); |
37 | 37 |
for(i=0;i<n;i++) |
38 | 38 |
l_nk[L[i]]++; |
39 | 39 |
|
40 |
- l_permun=(int*)Calloc(n,int); |
|
41 |
- l_ordern=(int*)Calloc(n,int); |
|
40 |
+ l_permun=(int*)R_Calloc(n,int); |
|
41 |
+ l_ordern=(int*)R_Calloc(n,int); |
|
42 | 42 |
for(i=0;i<n;i++){ |
43 | 43 |
l_ordern[i]=i; |
44 | 44 |
} |
45 | 45 |
} |
46 | 46 |
void delete_sampling_fixed() |
47 | 47 |
{ |
48 |
- Free(l_L); |
|
48 |
+ R_Free(l_L); |
|
49 | 49 |
l_L=NULL; |
50 |
- Free(l_nk); |
|
50 |
+ R_Free(l_nk); |
|
51 | 51 |
l_nk=NULL; |
52 |
- Free(l_permun); |
|
52 |
+ R_Free(l_permun); |
|
53 | 53 |
l_permun=NULL; |
54 |
- Free(l_ordern); |
|
54 |
+ R_Free(l_ordern); |
|
55 | 55 |
l_ordern=NULL; |
56 | 56 |
} |
57 | 57 |
|
... | ... |
@@ -255,9 +255,9 @@ float Fstat_num_denum(const float *Y, const int* L,const int n, const float na,f |
255 | 255 |
k is the number of groups, |
256 | 256 |
N is the total number of validate objects*/ |
257 | 257 |
k=*(int*)extra; |
258 |
- meani=(float *)Calloc(k,float); |
|
259 |
- ssi=(float *)Calloc(k,float); |
|
260 |
- ni=(int *)Calloc(k,int); |
|
258 |
+ meani=(float *)R_Calloc(k,float); |
|
259 |
+ ssi=(float *)R_Calloc(k,float); |
|
260 |
+ ni=(int *)R_Calloc(k,int); |
|
261 | 261 |
for(i=0;i<k;i++){ |
262 | 262 |
meani[i]=0;/*intialize to be zero*/ |
263 | 263 |
ssi[i]=0; |
... | ... |
@@ -297,9 +297,9 @@ float Fstat_num_denum(const float *Y, const int* L,const int n, const float na,f |
297 | 297 |
/*summarize the num and denum*/ |
298 | 298 |
*num=bss/(k-1.0); |
299 | 299 |
*denum=wss/(N-k-0.0); |
300 |
- Free(meani); |
|
301 |
- Free(ni); |
|
302 |
- Free(ssi); |
|
300 |
+ R_Free(meani); |
|
301 |
+ R_Free(ni); |
|
302 |
+ R_Free(ssi); |
|
303 | 303 |
return 1; |
304 | 304 |
} |
305 | 305 |
/*compute the Block F-stat for k samples, where L[i] is the labelling of object i, |
... | ... |
@@ -328,8 +328,8 @@ float Block_Fstat_num_denum(const float *Y, const int* L,const int n, const floa |
328 | 328 |
fprintf(stderr,"The design is not balanced as B(%d)xm(%d)!=n(%d)\n",B,m,n); |
329 | 329 |
return NA_FLOAT; |
330 | 330 |
} |
331 |
- meani=(float *)Calloc(B,float); |
|
332 |
- meanj=(float *)Calloc(m,float); |
|
331 |
+ meani=(float *)R_Calloc(B,float); |
|
332 |
+ meanj=(float *)R_Calloc(m,float); |
|
333 | 333 |
for(i=0;i<B;i++){ |
334 | 334 |
meani[i]=0;/*intialize to be zero*/ |
335 | 335 |
for(j=0;j<m;j++){ |
... | ... |
@@ -369,8 +369,8 @@ float Block_Fstat_num_denum(const float *Y, const int* L,const int n, const floa |
369 | 369 |
/*summarize the num and denum*/ |
370 | 370 |
*num=bss/(m-1.0); |
371 | 371 |
*denum=wss/((m-1.0)*(B-1.0)); |
372 |
- Free(meani); |
|
373 |
- Free(meanj); |
|
372 |
+ R_Free(meani); |
|
373 |
+ R_Free(meanj); |
|
374 | 374 |
return 1; |
375 | 375 |
} |
376 | 376 |
void int2bin(int r,int*V,int n) |
... | ... |
@@ -501,7 +501,7 @@ void label2sample(int n, int k, int* nk,int*L,int *permun) |
501 | 501 |
int *s;/*s is for starting*/ |
502 | 502 |
|
503 | 503 |
/*initialize the beginning*/ |
504 |
- s=(int*)Calloc(k,int); |
|
504 |
+ s=(int*)R_Calloc(k,int); |
|
505 | 505 |
s[0]=0; |
506 | 506 |
for(l=1;l<k;l++){ |
507 | 507 |
s[l]=s[l-1]+nk[l-1]; |
... | ... |
@@ -511,17 +511,17 @@ void label2sample(int n, int k, int* nk,int*L,int *permun) |
511 | 511 |
permun[s[l]]=j; |
512 | 512 |
s[l]++; |
513 | 513 |
} |
514 |
- Free(s); |
|
514 |
+ R_Free(s); |
|
515 | 515 |
} |
516 | 516 |
|
517 | 517 |
int next_label(int n, int k, int* nk, int*L) |
518 | 518 |
{ |
519 | 519 |
int *permun,ret; |
520 |
- permun=(int*)Calloc(n,int); |
|
520 |
+ permun=(int*)R_Calloc(n,int); |
|
521 | 521 |
label2sample(n,k,nk,L,permun); |
522 | 522 |
ret=next_mult_permu(permun,n,k,nk); |
523 | 523 |
sample2label(n,k,nk,permun,L); |
524 |
- Free(permun); |
|
524 |
+ R_Free(permun); |
|
525 | 525 |
return ret; |
526 | 526 |
} |
527 | 527 |
|
... | ... |
@@ -538,7 +538,7 @@ int next_two_permu(int* V, int n, int k) |
538 | 538 |
int* A=V; |
539 | 539 |
int* B=V+k; |
540 | 540 |
int* tempV,*cpyV; |
541 |
- tempV=(int*)Calloc(n,int); |
|
541 |
+ tempV=(int*)R_Calloc(n,int); |
|
542 | 542 |
|
543 | 543 |
i=k-1; |
544 | 544 |
while(i>=0&& A[i]>maxb){ |
... | ... |
@@ -554,7 +554,7 @@ int next_two_permu(int* V, int n, int k) |
554 | 554 |
/*using the tempV to swap the array A and array B*/ |
555 | 555 |
memcpy(V,tempV,sizeof(int)*n); |
556 | 556 |
/*coppying back to V*/ |
557 |
- Free(tempV); |
|
557 |
+ R_Free(tempV); |
|
558 | 558 |
return 0; |
559 | 559 |
} |
560 | 560 |
/*else to find the next permutation*/ |
... | ... |
@@ -574,7 +574,7 @@ int next_two_permu(int* V, int n, int k) |
574 | 574 |
/*copy the ((n-k)-(j+1)) elements from array |
575 | 575 |
B[j+1],...B[n-k-1],..,A[i+1],..A[k-1]*/ |
576 | 576 |
/*construct the array B[j+1],...B[n-k-1],A[i+1],..A[k-1]*/ |
577 |
- cpyV=(int*)Calloc(n,int); |
|
577 |
+ cpyV=(int*)R_Calloc(n,int); |
|
578 | 578 |
memcpy(cpyV,B+j+1,sizeof(int)*((n-k)-(j+1))); |
579 | 579 |
if(k>(i+1)) |
580 | 580 |
memcpy(cpyV+(n-k)-(j+1),A+i+1,sizeof(int)*(k-(i+1))); |
... | ... |
@@ -584,8 +584,8 @@ int next_two_permu(int* V, int n, int k) |
584 | 584 |
memcpy(tempV+k+j+2,cpyV+(k-i),sizeof(int)*((n-k)-(j+2))); |
585 | 585 |
/*copy back to V*/ |
586 | 586 |
memcpy(V,tempV,sizeof(int)*n); |
587 |
- Free(cpyV); |
|
588 |
- Free(tempV); |
|
587 |
+ R_Free(cpyV); |
|
588 |
+ R_Free(tempV); |
|
589 | 589 |
return 1; |
590 | 590 |
} |
591 | 591 |
|
... | ... |
@@ -642,14 +642,14 @@ int next_permu(int*V,int n) /* n has to be at least 2*/ |
642 | 642 |
if(V[j]>old) break; |
643 | 643 |
j--; |
644 | 644 |
} |
645 |
- cpyV=(int*)Calloc(n,int); |
|
645 |
+ cpyV=(int*)R_Calloc(n,int); |
|
646 | 646 |
memcpy(cpyV,V,sizeof(int)*n); |
647 | 647 |
V[i]=cpyV[j]; |
648 | 648 |
cpyV[j]=old; |
649 | 649 |
for(l=i+1;l<n;l++){ |
650 | 650 |
V[l]=cpyV[n+i-l]; |
651 | 651 |
} |
652 |
- Free(cpyV); |
|
652 |
+ R_Free(cpyV); |
|
653 | 653 |
return 1; |
654 | 654 |
} |
655 | 655 |
|
... | ... |
@@ -51,7 +51,7 @@ void order_mult_data(int* R,int n,int k,...) |
51 | 51 |
CMP_DATA *cmp_data; |
52 | 52 |
va_list ap; |
53 | 53 |
int i; |
54 |
- cmp_data=(CMP_DATA*)Calloc(k,CMP_DATA); |
|
54 |
+ cmp_data=(CMP_DATA*)R_Calloc(k,CMP_DATA); |
|
55 | 55 |
va_start(ap,k); |
56 | 56 |
for(i=0;i<k;i++) { |
57 | 57 |
cmp_data[i].V=va_arg(ap,float*); |
... | ... |
@@ -63,7 +63,7 @@ void order_mult_data(int* R,int n,int k,...) |
63 | 63 |
for(i=0;i<n;i++) |
64 | 64 |
R[i]=i; |
65 | 65 |
qsort(R,n,sizeof(R[0]),cmp_mult); |
66 |
- Free(cmp_data); |
|
66 |
+ R_Free(cmp_data); |
|
67 | 67 |
} |
68 | 68 |
|
69 | 69 |
void order_data(float* V,int*R,int n,FUNC_CMP func_cmp) |