3
Pascal Ballester (ESO/Garching)
4
Cristian Levin (ESO/La Silla)
8
various routines from Numerical Recipes
42
fprintf(stderr,"Numerical Recipes run-time error...\n");
46
/* functions of the OSMEMORY module of the Midas system library */
65
int nrl, int nrh, int ncl, int nch
71
int nrl, nrh, ncl, nch;
73
/* Allocates a int matrix with range [nrl..nrh][ncl..nch] */
78
/* Allocate pointers to rows */
79
m = (int **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(int *) );
82
/* Allocate rows and set pointers to them */
83
for ( i = nrl; i <= nrh; i++ ) {
84
m[i] = (int *)osmmget( (unsigned) (nch-ncl+1) * sizeof(int) );
93
int **m, int nrl, int nrh, int ncl
101
/* Frees a matrix allocated with imatrix() */
106
for ( i = nrh; i >= nrl; i-- )
107
osmmfree( (char *) (m[i] + ncl) );
109
osmmfree( (char *) (m + nrl) );
123
/* Allocates a int vector with range [nl..nh] */
127
v = (int *)osmmget( (unsigned) (nh-nl+1) * sizeof(int) );
142
/* Frees a vector allocated with ivector() */
144
osmmfree( (char *) (v + nl) );
150
int nrl, int nrh, int ncl, int nch
156
int nrl, nrh,ncl,nch;
158
/* Allocates a double matrix with range [nrl..nrh][ncl..nch] */
163
/* Allocate pointers to rows */
164
m = (double **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(double *) );
167
/* Allocate rows and set pointers to them */
168
for ( i = nrl; i <= nrh; i++ ) {
169
m[i] = (double *)osmmget( (unsigned) (nch-ncl+1) * sizeof(double) );
178
double **m, int nrl, int nrh, int ncl, int nch
182
m, nrl, nrh, ncl, nch
187
/* Frees a matrix allocated with dmatrix() */
191
for ( i = nrh; i >= nrl; i-- )
192
osmmfree( (char *) (m[i] + ncl) );
194
osmmfree( (char *) (m + nrl) );
208
/* Allocates a double vector with range [nl..nh] */
212
v = (double *)osmmget( (unsigned) (nh-nl+1) * sizeof(double) );
219
double *v, int nl, int nh
228
/* Frees a vector allocated with dvector() */
230
osmmfree( (char *) (v + nl) );
236
int nrl, int nrh, int ncl, int nch
244
/* Allocates a float matrix with range [nrl..nrh][ncl..nch] */
249
/* Allocate pointers to rows */
250
m = (float **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(float *) );
253
/* Allocate rows and set pointers to them */
254
for ( i = nrl; i <= nrh; i++ ) {
255
m[i] = (float *)osmmget( (unsigned) (nch-ncl+1) * sizeof(float) );
264
float **m, int nrl, int nrh, int ncl, int nch
268
m, nrl, nrh, ncl, nch
273
/* Frees a matrix allocated with fmatrix() */
277
for ( i = nrh; i >= nrl; i-- )
278
osmmfree( (char *) (m[i] + ncl) );
280
osmmfree( (char *) (m + nrl) );
294
/* Allocates a float vector with range [nl..nh] */
298
v = (float *)osmmget( (unsigned) (nh-nl+1) * sizeof(float) );
306
float *v, int nl, int nh
315
/* Frees a vector allocated with fvector() */
317
osmmfree( (char *) (v + nl) );
323
int nrl, int nrh, int ncl, int nch
331
/* Allocates a char matrix with range [nrl..nrh][ncl..nch] */
336
/* Allocate pointers to rows */
337
m = (char **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(char *) );
340
/* Allocate rows and set pointers to them */
341
for ( i = nrl; i <= nrh; i++ ) {
342
m[i] = (char *)osmmget( (unsigned) (nch-ncl+1) * sizeof(char) );
351
char **m, int nrl, int nrh, int ncl, int nch
355
m, nrl, nrh, ncl, nch
360
/* Frees a matrix allocated with cmatrix() */
364
for ( i = nrh; i >= nrl; i-- )
365
osmmfree( (char *) (m[i] + ncl) );
367
osmmfree( (char *) (m + nrl) );
381
/* Allocates a char vector with range [nl..nh] */
385
v = (char *)osmmget( (unsigned) (nh-nl+1) * sizeof(char) );
392
char *v, int nl, int nh
401
/* Frees a vector allocated with cvector() */
403
osmmfree( (char *) (v + nl) );
422
v=(float *)malloc((size_t) (nh-nl+1)*sizeof(float));
423
if (!v) nrerror("allocation failure in vector()");
430
float *v, int nl, int nh
440
osmmfree((char*) (v+nl));
446
int nrl, int nrh, int ncl, int nch
452
int nrl, nrh, ncl, nch;
459
m=(float **) malloc((size_t) (nrh-nrl+1)*sizeof(float*));
460
if (!m) nrerror("allocation failure 1 in matrix()");
463
for(i=nrl;i<=nrh;i++) {
464
m[i]=(float *) malloc((size_t) (nch-ncl+1)*sizeof(float));
465
if (!m[i]) nrerror("allocation failure 2 in matrix()");
474
float **m, int nrl, int nrh, int ncl, int nch
487
for(i=nrh;i>=nrl;i--) free((char*) (m[i]+ncl));
488
free((char*) (m+nrl));
494
float **a, int oldrl, int oldrh, int oldcl,
495
int oldch, int newrl, int newcl
499
a,oldrl,oldrh,oldcl,oldch,newrl,newcl
502
int oldrl,oldrh,oldcl,oldch,newrl,newcl;
509
m=(float **) malloc((size_t) (oldrh-oldrl+1)*sizeof(float*));
510
if (!m) nrerror("allocation failure in submatrix()");
513
for(i=oldrl,j=newrl;i<=oldrh;i++,j++) m[j]=a[i]+oldcl-newcl;
521
float **b, int nrl, int nrh, int ncl, int nch
532
osmmfree((char*) (b+nrl));
535
float **convert_matrix
538
float *a, int nrl, int nrh, int ncl, int nch
554
m = (float **) malloc((size_t) (nrow)*sizeof(float*));
555
if (!m) nrerror("allocation failure in convert_matrix()");
557
for(i=0,j=nrl;i<=nrow-1;i++,j++) m[j]=a+ncol*i-ncl;
561
void free_convert_matrix
564
float **b, int nrl, int nrh, int ncl, int nch
575
osmmfree((char*) (b+nrl));