1 #ifndef MHO_MathUtilities_HH__
2 #define MHO_MathUtilities_HH__
41 static double dwin(
double value,
double lower,
double upper);
54 static int parabola(
double y[3],
double lower,
double upper,
double* x_max,
double* amp_max,
double q[3]);
64 static int minvert3(
double a[3][3],
double ainv[3][3]);
78 static int linterp (
double coord1,
double value1,
double coord2,
double value2,
double coord,
double *
value);
95 static int ap_mean(
double start,
double stop,
double *coords,
double *val1,
double *val2,
int n,
int *nstart,
double *result1,
double *result2);
105 static double average(std::vector< double >& vec);
128 double& lower_freq,
double& upper_freq)
130 if(net_sideband ==
"U")
132 lower_freq = sky_freq;
133 upper_freq = sky_freq + bandwidth;
136 if(net_sideband ==
"L")
138 upper_freq = sky_freq;
139 lower_freq = sky_freq - bandwidth;
143 upper_freq = sky_freq + bandwidth;
144 lower_freq = sky_freq - bandwidth;
162 template<
typename XValueType >
163 static int FindIntersection(XValueType a, XValueType b, XValueType c, XValueType d, XValueType result[2])
181 std::swap(arr[1], arr[3]);
182 std::swap(index[1], index[3]);
186 std::swap(arr[0], arr[2]);
187 std::swap(index[0], index[2]);
191 std::swap(arr[0], arr[1]);
192 std::swap(index[0], index[1]);
196 std::swap(arr[2], arr[3]);
197 std::swap(index[2], index[3]);
201 std::swap(arr[1], arr[2]);
202 std::swap(index[1], index[2]);
217 sum = index[0] + index[1];
219 if((sum == 0) || (sum == 2))
Class MHO_MathUtilities.
Definition: MHO_MathUtilities.hh:25
static int ap_mean(double start, double stop, double *coords, double *val1, double *val2, int n, int *nstart, double *result1, double *result2)
Calculates average phase from start to stop using given coordinates and values.
Definition: MHO_MathUtilities.cc:159
MHO_MathUtilities()
Definition: MHO_MathUtilities.hh:27
static double angular_average(std::vector< double > &vec)
Calculates the average angle in radians from a vector of angles.
Definition: MHO_MathUtilities.cc:346
static int minvert3(double a[3][3], double ainv[3][3])
Calculates the inverse of a 3x3 matrix and stores it in ainv.
Definition: MHO_MathUtilities.cc:57
static int FindIntersection(XValueType a, XValueType b, XValueType c, XValueType d, XValueType result[2])
Function FindIntersection looks for overlap between the intervals [a,b) and [c,d) although if a,...
Definition: MHO_MathUtilities.hh:163
static void DetermineChannelFrequencyLimits(double sky_freq, double bandwidth, std::string net_sideband, double &lower_freq, double &upper_freq)
Calculates lower and upper frequency limits for a given channel based on sky frequency,...
Definition: MHO_MathUtilities.hh:127
static int parabola(double y[3], double lower, double upper, double *x_max, double *amp_max, double q[3])
Calculates parabola parameters and maximum x, amplitude values within a range.
Definition: MHO_MathUtilities.cc:22
static double dwin(double value, double lower, double upper)
Clamps a value between lower and upper bounds.
Definition: MHO_MathUtilities.cc:12
static double average(std::vector< double > &vec)
Calculates the average of values in a vector.
Definition: MHO_MathUtilities.cc:330
virtual ~MHO_MathUtilities()
Definition: MHO_MathUtilities.hh:28
static int linterp(double coord1, double value1, double coord2, double value2, double coord, double *value)
Performs linear interpolation between two points and returns the interpolated value.
Definition: MHO_MathUtilities.cc:110
Definition: MHO_ChannelLabeler.hh:17