00001 #ifndef _NR_UTILS_H_
00002 #define _NR_UTILS_H_
00003
00004 #ifdef __GNUC__
00005 #define UNUSED __attribute__((unused))
00006 #else
00007 #define UNUSED
00008 #endif
00009
00010 static float sqrarg UNUSED;
00011 #define SQR(a) ((sqrarg=(a)) == 0.0 ? 0.0 : sqrarg*sqrarg)
00012
00013 static double dsqrarg UNUSED;
00014 #define DSQR(a) ((dsqrarg=(a)) == 0.0 ? 0.0 : dsqrarg*dsqrarg)
00015
00016 static double dmaxarg1 UNUSED,dmaxarg2 UNUSED;
00017 #define DMAX(a,b) (dmaxarg1=(a),dmaxarg2=(b),(dmaxarg1) > (dmaxarg2) ?\
00018 (dmaxarg1) : (dmaxarg2))
00019
00020 static double dminarg1 UNUSED,dminarg2 UNUSED;
00021 #define DMIN(a,b) (dminarg1=(a),dminarg2=(b),(dminarg1) < (dminarg2) ?\
00022 (dminarg1) : (dminarg2))
00023
00024 static float maxarg1 UNUSED,maxarg2 UNUSED;
00025 #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\
00026 (maxarg1) : (maxarg2))
00027
00028 static float minarg1 UNUSED,minarg2 UNUSED;
00029 #define FMIN(a,b) (minarg1=(a),minarg2=(b),(minarg1) < (minarg2) ?\
00030 (minarg1) : (minarg2))
00031
00032 static long lmaxarg1 UNUSED,lmaxarg2 UNUSED;
00033 #define LMAX(a,b) (lmaxarg1=(a),lmaxarg2=(b),(lmaxarg1) > (lmaxarg2) ?\
00034 (lmaxarg1) : (lmaxarg2))
00035
00036 static long lminarg1 UNUSED,lminarg2 UNUSED;
00037 #define LMIN(a,b) (lminarg1=(a),lminarg2=(b),(lminarg1) < (lminarg2) ?\
00038 (lminarg1) : (lminarg2))
00039
00040 static int imaxarg1 UNUSED,imaxarg2 UNUSED;
00041 #define IMAX(a,b) (imaxarg1=(a),imaxarg2=(b),(imaxarg1) > (imaxarg2) ?\
00042 (imaxarg1) : (imaxarg2))
00043
00044 static int iminarg1 UNUSED,iminarg2 UNUSED;
00045 #define IMIN(a,b) (iminarg1=(a),iminarg2=(b),(iminarg1) < (iminarg2) ?\
00046 (iminarg1) : (iminarg2))
00047
00048 #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a))
00049
00050 #if defined(__STDC__) || defined(ANSI) || defined(NRANSI)
00051
00052 void nrerror(char error_text[]);
00053 float *vector(long nl, long nh);
00054 int *ivector(long nl, long nh);
00055 unsigned char *cvector(long nl, long nh);
00056 unsigned long *lvector(long nl, long nh);
00057 double *dvector(long nl, long nh);
00058 float **matrix(long nrl, long nrh, long ncl, long nch);
00059 double **dmatrix(long nrl, long nrh, long ncl, long nch);
00060 int **imatrix(long nrl, long nrh, long ncl, long nch);
00061 float **submatrix(float **a, long oldrl, long oldrh, long oldcl, long oldch,
00062 long newrl, long newcl);
00063 float **convert_matrix(float *a, long nrl, long nrh, long ncl, long nch);
00064 float ***f3tensor(long nrl, long nrh, long ncl, long nch, long ndl, long ndh);
00065 void free_vector(float *v, long nl, long nh);
00066 void free_ivector(int *v, long nl, long nh);
00067 void free_cvector(unsigned char *v, long nl, long nh);
00068 void free_lvector(unsigned long *v, long nl, long nh);
00069 void free_dvector(double *v, long nl, long nh);
00070 void free_matrix(float **m, long nrl, long nrh, long ncl, long nch);
00071 void free_dmatrix(double **m, long nrl, long nrh, long ncl, long nch);
00072 void free_imatrix(int **m, long nrl, long nrh, long ncl, long nch);
00073 void free_submatrix(float **b, long nrl, long nrh, long ncl, long nch);
00074 void free_convert_matrix(float **b, long nrl, long nrh, long ncl, long nch);
00075 void free_f3tensor(float ***t, long nrl, long nrh, long ncl, long nch,
00076 long ndl, long ndh);
00077
00078 #else
00079
00080
00081 void nrerror();
00082 float *vector();
00083 float **matrix();
00084 float **submatrix();
00085 float **convert_matrix();
00086 float ***f3tensor();
00087 double *dvector();
00088 double **dmatrix();
00089 int *ivector();
00090 int **imatrix();
00091 unsigned char *cvector();
00092 unsigned long *lvector();
00093 void free_vector();
00094 void free_dvector();
00095 void free_ivector();
00096 void free_cvector();
00097 void free_lvector();
00098 void free_matrix();
00099 void free_submatrix();
00100 void free_convert_matrix();
00101 void free_dmatrix();
00102 void free_imatrix();
00103 void free_f3tensor();
00104
00105 #endif
00106
00107 #endif