00001
00002
00009 #ifndef __helperfunc_h__
00010 #define __helperfunc_h__
00011
00012 #include <string>
00013 #include <vector>
00014
00015 using namespace std;
00016
00017 #include "Matrix.h"
00018 #include "Cvals.h"
00019
00020
00021 #ifndef M_PI
00022 #define M_PI 3.1415926535897932385
00023 #endif
00024
00028 struct array_data
00029 {
00030 int dimension;
00031 int * col_length;
00032 int bytes;
00033 int type;
00035 void * arr;
00036 };
00037
00038 void * alloc_1d_array(int size, int type);
00039 struct array_data alloc_mem(int dimension, int type, ...);
00040 void * shift_pointer(void * pointer, int type, int num);
00041 void set_pointer_pointer_val(void * pointer, int type, void * val);
00042 void * get_pointer_pointer_val(void * pointer, int type);
00043 void print_alloc_data(struct array_data arr);
00044 void check_pointer_sanity(void * pointer, const char * func);
00045 void print_pointer_val(void * pointer, int type);
00046 void free_mem(struct array_data arr);
00047
00048
00049
00050
00051
00052
00054 int gridder(int nx, int ny, int ndata, int offset[3], int jump[3],
00055 double xmin, double xmax, double ymin, double ymax,
00056 float * xval, float * yval, float * val,
00057 float * xsep, float * ysep, float ** results);
00058 int gridder(int nx, int ny, int ndata, int offset[3], int jump[3],
00059 double xmin, double xmax, double ymin, double ymax,
00060 float * xval, float * yval, float * val,
00061 vector<float> & xsep, vector<float> & ysep,
00062 Matrix<float> & results, Matrix<int> & number);
00063 int gridder(int nx, int ny, int ilow, int ihigh,
00064 double xmin, double xmax, double ymin, double ymax,
00065 Cvals * xval, Cvals * yval, Cvals * val,
00066 vector<float> & xsep, vector<float> & ysep,
00067 Matrix<float> & results, Matrix<int> & number);
00068
00069 double get_upbnd_bin_linear(int nbins, double xmin, double xmax, int bin);
00070 double get_lowbnd_bin_linear(int nbins, double xmin, double xmax, int bin);
00071 int get_bin_number_linear(int nbins, double xmin, double xmax, double xval);
00072 double get_center_bin_linear(int nbins, double xmin, double xmax, int bin);
00073
00074
00075
00076
00077
00078
00080 float * al1df(int nval);
00081 void fr1df(float * pointer);
00082
00084 float ** al2df(int nrow, int ncol);
00085 void fr2df(float ** pointer, int ncol);
00086
00087
00088
00089
00090
00091
00092
00093
00094 void flhunt(float * xx, int n, float x, int *jlo);
00095 void flhunt(vector<float> xx, int n, float x, int *jlo);
00096
00097
00098
00099
00100
00101 void
00102 convolve_2d_standard(std::string type, Matrix <float> & matrix, vector <float> xvals, vector <float> yvals,
00103 std::vector <double> parameters);
00104 void
00105 convolve_2d_standard_gaussian(float * array, int nrow, int ncol, const vector<float> & xvals, const vector<float> & yvals,
00106 double xsigma, double ysigma,
00107 const double & gauss_cut);
00108 void
00109 convolve_2d_standard_gaussian(Matrix <float> & matrix, const vector <float> & xvals, const vector <float> & yvals,
00110 double xsigma, double ysigma,
00111 const double & gauss_cut=0.);
00112
00113 void
00114 convolve_2d_standard_gaussian_row(unsigned n,
00115 Matrix <float> & matrix, Matrix <float> & temp,
00116 const vector <float> & xvals, const vector <float> & yvals,
00117 double xsigma, double ysigma,
00118 const int & xcut, const int & ycut);
00119
00120 void
00121 convolve_2d_standard_gaussian_point(unsigned n, unsigned m,
00122 Matrix <float> & matrix, Matrix <float> & temp,
00123 const vector <float> & xvals, const vector <float> & yvals,
00124 double xsigma, double ysigma,
00125 const int & xcut, const int & ycut);
00126
00127 void
00128 convolve_2d_standard_gaussian_varsig(unsigned n, unsigned m,
00129 Matrix <float> & matrix, Matrix <float> & temp,
00130 const Matrix <float> & xsig, const Matrix <float> & ysig,
00131 const vector <float> & xvals, const vector <float> & yvals);
00132
00133 void
00134 test_convolution(void);
00135
00136
00137 #endif