30#pragma warning( disable : 4251 )
34#if defined(_WINDOWS) && !defined(__MINGW32__)
36 #define StfnumDll __declspec( dllexport )
38 #define StfnumDll __declspec( dllimport )
48#if (__cplusplus < 201103)
49# include <boost/function.hpp>
63#define INFINITY (DBL_MAX+DBL_MAX)
66 static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
67 #define NAN (*(const float *) __nan)
85#if (__cplusplus < 201103)
93typedef boost::function<double(
double,
double,
double,
double,
double)>
Scale;
103typedef std::function<double(
double,
double,
double,
double,
double)>
Scale;
133 parInfo(
const std::string& desc_,
bool toFit_,
bool constrained_ =
false,
163 Table(
const std::map< std::string, double >& map);
170 double at(std::size_t row,std::size_t col)
const;
177 double&
at(std::size_t row,std::size_t col);
184 bool IsEmpty(std::size_t row,std::size_t col)
const;
191 void SetEmpty(std::size_t row,std::size_t col,
bool value=
true);
220 std::size_t
nRows()
const {
return rowLabels.size(); }
225 std::size_t
nCols()
const {
return colLabels.size(); }
234 std::vector< std::vector<double> > values;
235 std::vector< std::deque< bool > > empty;
236 std::vector< std::string > rowLabels;
237 std::vector< std::string > colLabels;
240#if (__cplusplus < 201103)
246 const std::vector<parInfo>& parsInfo,
257 const std::vector<parInfo>& parsInfo,
281 storedFunc(
const std::string& name_,
const std::vector<parInfo>& pInfo_,
282 const Func& func_,
const Init& init_,
const Jac& jac_,
bool hasJac_ =
true,
332 std::size_t filter_start,
333 std::size_t filter_end,
369 const std::vector<T>& y,
380std::vector<T>
diff(
const std::vector<T>& input, T x_scale);
547typedef std::vector< stfnum::storedFunc >::const_iterator
c_stfunc_it;
568 double factor_i=newF/oldF;
569 int size=(int)y.size();
571 int size_i=(int)(
size*factor_i);
574 for (
int n_p=0; n_p <
size; ++n_p) {
580 std::vector<T> y_if(size_i);
584 for (
int n_i=0; n_i < size_i; ++n_i) {
585 x_i[n_i]=(double)n_i * (
double)
size/(double)size_i;
594 std::vector<T> diffVA(input.size()-1);
595 for (
unsigned n=0;
n<diffVA.size();++
n) {
596 diffVA[
n]=(input[
n+1]-input[
n])/x_scale;
WORD TSTime TpMarker WORD size
A table used for printing information.
std::vector< double > Vector_double
Vector_double nojac(double x, const Vector_double &p)
Dummy function, serves as a placeholder to initialize functions without a Jacobian.
StfnumDll double fbessel4(double x, const Vector_double &p)
Computes a 4th-order Bessel polynomial that can be used as a filter kernel.
int linsolv(int m, int n, int nrhs, Vector_double &A, Vector_double &B)
Solves a linear equation system using LAPACK.
std::size_t nRows() const
Retrieves the number of rows.
Table(const std::map< std::string, double > &map)
Constructor.
StfnumDll double integrate_simpson(const Vector_double &input, std::size_t a, std::size_t b, double x_scale)
Integration using Simpson's rule.
direction
The direction of peak calculations.
double & at(std::size_t row, std::size_t col)
Range-checked access. Returns a reference. Throws std::out_of_range if out of range.
std::map< double, int > histogram(const Vector_double &data, int nbins=-1)
Computes a histogram.
int pow2(int arg)
Computes . Uses the bitwise-shift operator (<<).
bool IsEmpty(std::size_t row, std::size_t col) const
Check whether a cell is empty.
boost::function< void(const Vector_double &, double, double, double, double, double, Vector_double &)> Init
Initialising function for the parameters in stfnum::Func to start a fit.
StfnumDll Vector_double quad(const Vector_double &data, std::size_t begin, std::size_t end)
Solve quadratic equations for 3 adjacent sampling points.
std::vector< T > diff(const std::vector< T > &input, T x_scale)
Differentiate data.
StfnumDll std::vector< int > peakIndices(const Vector_double &data, double threshold, int minDistance)
Searches for positive-going peaks.
StfnumDll Vector_double linCorr(const Vector_double &va1, const Vector_double &va2, stfio::ProgressInfo &progDlg)
Computes the linear correlation between two arrays.
boost::function< Vector_double(double, const Vector_double &)> Jac
The jacobian of a stfnum::Func.
StfnumDll Vector_double filter(const Vector_double &toFilter, std::size_t filter_start, std::size_t filter_end, const Vector_double &a, int SR, stfnum::Func func, bool inverse=false)
Convolves a data set with a filter function.
StfnumDll double fgaussColqu(double x, const Vector_double &p)
Computes a Gaussian that can be used as a filter kernel.
parInfo()
Default constructor.
boost::function< double(double, const Vector_double &)> Func
A function taking a double and a vector and returning a double.
boost::function< Table(const Vector_double &, const std::vector< stfnum::parInfo >, double)> Output
Print the output of a fit into a stfnum::Table.
Table defaultOutput(const Vector_double &pars, const std::vector< parInfo > &parsInfo, double chisqr)
Default fit output function, constructing a stfnum::Table from the parameters, their description and ...
const std::string & GetRowLabel(std::size_t row) const
Retrieves the label of a row.
StfnumDll double integrate_trapezium(const Vector_double &input, std::size_t a, std::size_t b, double x_scale)
Integration using the trapezium rule.
StfnumDll double threshold(const std::vector< double > &data, std::size_t llp, std::size_t ulp, double slope, double &thrT, std::size_t windowLength)
Find the value within data between llp and ulp at which slope is exceeded.
parInfo(const std::string &desc_, bool toFit_, bool constrained_=false, double constr_lb_=0, double constr_ub_=0, Scale scale_=noscale, Scale unscale_=noscale)
Constructor.
void AppendRows(std::size_t nRows)
Appends rows to the table.
std::vector< parInfo > pInfo
StfnumDll Vector_double deconvolve(const Vector_double &data, const Vector_double &templ, int SR, double hipass, double lopass, stfio::ProgressInfo &progDlg)
Deconvolves a template from a signal.
T SQR(T a)
Calculates the square of a number.
void SetRowLabel(std::size_t row, const std::string &label)
Sets the label of a row.
baseline_method
Methods for Baseline computation.
void SetColLabel(std::size_t col, const std::string &label)
Sets the label of a column.
const std::string & GetColLabel(std::size_t col) const
Retrieves the label of a column.
double at(std::size_t row, std::size_t col) const
Range-checked access. Returns a copy. Throws std::out_of_range if out of range.
StfnumDll Vector_double detectionCriterion(const Vector_double &data, const Vector_double &templ, stfio::ProgressInfo &progDlg)
Computes the event detection criterion according to Clements & Bekkers (1997).
double xscale(double param, double xscale, double xoff, double yscale, double yoff)
Scales a parameter that linearly depends on x.
std::vector< T > cubicSpline(const std::vector< T > &y, T oldF, T newF)
Interpolates a dataset using cubic splines.
double noscale(double param, double xscale, double xoff, double yscale, double yoff)
Dummy function, serves as a placeholder to initialize parameters without a scaling function.
storedFunc(const std::string &name_, const std::vector< parInfo > &pInfo_, const Func &func_, const Init &init_, const Jac &jac_, bool hasJac_=true, const Output &output_=defaultOutput)
Constructor.
double fboltz(double x, const Vector_double &p)
Computes a Boltzmann function.
Table(std::size_t nRows, std::size_t nCols)
Constructor.
std::size_t nCols() const
Retrieves the number of columns.
double fbessel(double x, int n)
Computes a Bessel polynomial.
int fac(int arg)
Computes the faculty of an integer.
boost::function< double(double, double, double, double, double)> Scale
Scaling function for fit parameters.
double yscale(double param, double xscale, double xoff, double yscale, double yoff)
Scales a parameter that linearly depends on y.
void SetEmpty(std::size_t row, std::size_t col, bool value=true)
Empties or un-empties a cell.
double spline_cubic_val(const Vector_double &t, double tval, const Vector_double &y, const Vector_double &ypp, double &ypval, double &yppval)
Vector_double spline_cubic_set(const Vector_double &t, const Vector_double &y, int ibcbeg, double ybcbeg, int ibcend, double ybcend)
Cubic spline interpolation.
void SWAP(T s1, T s2)
Swaps s1 and s2.
std::vector< stfnum::storedFunc >::const_iterator c_stfunc_it
#define StfnumDll
Defines dll export or import functions for libstfnum on Windows.