| 1 |
/*=========================================================================== |
| 2 |
Copyright (C) 1993-2009 European Southern Observatory (ESO) |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License as |
| 6 |
published by the Free Software Foundation; either version 2 of |
| 7 |
the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public |
| 15 |
License along with this program; if not, write to the Free |
| 16 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 17 |
MA 02139, USA. |
| 18 |
|
| 19 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 20 |
Internet e-mail: [email protected] |
| 21 |
Postal address: European Southern Observatory |
| 22 |
Data Management Division |
| 23 |
Karl-Schwarzschild-Strasse 2 |
| 24 |
D 85748 Garching bei Muenchen |
| 25 |
GERMANY |
| 26 |
===========================================================================*/ |
| 27 |
|
| 28 |
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ |
| 29 |
/* .IDENT lnplot.c */ |
| 30 |
/* .AUTHORS Pascal Ballester (ESO/Garching) */ |
| 31 |
/* Cristian Levin (ESO/La Silla) */ |
| 32 |
/* .KEYWORDS Memory management, Spectroscopy, Long-Slit */ |
| 33 |
/* .PURPOSE */ |
| 34 |
/* .VERSION 1.0 Package Creation 17-MAR-1993 |
| 35 |
|
| 36 |
090825 last modif */ |
| 37 |
/* ------------------------------------------------------- */ |
| 38 |
|
| 39 |
|
| 40 |
#include <stdio.h> |
| 41 |
|
| 42 |
#include <midas_def.h> |
| 43 |
|
| 44 |
|
| 45 |
int *ivector( nl, nh ) |
| 46 |
int nl, nh; |
| 47 |
/* Allocates a int vector with range [nl..nh] */ |
| 48 |
{ |
| 49 |
int *v; |
| 50 |
|
| 51 |
v = (int *)osmmget( (unsigned) (nh-nl+1) * sizeof(int) ); |
| 52 |
return( v - nl ); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
void free_ivector( v, nl, nh ) |
| 57 |
int *v; |
| 58 |
int nl, nh; |
| 59 |
/* Frees a vector allocated with ivector() */ |
| 60 |
{ |
| 61 |
osmmfree( (char *) (v + nl) ); |
| 62 |
} |
| 63 |
|
| 64 |
double **dmatrix( nrl, nrh, ncl, nch ) |
| 65 |
int nrl, nrh, ncl, nch; |
| 66 |
/* Allocates a double matrix with range [nrl..nrh][ncl..nch] */ |
| 67 |
{ |
| 68 |
int i; |
| 69 |
double **m; |
| 70 |
|
| 71 |
/* Allocate pointers to rows */ |
| 72 |
m = (double **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(double *) ); |
| 73 |
m -= nrl; |
| 74 |
|
| 75 |
/* Allocate rows and set pointers to them */ |
| 76 |
for ( i = nrl; i <= nrh; i++ ) { |
| 77 |
m[i] = (double *)osmmget( (unsigned) (nch-ncl+1) * sizeof(double) ); |
| 78 |
m[i] -= ncl; |
| 79 |
} |
| 80 |
return( m ); |
| 81 |
} |
| 82 |
|
| 83 |
double *dvector( nl, nh ) |
| 84 |
int nl, nh; |
| 85 |
/* Allocates a double vector with range [nl..nh] */ |
| 86 |
{ |
| 87 |
double *v; |
| 88 |
|
| 89 |
v = (double *)osmmget( (unsigned) (nh-nl+1) * sizeof(double) ); |
| 90 |
return( v - nl ); |
| 91 |
} |
| 92 |
|
| 93 |
void free_dmatrix( m, nrl, nrh, ncl, nch ) |
| 94 |
double **m; |
| 95 |
int nrl, nrh, ncl, nch; |
| 96 |
/* Frees a matrix allocated with dmatrix() */ |
| 97 |
{ |
| 98 |
int i; |
| 99 |
|
| 100 |
for ( i = nrh; i >= nrl; i-- ) |
| 101 |
osmmfree( (char *) (m[i] + ncl) ); |
| 102 |
|
| 103 |
osmmfree( (char *) (m + nrl) ); |
| 104 |
} |
| 105 |
|
| 106 |
void free_dvector( v, nl, nh ) |
| 107 |
double *v; |
| 108 |
int nl, nh; |
| 109 |
/* Frees a vector allocated with dvector() */ |
| 110 |
{ |
| 111 |
osmmfree( (char *) (v + nl) ); |
| 112 |
} |
| 113 |
|
| 114 |
float **fmatrix( nrl, nrh, ncl, nch ) |
| 115 |
int nrl, nrh, ncl, nch; |
| 116 |
/* Allocates a float matrix with range [nrl..nrh][ncl..nch] */ |
| 117 |
{ |
| 118 |
int i; |
| 119 |
float **m; |
| 120 |
|
| 121 |
/* Allocate pointers to rows */ |
| 122 |
m = (float **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(float *) ); |
| 123 |
m -= nrl; |
| 124 |
|
| 125 |
/* Allocate rows and set pointers to them */ |
| 126 |
for ( i = nrl; i <= nrh; i++ ) { |
| 127 |
m[i] = (float *)osmmget( (unsigned) (nch-ncl+1) * sizeof(float) ); |
| 128 |
m[i] -= ncl; |
| 129 |
} |
| 130 |
return( m ); |
| 131 |
} |
| 132 |
|
| 133 |
float *fvector( nl, nh ) |
| 134 |
int nl, nh; |
| 135 |
/* Allocates a float vector with range [nl..nh] */ |
| 136 |
{ |
| 137 |
float *v; |
| 138 |
|
| 139 |
v = (float *)osmmget( (unsigned) (nh-nl+1) * sizeof(float) ); |
| 140 |
return( v - nl ); |
| 141 |
} |
| 142 |
|
| 143 |
void free_fmatrix( m, nrl, nrh, ncl, nch ) |
| 144 |
float **m; |
| 145 |
int nrl, nrh, ncl, nch; |
| 146 |
/* Frees a matrix allocated with fmatrix() */ |
| 147 |
{ |
| 148 |
int i; |
| 149 |
|
| 150 |
for ( i = nrh; i >= nrl; i-- ) |
| 151 |
osmmfree( (char *) (m[i] + ncl) ); |
| 152 |
|
| 153 |
osmmfree( (char *) (m + nrl) ); |
| 154 |
} |
| 155 |
|
| 156 |
void free_fvector( v, nl, nh ) |
| 157 |
float *v; |
| 158 |
int nl, nh; |
| 159 |
/* Frees a vector allocated with fvector() */ |
| 160 |
{ |
| 161 |
osmmfree( (char *) (v + nl) ); |
| 162 |
} |
| 163 |
|
| 164 |
char **cmatrix( nrl, nrh, ncl, nch ) |
| 165 |
int nrl, nrh, ncl, nch; |
| 166 |
/* Allocates a char matrix with range [nrl..nrh][ncl..nch] */ |
| 167 |
{ |
| 168 |
int i; |
| 169 |
char **m; |
| 170 |
|
| 171 |
/* Allocate pointers to rows */ |
| 172 |
m = (char **)osmmget( (unsigned) (nrh-nrl+1) * sizeof(char *) ); |
| 173 |
m -= nrl; |
| 174 |
|
| 175 |
/* Allocate rows and set pointers to them */ |
| 176 |
for ( i = nrl; i <= nrh; i++ ) { |
| 177 |
m[i] = (char *)osmmget( (unsigned) (nch-ncl+1) * sizeof(char) ); |
| 178 |
m[i] -= ncl; |
| 179 |
} |
| 180 |
return( m ); |
| 181 |
} |
| 182 |
|
| 183 |
char *cvector( nl, nh ) |
| 184 |
int nl, nh; |
| 185 |
/* Allocates a char vector with range [nl..nh] */ |
| 186 |
{ |
| 187 |
char *v; |
| 188 |
|
| 189 |
v = (char *)osmmget( (unsigned) (nh-nl+1) * sizeof(char) ); |
| 190 |
return( v - nl ); |
| 191 |
} |
| 192 |
|
| 193 |
void free_cmatrix( m, nrl, nrh, ncl, nch ) |
| 194 |
char **m; |
| 195 |
int nrl, nrh, ncl, nch; |
| 196 |
/* Frees a matrix allocated with cmatrix() */ |
| 197 |
{ |
| 198 |
int i; |
| 199 |
|
| 200 |
for ( i = nrh; i >= nrl; i-- ) |
| 201 |
osmmfree( (char *) (m[i] + ncl) ); |
| 202 |
|
| 203 |
osmmfree( (char *) (m + nrl) ); |
| 204 |
} |
| 205 |
|
| 206 |
void free_cvector( v, nl, nh ) |
| 207 |
char *v; |
| 208 |
int nl, nh; |
| 209 |
/* Frees a vector allocated with cvector() */ |
| 210 |
{ |
| 211 |
osmmfree( (char *) (v + nl) ); |
| 212 |
} |