TwiceAsNice  2019-02-18
Static Public Member Functions | Static Protected Member Functions | List of all members
Nice::Alg Class Reference

#include <Alg.h>

Collaboration diagram for Nice::Alg:
Collaboration graph

Static Public Member Functions

template<class T >
static void SWAP (T &a, T &b)
 exchange (swap) two values. More...
 
template<class T >
static constSQR (const T a)
 compute the square of a value More...
 
static void linearFit (boost::numeric::ublas::vector< double > &_x, boost::numeric::ublas::vector< double > &_y, boost::numeric::ublas::vector< double > &_sig, boost::numeric::ublas::vector< double > &_a, boost::numeric::ublas::vector< bool > &_ia, boost::numeric::ublas::matrix< double > &_covar, double &_chisq, void _funcs(const double, boost::numeric::ublas::vector< double > &))
 linear least-square solver using normal equations More...
 
static void gaussj (boost::numeric::ublas::matrix< double > &a, boost::numeric::ublas::matrix< double > &b)
 Gauss-Jordan elimination. More...
 
static void covsrt (boost::numeric::ublas::matrix< double > &_covar, boost::numeric::ublas::vector< bool > &_ia, const int _mfit)
 Sorts covariance matrix. More...
 
template<typename T >
static std::vector< std::vector< int > > subSets (T N, T m)
 construct subsets of size m out of n elements More...
 
static Nice::SeqPoint generateSpiral (const Nice::Circle &c, int type, double latConst)
 construct a chain of points on a c.c.w. spiral. More...
 
template<class T >
static void SWAP (T &a, T &b)
 exchange (swap) two values. More...
 
template<class T >
static constSQR (const T a)
 compute the square of a value More...
 
static void linearFit (boost::numeric::ublas::vector< double > &_x, boost::numeric::ublas::vector< double > &_y, boost::numeric::ublas::vector< double > &_sig, boost::numeric::ublas::vector< double > &_a, boost::numeric::ublas::vector< bool > &_ia, boost::numeric::ublas::matrix< double > &_covar, double &_chisq, void _funcs(const double, boost::numeric::ublas::vector< double > &))
 
static void gaussj (boost::numeric::ublas::matrix< double > &a, boost::numeric::ublas::matrix< double > &b)
 
static void covsrt (boost::numeric::ublas::matrix< double > &_covar, boost::numeric::ublas::vector< bool > &_ia, const int _mfit)
 
template<typename T >
static std::vector< std::vector< int > > subSets (T N, T m)
 
static Nice::SeqPoint generateSpiral (const Nice::Circle &c, int type, double latConst)
 

Static Protected Member Functions

template<typename T >
static std::vector< std::vector< int > > subSets (T N, T m, std::vector< int > fxd, T minm)
 construct subsets of size m out of n elements More...
 
template<typename T >
static std::vector< std::vector< int > > subSets (T N, T m, std::vector< int > fxd, T minm)
 

Member Function Documentation

◆ covsrt() [1/2]

void Nice::Alg::covsrt ( boost::numeric::ublas::matrix< double > &  covar,
boost::numeric::ublas::vector< bool > &  ia,
const int  mfit 
)
static

Sorts covariance matrix.

Parameters
_covar
_ia
_mfit

◆ covsrt() [2/2]

static void Nice::Alg::covsrt ( boost::numeric::ublas::matrix< double > &  _covar,
boost::numeric::ublas::vector< bool > &  _ia,
const int  _mfit 
)
static

◆ gaussj() [1/2]

void Nice::Alg::gaussj ( boost::numeric::ublas::matrix< double > &  a,
boost::numeric::ublas::matrix< double > &  b 
)
static

Gauss-Jordan elimination.

Used e.g. by lfit to solve for the coefficients (and to find the covariance matrix)

Parameters
_a
_b

◆ gaussj() [2/2]

static void Nice::Alg::gaussj ( boost::numeric::ublas::matrix< double > &  a,
boost::numeric::ublas::matrix< double > &  b 
)
static

◆ generateSpiral() [1/2]

Nice::SeqPoint Nice::Alg::generateSpiral ( const Nice::Circle c,
int  type,
double  latConst 
)
static

construct a chain of points on a c.c.w. spiral.


Parameters
cA circle which will contain the spiral. The center of the circle defines the starting point of the spiral. The radius of the circle defines how far the spiral radius may reach out from the center.
typeType of the discret underlying lattice. If type=0 the points are on a simple 2D quadratic lattice. If type=1 the points are on a simple triangular (a.k.a. hexagonal) lattice. There is no type for centered square lattices, because these are the same as quadratic lattices rotated by 45 degrees and shrunk by a factor sqrt(2). (So they may be derived by rotation and shrinking the vector of points returned by this function.)
latConstThe lattice constant in the same units as the circle center and radius. This is the shortest distance between two distinct points on the lattice. That value should not be an integer multiple of the lattice constant (to avoid fuzzy interpretation of which points on the spiral stay within the circle)
Returns
A sequence of points with increasing distance from the circle center.
Since
2017-11-02
Author
R. J. Mathar

◆ generateSpiral() [2/2]

static Nice::SeqPoint Nice::Alg::generateSpiral ( const Nice::Circle c,
int  type,
double  latConst 
)
static

◆ linearFit() [1/2]

void Nice::Alg::linearFit ( boost::numeric::ublas::vector< double > &  _x,
boost::numeric::ublas::vector< double > &  _y,
boost::numeric::ublas::vector< double > &  _sig,
boost::numeric::ublas::vector< double > &  _a,
boost::numeric::ublas::vector< bool > &  _ia,
boost::numeric::ublas::matrix< double > &  _covar,
double &  _chisq,
void   _funcsconst double, boost::numeric::ublas::vector< double > & 
)
static

linear least-square solver using normal equations

Given a set of data points _x[0..ndat-1], _y[0..ndat-1] with inidividual standard deviations sig[0..ndat-1], use chi-squared minimization to fit for some or all of the coefficeints a[0..ma-1] of a function that depends linearly on a, y=sum_i a_i*afunc_i(x). The boolean input array ia[0..ma-1] indicates by true entries those components of a that should be fitted for, and by false entries those components that should be held fixed at their input values. The program returns values for a[0..ma-1], chi-square=chisq, and the covariance matrix covar[0..ma-1][0..ma-1]. (Parameters held fixed will return zero covariances.) The user supplies a routine funcs(x,afunc) that returns the ma basis functions evaluated at x=x in the array afunc[0..ma-1]). (Excerpt of numerical recipies section 15.4)

Parameters
[in]_xdata points (x)
[in]_ydata points (y)
[in]_sigstandard deviations of the data points
[out]_acoefficients
[in]_iaflags for each coefficient. if false, coefficient will be kept constant
[out]_covarcovariance matrix will be returned
[out]_chisqchi^2 as return value
[in]_funcsthe function that is linear to the coefficients a

◆ linearFit() [2/2]

static void Nice::Alg::linearFit ( boost::numeric::ublas::vector< double > &  _x,
boost::numeric::ublas::vector< double > &  _y,
boost::numeric::ublas::vector< double > &  _sig,
boost::numeric::ublas::vector< double > &  _a,
boost::numeric::ublas::vector< bool > &  _ia,
boost::numeric::ublas::matrix< double > &  _covar,
double &  _chisq,
void   _funcsconst double, boost::numeric::ublas::vector< double > & 
)
static

◆ SQR() [1/2]

template<class T >
static const T Nice::Alg::SQR ( const a)
inlinestatic

compute the square of a value


Parameters
aThe value to be squared.
Returns
The square of a.

◆ SQR() [2/2]

template<class T >
static const T Nice::Alg::SQR ( const a)
inlinestatic

compute the square of a value


Parameters
aThe value to be squared.
Returns
The square of a.

◆ subSets() [1/4]

template<typename T >
std::vector< std::vector< int > > Nice::Alg::subSets ( N,
m 
)
static

construct subsets of size m out of n elements


This is the standard combinatorial sub-set construction. For N=5 , m=3 we construct <0,1,2>, <0,1,3>, <0,1,4>, <0,2,3>, <0,2,4>...., <2,3,4>.

Parameters
NThe number of elements to choose from.
mThe number of elements selected in each element of the result.
Returns
ordered lists of numbers in the range 0..n-1 where each list has m elements. The cardinality of the outer vector is biomial(N,m).
Since
2017-03-30
Author
R. J. Mathar

◆ subSets() [2/4]

template<typename T >
static std::vector< std::vector<int> > Nice::Alg::subSets ( N,
m 
)
static

◆ subSets() [3/4]

template<typename T >
static std::vector< std::vector<int> > Nice::Alg::subSets ( N,
m,
std::vector< int >  fxd,
minm 
)
staticprotected

◆ subSets() [4/4]

template<typename T >
std::vector< std::vector< int > > Nice::Alg::subSets ( N,
m,
std::vector< int >  fxd,
minm 
)
staticprotected

construct subsets of size m out of n elements


Parameters
NThe number of elements to coose from.
mThe number of elements selected in each element of the result.
[in]fxdThe sublist of indices which are already fixed.
[in]minmA lower bound of the indices to be taken freely.
Returns
ordered lists of numbers in the range 0..n-1 where
Since
2017-03-30
Author
R. J. Mathar

◆ SWAP() [1/2]

template<class T >
static void Nice::Alg::SWAP ( T &  a,
T &  b 
)
inlinestatic

exchange (swap) two values.


Parameters
[in,out]a
[in,out]b

◆ SWAP() [2/2]

template<class T >
static void Nice::Alg::SWAP ( T &  a,
T &  b 
)
inlinestatic

exchange (swap) two values.


Parameters
[in,out]a
[in,out]b

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