HOPS
HOPS class reference
Public Member Functions | Static Public Member Functions | List of all members
hops::MHO_MathUtilities Class Reference

Class MHO_MathUtilities. More...

#include <MHO_MathUtilities.hh>

Public Member Functions

 MHO_MathUtilities ()
 
virtual ~MHO_MathUtilities ()
 

Static Public Member Functions

static double angular_average (std::vector< double > &vec)
 Calculates the average angle in radians from a vector of angles. More...
 
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. More...
 
static double average (std::vector< double > &vec)
 Calculates the average of values in a vector. More...
 
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, bandwidth, and net sideband. More...
 
static double dwin (double value, double lower, double upper)
 Clamps a value between lower and upper bounds. More...
 
template<typename XValueType >
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,b and c,d are the end-points of an intervals we do not explicitly assume they are ordered there. More...
 
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. More...
 
static int minvert3 (double a[3][3], double ainv[3][3])
 Calculates the inverse of a 3x3 matrix and stores it in ainv. More...
 
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. More...
 

Detailed Description

Class MHO_MathUtilities.

implements a variety of simple math functions copied from original hops3 c code with minimal changes along with some other simple helper functions

Author
J. Barrett - barre.nosp@m.ttj@.nosp@m.mit.e.nosp@m.du
Date
Tue Dec 5 17:01:15 2023 -0500

Constructor & Destructor Documentation

◆ MHO_MathUtilities()

hops::MHO_MathUtilities::MHO_MathUtilities ( )
inline

◆ ~MHO_MathUtilities()

virtual hops::MHO_MathUtilities::~MHO_MathUtilities ( )
inlinevirtual

Member Function Documentation

◆ angular_average()

double hops::MHO_MathUtilities::angular_average ( std::vector< double > &  vec)
static

Calculates the average angle in radians from a vector of angles.

Parameters
vecInput vector of angles in radians.
Returns
Average angle in radians.
Note
This is a static function.

◆ ap_mean()

int hops::MHO_MathUtilities::ap_mean ( double  start,
double  stop,
double *  coords,
double *  val1,
double *  val2,
int  n,
int *  nstart,
double *  result1,
double *  result2 
)
static

Calculates average phase from start to stop using given coordinates and values.

Parameters
startStarting point for averaging
stopEnding point for averaging
coordsArray of coordinate points
val1First set of value points corresponding to coords
val2Second set of value points corresponding to coords
nNumber of points in coords and val arrays
nstartStarting point for averaging, saved from previous call
result1Output: Average of first set of values
result2Output: Average of second set of values
Returns
0 on success, -1 on error
Note
This is a static function.

◆ average()

double hops::MHO_MathUtilities::average ( std::vector< double > &  vec)
static

Calculates the average of values in a vector.

Parameters
vecInput vector of doubles
Returns
Average value as double
Note
This is a static function.

◆ DetermineChannelFrequencyLimits()

static void hops::MHO_MathUtilities::DetermineChannelFrequencyLimits ( double  sky_freq,
double  bandwidth,
std::string  net_sideband,
double &  lower_freq,
double &  upper_freq 
)
inlinestatic

Calculates lower and upper frequency limits for a given channel based on sky frequency, bandwidth, and net sideband.

Parameters
sky_freqInput sky frequency in MHz
bandwidthBandwidth of the channel in MHz
net_sidebandNetwork sideband ('U' for upper, 'L' for lower)
lower_freqOutput lower frequency limit in MHz
upper_freqOutput upper frequency limit in MHz
Note
This is a static function.

◆ dwin()

double hops::MHO_MathUtilities::dwin ( double  value,
double  lower,
double  upper 
)
static

Clamps a value between lower and upper bounds.

Parameters
valueThe input value to be clamped.
lowerThe lower bound for clamping.
upperThe upper bound for clamping.
Returns
The clamped value within the specified bounds.
Note
This is a static function.

◆ FindIntersection()

template<typename XValueType >
static int hops::MHO_MathUtilities::FindIntersection ( XValueType  a,
XValueType  b,
XValueType  c,
XValueType  d,
XValueType  result[2] 
)
inlinestatic

Function FindIntersection looks for overlap between the intervals [a,b) and [c,d) although if a,b and c,d are the end-points of an intervals we do not explicitly assume they are ordered there.

Template Parameters
XValueTypeTemplate parameter XValueType
Parameters
a(XValueType)
b(XValueType)
c(XValueType)
d(XValueType)
result[2]Parameter description
Returns
Return value (int)
Note
This is a static function.

◆ linterp()

int hops::MHO_MathUtilities::linterp ( double  coord1,
double  value1,
double  coord2,
double  value2,
double  coord,
double *  value 
)
static

Performs linear interpolation between two points and returns the interpolated value.

Parameters
coord1Coordinate of the first point
value1Value at the first coordinate
coord2Coordinate of the second point
value2Value at the second coordinate
coordCoordinate for which to interpolate
valueOutput parameter for the interpolated value
Returns
0 if successful, -1 and error message on failure
Note
This is a static function.

◆ minvert3()

int hops::MHO_MathUtilities::minvert3 ( double  a[3][3],
double  ainv[3][3] 
)
static

Calculates the inverse of a 3x3 matrix and stores it in ainv.

Parameters
a[3][3]Input 3x3 matrix to be inverted
ainv[3][3]Parameter description
Returns
Non-zero if input matrix is singular, zero otherwise
Note
This is a static function.

◆ parabola()

int hops::MHO_MathUtilities::parabola ( double  y[3],
double  lower,
double  upper,
double *  x_max,
double *  amp_max,
double  q[3] 
)
static

Calculates parabola parameters and maximum x, amplitude values within a range.

Parameters
y[3]Input coordinates for parabola calculation
lowerLower bound of the range
upperUpper bound of the range
x_maxOutput: Maximum x-value in the given range
amp_maxOutput: Maximum amplitude value in the given range
q[3]Output: Coefficients for parabola equation
Returns
Error code indicating interpolation status (0: success, 1: max at edge, 2: positive curvature)
Note
This is a static function.

The documentation for this class was generated from the following files: