1 #ifdef HAVE_STDLIB_H
2 #include <stdlib.h>
3 #endif
4 #if defined(__STDC__) || defined(ANSI) || defined(NRANSI) /* ANSI */
5
6 #include <stdio.h>
7 #include <stddef.h>
8 #ifndef GCC
9
10 #endif
11 #define NR_END 1
12 #define FREE_ARG char*
13
nrerror(char error_text[])14 void nrerror(char error_text[])
15 /* Numerical Recipes standard error handler */
16 {
17 fprintf(stderr,"Numerical Recipes run-time error...\n");
18 fprintf(stderr,"%s\n",error_text);
19 fprintf(stderr,"...now exiting to system...\n");
20 exit(1);
21 }
22
vector(long nl,long nh)23 float *vector(long nl, long nh)
24 /* allocate a float vector with subscript range v[nl..nh] */
25 {
26 float *v;
27
28 v=(float *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(float)));
29 if (!v) nrerror("allocation failure in vector()");
30 return v-nl+NR_END;
31 }
32
ivector(long nl,long nh)33 int *ivector(long nl, long nh)
34 /* allocate an int vector with subscript range v[nl..nh] */
35 {
36 int *v;
37
38 v=(int *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(int)));
39 if (!v) nrerror("allocation failure in ivector()");
40 return v-nl+NR_END;
41 }
42
cvector(long nl,long nh)43 unsigned char *cvector(long nl, long nh)
44 /* allocate an unsigned char vector with subscript range v[nl..nh] */
45 {
46 unsigned char *v;
47
48 v=(unsigned char *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
49 if (!v) nrerror("allocation failure in cvector()");
50 return v-nl+NR_END;
51 }
52
lvector(long nl,long nh)53 unsigned long *lvector(long nl, long nh)
54 /* allocate an unsigned long vector with subscript range v[nl..nh] */
55 {
56 unsigned long *v;
57
58 v=(unsigned long *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(long)));
59 if (!v) nrerror("allocation failure in lvector()");
60 return v-nl+NR_END;
61 }
62
dvector(long nl,long nh)63 double *dvector(long nl, long nh)
64 /* allocate a double vector with subscript range v[nl..nh] */
65 {
66 double *v;
67 v=(double *)malloc((size_t) ((nh-nl+1+NR_END)*sizeof(double)));
68 if (!v) nrerror("allocation failure in dvector()");
69 return v-nl+NR_END;
70 }
71
matrix(long nrl,long nrh,long ncl,long nch)72 float **matrix(long nrl, long nrh, long ncl, long nch)
73 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
74 {
75 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
76 float **m;
77
78 /* allocate pointers to rows */
79 m=(float **) malloc((size_t)((nrow+NR_END)*sizeof(float*)));
80 if (!m) nrerror("allocation failure 1 in matrix()");
81 m += NR_END;
82 m -= nrl;
83
84 /* allocate rows and set pointers to them */
85 m[nrl]=(float *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float)));
86 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
87 m[nrl] += NR_END;
88 m[nrl] -= ncl;
89
90 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
91
92 /* return pointer to array of pointers to rows */
93 return m;
94 }
95
dmatrix(long nrl,long nrh,long ncl,long nch)96 double **dmatrix(long nrl, long nrh, long ncl, long nch)
97 /* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
98 {
99 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
100 double **m;
101
102 /* allocate pointers to rows */
103 m=(double **) malloc((size_t)((nrow+NR_END)*sizeof(double*)));
104 if (!m) nrerror("allocation failure 1 in matrix()");
105 m += NR_END;
106 m -= nrl;
107
108 /* allocate rows and set pointers to them */
109 m[nrl]=(double *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(double)));
110 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
111 m[nrl] += NR_END;
112 m[nrl] -= ncl;
113
114 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
115
116 /* return pointer to array of pointers to rows */
117 return m;
118 }
119
imatrix(long nrl,long nrh,long ncl,long nch)120 int **imatrix(long nrl, long nrh, long ncl, long nch)
121 /* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
122 {
123 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
124 int **m;
125
126 /* allocate pointers to rows */
127 m=(int **) malloc((size_t)((nrow+NR_END)*sizeof(int*)));
128 if (!m) nrerror("allocation failure 1 in matrix()");
129 m += NR_END;
130 m -= nrl;
131
132
133 /* allocate rows and set pointers to them */
134 m[nrl]=(int *) malloc((size_t)((nrow*ncol+NR_END)*sizeof(int)));
135 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
136 m[nrl] += NR_END;
137 m[nrl] -= ncl;
138
139 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
140
141 /* return pointer to array of pointers to rows */
142 return m;
143 }
144
submatrix(float ** a,long oldrl,long oldrh,long oldcl,long oldch,long newrl,long newcl)145 float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
146 long newrl, long newcl)
147 /* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
148 {
149 long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
150 float **m;
151
152 /* allocate array of pointers to rows */
153 m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
154 if (!m) nrerror("allocation failure in submatrix()");
155 m += NR_END;
156 m -= newrl;
157
158 /* set pointers to rows */
159 for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
160
161 /* return pointer to array of pointers to rows */
162 return m;
163 }
164
convert_matrix(float * a,long nrl,long nrh,long ncl,long nch)165 float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch)
166 /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
167 declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
168 and ncol=nch-ncl+1. The routine should be called with the address
169 &a[0][0] as the first argument. */
170 {
171 long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
172 float **m;
173
174 /* allocate pointers to rows */
175 m=(float **) malloc((size_t) ((nrow+NR_END)*sizeof(float*)));
176 if (!m) nrerror("allocation failure in convert_matrix()");
177 m += NR_END;
178 m -= nrl;
179
180 /* set pointers to rows */
181 m[nrl]=a-ncl;
182 for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
183 /* return pointer to array of pointers to rows */
184 return m;
185 }
186
f3tensor(long nrl,long nrh,long ncl,long nch,long ndl,long ndh)187 float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh)
188 /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
189 {
190 long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
191 float ***t;
192
193 /* allocate pointers to pointers to rows */
194 t=(float ***) malloc((size_t)((nrow+NR_END)*sizeof(float**)));
195 if (!t) nrerror("allocation failure 1 in f3tensor()");
196 t += NR_END;
197 t -= nrl;
198
199 /* allocate pointers to rows and set pointers to them */
200 t[nrl]=(float **) malloc((size_t)((nrow*ncol+NR_END)*sizeof(float*)));
201 if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
202 t[nrl] += NR_END;
203 t[nrl] -= ncl;
204
205 /* allocate rows and set pointers to them */
206 t[nrl][ncl]=(float *) malloc((size_t)((nrow*ncol*ndep+NR_END)*sizeof(float)));
207 if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
208 t[nrl][ncl] += NR_END;
209 t[nrl][ncl] -= ndl;
210
211 for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
212 for(i=nrl+1;i<=nrh;i++) {
213 t[i]=t[i-1]+ncol;
214 t[i][ncl]=t[i-1][ncl]+ncol*ndep;
215 for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
216 }
217
218 /* return pointer to array of pointers to rows */
219 return t;
220 }
221
free_vector(float * v,long nl,long nh)222 void free_vector(float *v, long nl, long nh)
223 /* free a float vector allocated with vector() */
224 {
225 free((FREE_ARG) (v+nl-NR_END));
226 }
227
free_ivector(int * v,long nl,long nh)228 void free_ivector(int *v, long nl, long nh)
229 /* free an int vector allocated with ivector() */
230 {
231 free((FREE_ARG) (v+nl-NR_END));
232 }
233
free_cvector(unsigned char * v,long nl,long nh)234 void free_cvector(unsigned char *v, long nl, long nh)
235 /* free an unsigned char vector allocated with cvector() */
236 {
237 free((FREE_ARG) (v+nl-NR_END));
238 }
239
free_lvector(unsigned long * v,long nl,long nh)240 void free_lvector(unsigned long *v, long nl, long nh)
241 /* free an unsigned long vector allocated with lvector() */
242 {
243 free((FREE_ARG) (v+nl-NR_END));
244 }
245
free_dvector(double * v,long nl,long nh)246 void free_dvector(double *v, long nl, long nh)
247 /* free a double vector allocated with dvector() */
248 {
249 free((FREE_ARG) (v+nl-NR_END));
250 }
251
free_matrix(float ** m,long nrl,long nrh,long ncl,long nch)252 void free_matrix(float **m, long nrl, long nrh, long ncl, long nch)
253 /* free a float matrix allocated by matrix() */
254 {
255 free((FREE_ARG) (m[nrl]+ncl-NR_END));
256 free((FREE_ARG) (m+nrl-NR_END));
257 }
258
free_dmatrix(double ** m,long nrl,long nrh,long ncl,long nch)259 void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch)
260 /* free a double matrix allocated by dmatrix() */
261 {
262 free((FREE_ARG) (m[nrl]+ncl-NR_END));
263 free((FREE_ARG) (m+nrl-NR_END));
264 }
265
free_imatrix(int ** m,long nrl,long nrh,long ncl,long nch)266 void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch)
267 /* free an int matrix allocated by imatrix() */
268 {
269 free((FREE_ARG) (m[nrl]+ncl-NR_END));
270 free((FREE_ARG) (m+nrl-NR_END));
271 }
272
free_submatrix(float ** b,long nrl,long nrh,long ncl,long nch)273 void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch)
274 /* free a submatrix allocated by submatrix() */
275 {
276 free((FREE_ARG) (b+nrl-NR_END));
277 }
278
free_convert_matrix(float ** b,long nrl,long nrh,long ncl,long nch)279 void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch)
280 /* free a matrix allocated by convert_matrix() */
281 {
282 free((FREE_ARG) (b+nrl-NR_END));
283 }
284
free_f3tensor(float *** t,long nrl,long nrh,long ncl,long nch,long ndl,long ndh)285 void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
286 long ndl, long ndh)
287 /* free a float f3tensor allocated by f3tensor() */
288 {
289 free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
290 free((FREE_ARG) (t[nrl]+ncl-NR_END));
291 free((FREE_ARG) (t+nrl-NR_END));
292 }
293
294 #else /* ANSI */
295 /* traditional - K&R */
296
297 #include <stdio.h>
298 #define NR_END 1
299 #define FREE_ARG char*
300
nrerror(error_text)301 void nrerror(error_text)
302 char error_text[];
303 /* Numerical Recipes standard error handler */
304 {
305 void exit();
306
307 fprintf(stderr,"Numerical Recipes run-time error...\n");
308 fprintf(stderr,"%s\n",error_text);
309 fprintf(stderr,"...now exiting to system...\n");
310 exit(1);
311 }
312
vector(nl,nh)313 float *vector(nl,nh)
314 long nh,nl;
315 /* allocate a float vector with subscript range v[nl..nh] */
316 {
317 float *v;
318
319 v=(float *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(float)));
320 if (!v) nrerror("allocation failure in vector()");
321 return v-nl+NR_END;
322 }
323
ivector(nl,nh)324 int *ivector(nl,nh)
325 long nh,nl;
326 /* allocate an int vector with subscript range v[nl..nh] */
327 {
328 int *v;
329
330 v=(int *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(int)));
331 if (!v) nrerror("allocation failure in ivector()");
332 return v-nl+NR_END;
333 }
334
cvector(nl,nh)335 unsigned char *cvector(nl,nh)
336 long nh,nl;
337 /* allocate an unsigned char vector with subscript range v[nl..nh] */
338 {
339 unsigned char *v;
340
341 v=(unsigned char *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(unsigned char)));
342 if (!v) nrerror("allocation failure in cvector()");
343 return v-nl+NR_END;
344 }
345
lvector(nl,nh)346 unsigned long *lvector(nl,nh)
347 long nh,nl;
348 /* allocate an unsigned long vector with subscript range v[nl..nh] */
349 {
350 unsigned long *v;
351
352 v=(unsigned long *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(long)));
353 if (!v) nrerror("allocation failure in lvector()");
354 return v-nl+NR_END;
355 }
356
dvector(nl,nh)357 double *dvector(nl,nh)
358 long nh,nl;
359 /* allocate a double vector with subscript range v[nl..nh] */
360 {
361 double *v;
362
363 v=(double *)malloc((unsigned int) ((nh-nl+1+NR_END)*sizeof(double)));
364 if (!v) nrerror("allocation failure in dvector()");
365 return v-nl+NR_END;
366 }
367
matrix(nrl,nrh,ncl,nch)368 float **matrix(nrl,nrh,ncl,nch)
369 long nch,ncl,nrh,nrl;
370 /* allocate a float matrix with subscript range m[nrl..nrh][ncl..nch] */
371 {
372 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
373 float **m;
374
375 /* allocate pointers to rows */
376 m=(float **) malloc((unsigned int)((nrow+NR_END)*sizeof(float*)));
377 if (!m) nrerror("allocation failure 1 in matrix()");
378 m += NR_END;
379 m -= nrl;
380
381 /* allocate rows and set pointers to them */
382 m[nrl]=(float *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float)));
383 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
384 m[nrl] += NR_END;
385 m[nrl] -= ncl;
386
387 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
388
389 /* return pointer to array of pointers to rows */
390 return m;
391 }
392
dmatrix(nrl,nrh,ncl,nch)393 double **dmatrix(nrl,nrh,ncl,nch)
394 long nch,ncl,nrh,nrl;
395 /* allocate a double matrix with subscript range m[nrl..nrh][ncl..nch] */
396 {
397 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
398 double **m;
399
400 /* allocate pointers to rows */
401 m=(double **) malloc((unsigned int)((nrow+NR_END)*sizeof(double*)));
402 if (!m) nrerror("allocation failure 1 in matrix()");
403 m += NR_END;
404 m -= nrl;
405
406 /* allocate rows and set pointers to them */
407 m[nrl]=(double *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(double)));
408 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
409 m[nrl] += NR_END;
410 m[nrl] -= ncl;
411
412 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
413
414 /* return pointer to array of pointers to rows */
415 return m;
416 }
417
imatrix(nrl,nrh,ncl,nch)418 int **imatrix(nrl,nrh,ncl,nch)
419 long nch,ncl,nrh,nrl;
420 /* allocate a int matrix with subscript range m[nrl..nrh][ncl..nch] */
421 {
422 long i, nrow=nrh-nrl+1,ncol=nch-ncl+1;
423 int **m;
424
425 /* allocate pointers to rows */
426 m=(int **) malloc((unsigned int)((nrow+NR_END)*sizeof(int*)));
427 if (!m) nrerror("allocation failure 1 in matrix()");
428 m += NR_END;
429 m -= nrl;
430
431
432 /* allocate rows and set pointers to them */
433 m[nrl]=(int *) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(int)));
434 if (!m[nrl]) nrerror("allocation failure 2 in matrix()");
435 m[nrl] += NR_END;
436 m[nrl] -= ncl;
437
438 for(i=nrl+1;i<=nrh;i++) m[i]=m[i-1]+ncol;
439
440 /* return pointer to array of pointers to rows */
441 return m;
442 }
443
submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)444 float **submatrix(a,oldrl,oldrh,oldcl,oldch,newrl,newcl)
445 float **a;
446 long newcl,newrl,oldch,oldcl,oldrh,oldrl;
447 /* point a submatrix [newrl..][newcl..] to a[oldrl..oldrh][oldcl..oldch] */
448 {
449 long i,j,nrow=oldrh-oldrl+1,ncol=oldcl-newcl;
450 float **m;
451
452 /* allocate array of pointers to rows */
453 m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
454 if (!m) nrerror("allocation failure in submatrix()");
455 m += NR_END;
456 m -= newrl;
457
458 /* set pointers to rows */
459 for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+ncol;
460
461 /* return pointer to array of pointers to rows */
462 return m;
463 }
464
convert_matrix(a,nrl,nrh,ncl,nch)465 float **convert_matrix(a,nrl,nrh,ncl,nch)
466 float *a;
467 long nch,ncl,nrh,nrl;
468 /* allocate a float matrix m[nrl..nrh][ncl..nch] that points to the matrix
469 declared in the standard C manner as a[nrow][ncol], where nrow=nrh-nrl+1
470 and ncol=nch-ncl+1. The routine should be called with the address
471 &a[0][0] as the first argument. */
472 {
473 long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1;
474 float **m;
475
476 /* allocate pointers to rows */
477 m=(float **) malloc((unsigned int) ((nrow+NR_END)*sizeof(float*)));
478 if (!m) nrerror("allocation failure in convert_matrix()");
479 m += NR_END;
480 m -= nrl;
481
482 /* set pointers to rows */
483 m[nrl]=a-ncl;
484 for(i=1,j=nrl+1;i<nrow;i++,j++) m[j]=m[j-1]+ncol;
485 /* return pointer to array of pointers to rows */
486 return m;
487 }
488
f3tensor(nrl,nrh,ncl,nch,ndl,ndh)489 float ***f3tensor(nrl,nrh,ncl,nch,ndl,ndh)
490 long nch,ncl,ndh,ndl,nrh,nrl;
491 /* allocate a float 3tensor with range t[nrl..nrh][ncl..nch][ndl..ndh] */
492 {
493 long i,j,nrow=nrh-nrl+1,ncol=nch-ncl+1,ndep=ndh-ndl+1;
494 float ***t;
495
496 /* allocate pointers to pointers to rows */
497 t=(float ***) malloc((unsigned int)((nrow+NR_END)*sizeof(float**)));
498 if (!t) nrerror("allocation failure 1 in f3tensor()");
499 t += NR_END;
500 t -= nrl;
501
502 /* allocate pointers to rows and set pointers to them */
503 t[nrl]=(float **) malloc((unsigned int)((nrow*ncol+NR_END)*sizeof(float*)));
504 if (!t[nrl]) nrerror("allocation failure 2 in f3tensor()");
505 t[nrl] += NR_END;
506 t[nrl] -= ncl;
507
508 /* allocate rows and set pointers to them */
509 t[nrl][ncl]=(float *) malloc((unsigned int)((nrow*ncol*ndep+NR_END)*sizeof(float)));
510 if (!t[nrl][ncl]) nrerror("allocation failure 3 in f3tensor()");
511 t[nrl][ncl] += NR_END;
512 t[nrl][ncl] -= ndl;
513
514 for(j=ncl+1;j<=nch;j++) t[nrl][j]=t[nrl][j-1]+ndep;
515 for(i=nrl+1;i<=nrh;i++) {
516 t[i]=t[i-1]+ncol;
517 t[i][ncl]=t[i-1][ncl]+ncol*ndep;
518 for(j=ncl+1;j<=nch;j++) t[i][j]=t[i][j-1]+ndep;
519 }
520
521 /* return pointer to array of pointers to rows */
522 return t;
523 }
524
free_vector(v,nl,nh)525 void free_vector(v,nl,nh)
526 float *v;
527 long nh,nl;
528 /* free a float vector allocated with vector() */
529 {
530 free((FREE_ARG) (v+nl-NR_END));
531 }
532
free_ivector(v,nl,nh)533 void free_ivector(v,nl,nh)
534 int *v;
535 long nh,nl;
536 /* free an int vector allocated with ivector() */
537 {
538 free((FREE_ARG) (v+nl-NR_END));
539 }
540
free_cvector(v,nl,nh)541 void free_cvector(v,nl,nh)
542 long nh,nl;
543 unsigned char *v;
544 /* free an unsigned char vector allocated with cvector() */
545 {
546 free((FREE_ARG) (v+nl-NR_END));
547 }
548
free_lvector(v,nl,nh)549 void free_lvector(v,nl,nh)
550 long nh,nl;
551 unsigned long *v;
552 /* free an unsigned long vector allocated with lvector() */
553 {
554 free((FREE_ARG) (v+nl-NR_END));
555 }
556
free_dvector(v,nl,nh)557 void free_dvector(v,nl,nh)
558 double *v;
559 long nh,nl;
560 /* free a double vector allocated with dvector() */
561 {
562 free((FREE_ARG) (v+nl-NR_END));
563 }
564
free_matrix(m,nrl,nrh,ncl,nch)565 void free_matrix(m,nrl,nrh,ncl,nch)
566 float **m;
567 long nch,ncl,nrh,nrl;
568 /* free a float matrix allocated by matrix() */
569 {
570 free((FREE_ARG) (m[nrl]+ncl-NR_END));
571 free((FREE_ARG) (m+nrl-NR_END));
572 }
573
free_dmatrix(m,nrl,nrh,ncl,nch)574 void free_dmatrix(m,nrl,nrh,ncl,nch)
575 double **m;
576 long nch,ncl,nrh,nrl;
577 /* free a double matrix allocated by dmatrix() */
578 {
579 free((FREE_ARG) (m[nrl]+ncl-NR_END));
580 free((FREE_ARG) (m+nrl-NR_END));
581 }
582
free_imatrix(m,nrl,nrh,ncl,nch)583 void free_imatrix(m,nrl,nrh,ncl,nch)
584 int **m;
585 long nch,ncl,nrh,nrl;
586 /* free an int matrix allocated by imatrix() */
587 {
588 free((FREE_ARG) (m[nrl]+ncl-NR_END));
589 free((FREE_ARG) (m+nrl-NR_END));
590 }
591
free_submatrix(b,nrl,nrh,ncl,nch)592 void free_submatrix(b,nrl,nrh,ncl,nch)
593 float **b;
594 long nch,ncl,nrh,nrl;
595 /* free a submatrix allocated by submatrix() */
596 {
597 free((FREE_ARG) (b+nrl-NR_END));
598 }
599
free_convert_matrix(b,nrl,nrh,ncl,nch)600 void free_convert_matrix(b,nrl,nrh,ncl,nch)
601 float **b;
602 long nch,ncl,nrh,nrl;
603 /* free a matrix allocated by convert_matrix() */
604 {
605 free((FREE_ARG) (b+nrl-NR_END));
606 }
607
free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)608 void free_f3tensor(t,nrl,nrh,ncl,nch,ndl,ndh)
609 float ***t;
610 long nch,ncl,ndh,ndl,nrh,nrl;
611 /* free a float f3tensor allocated by f3tensor() */
612 {
613 free((FREE_ARG) (t[nrl][ncl]+ndl-NR_END));
614 free((FREE_ARG) (t[nrl]+ncl-NR_END));
615 free((FREE_ARG) (t+nrl-NR_END));
616 }
617
618 #endif /* ANSI */
619