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

Trapezoidal integrator over tabular data with linear interpolation. More...

#include <MHO_ApMeanIntegrator.hh>

Public Member Functions

 MHO_ApMeanIntegrator ()
 
 ~MHO_ApMeanIntegrator ()
 
int Initialize (int n, const double *coords, const double *val1, const double *val2)
 Load tabular data. Must be called before Integrate(). More...
 
int Integrate (double start, double stop, int *nstart, double *result1, double *result2)
 Compute the average of val1 and val2 over [start, stop]. More...
 

Detailed Description

Trapezoidal integrator over tabular data with linear interpolation.

Replaces the static-buffer ap_mean() function with a re-entrant object. The caller initializes the integrator once with a set of (coord, val1, val2) points, then queries integrated averages over successive [start, stop] intervals. The optional nstart pointer is an optimizer hint so that the search for the first relevant tabular point does not restart from the beginning on each call.

Thread-safe by design: each instance owns its own buffers.

Constructor & Destructor Documentation

◆ MHO_ApMeanIntegrator()

hops::MHO_ApMeanIntegrator::MHO_ApMeanIntegrator ( )

◆ ~MHO_ApMeanIntegrator()

hops::MHO_ApMeanIntegrator::~MHO_ApMeanIntegrator ( )

Member Function Documentation

◆ Initialize()

int hops::MHO_ApMeanIntegrator::Initialize ( int  n,
const double *  coords,
const double *  val1,
const double *  val2 
)

Load tabular data. Must be called before Integrate().

Parameters
nNumber of data points (must be > 0).
coordsMonotonically increasing coordinate array of size n.
val1First value array (e.g. real part) of size n.
val2Second value array (e.g. imaginary part) of size n.
Returns
0 on success, -1 if n <= 0.

◆ Integrate()

int hops::MHO_ApMeanIntegrator::Integrate ( double  start,
double  stop,
int *  nstart,
double *  result1,
double *  result2 
)

Compute the average of val1 and val2 over [start, stop].

Uses trapezoidal integration with linear interpolation at the interval boundaries. Guard points are extrapolated beyond the first and last tabular entries so that edge intervals are handled gracefully.

Parameters
startInterval start coordinate.
stopInterval stop coordinate (must be > start).
nstartIn/out optimizer index. Set to 0 for the first call after Initialize(); the method updates it for subsequent calls.
result1Output average of val1.
result2Output average of val2.
Returns
0 on success, 1 if the interval is out of range (results set to 0), -1 on interpolation error.

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