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