DecompLib
A simple library for decomposition of spectra using a response matrix.
|
Functions used to decompose the input spectrum. More...
Functions | |
template<typename ParamType > | |
long long | performDecomposition (DataVector< ParamType > &data, RespMatrix< ParamType > &respMatrix, DecompVector< ParamType > ¶mSet, ParamType minThresh=1e-6, ParamType convThresh=0.005, bool printBadSafety=true) |
Performs a decomposition of data using respMatrix and the initial guess in paramSet, it then outputs the result in paramSet. More... | |
template<typename ParamType > | |
bool | testConvergence (ParamType *oldVals, ParamType *newVals, int numRespFuncs, ParamType minThresh, ParamType convThresh) |
Tests if two parameter sets vary more than convThresh. More... | |
template<typename ParamType > | |
int | testSafety (DataVector< ParamType > &data, RespMatrix< ParamType > &respMatrix, DecompVector< ParamType > ¶mSet, ParamType minThresh, ParamType convThresh, bool printBadSafety=true) |
Tests the inputs that would go into performDecomposition for safety. More... | |
Functions used to decompose the input spectrum.
The function performDecomposition takes the inputs and iterates until it has attained convergence.
testConvergence is used by performDecomposition to check if it has obtained convergence in that iteration
long long performDecomposition | ( | DataVector< ParamType > & | data, |
RespMatrix< ParamType > & | respMatrix, | ||
DecompVector< ParamType > & | paramSet, | ||
ParamType | minThresh = 1e-6 , |
||
ParamType | convThresh = 0.005 , |
||
bool | printBadSafety = true |
||
) |
Performs a decomposition of data using respMatrix and the initial guess in paramSet, it then outputs the result in paramSet.
ParamType | The floating point type that is to be used for the calculations |
data | The DataVector with the spectrum to be decomposed |
respMatrix | The RespMatrix which holds the set of response functions to use to decompose the data spectrum |
paramSet | The DecompVector which contains the initial guess and will contain the final decomposition parameters |
minThresh | The value below which parameters are not tested for determining convergence defaults to 1.0e-6 |
convThresh | The maximum fractional change between iterations allowed before parameters are considered unconverged defaults to 0.005 |
printBadSafety | Print what failed in a safety check |
Error Value | Description |
---|---|
-1 | A row or column of the response matrix contains all zeros |
-2 | One of the initial decomposition parameters is less than or equal to zero |
-3 | The data vector is either all zeros or contains one or more negative numbers |
-4 | The number of bins in the input spectrum is not the same as the number of bins in a response function |
-5 | The number of response functions is not the same as the number of bins in the DecompVector |
-6 | The minimum value to be tested for convergence is less than or equal to zero |
-7 | The maximum change allowed to be considered converged is less than or equal to zero |
-8 | The number of bins in the input spectrum does not exceed the number of response functions |
\[ f_{\mu}^{(s+1)} = \frac{1}{\sum\limits_{j}R_{\mu{}j}} \sum\limits_{i}\frac{f_{\mu{}}^{(s)} R_{\mu{}i}d_i}{\sum\limits_{\alpha}R_{\alpha{}i}f_{\alpha}^{(s)}} \]
Where \(f_{\mu}^{(s+1)}\) contains the decomposition weights / spectrum for iteration \((s+1)\), \(R_{\mu{}\nu{}}\) contains the response matrix, and \(d_{i}\) contains the initial spectrum to be decomposed.The formula above is slightly rearranged to yield the algorithm used in the function below.
Definition at line 62 of file Decomposition.h.
References DataVector< ParamType >::getElement(), DecompVector< ParamType >::getElement(), RespMatrix< ParamType >::getMatrixPtr(), RespMatrix< ParamType >::getNumRespFuncs(), RespMatrix< ParamType >::getRespFuncsLens(), RespMatrix< ParamType >::getSummedRowPtr(), RespMatrix< ParamType >::getTransposePtr(), DecompVector< ParamType >::setElement(), testConvergence(), and testSafety().
bool testConvergence | ( | ParamType * | oldVals, |
ParamType * | newVals, | ||
int | numRespFuncs, | ||
ParamType | minThresh, | ||
ParamType | convThresh | ||
) |
Tests if two parameter sets vary more than convThresh.
ParamType | The floating point type contained in the arrays of values to check for convergence |
oldVals | The array of parameters at the beginning of the current iteration |
newVals | The array of parameters at the end of the current iteration |
numRespFuncs | The number of response functions for the decomposition / the length of oldVals and newVals |
minThresh | The value that causes a parameter to be ignored if both the old and new val sets have a parameter whose value is below minThresh it is not considered for determining convergence |
convThresh | The maximum fractional change allowed before a pair of parameters are considered un-converged |
Definition at line 34 of file Helper.h.
Referenced by performDecomposition().
int testSafety | ( | DataVector< ParamType > & | data, |
RespMatrix< ParamType > & | respMatrix, | ||
DecompVector< ParamType > & | paramSet, | ||
ParamType | minThresh, | ||
ParamType | convThresh, | ||
bool | printBadSafety = true |
||
) |
Tests the inputs that would go into performDecomposition for safety.
ParamType | The floating point type that is to be used for the calculations |
data | The DataVector with the spectrum to be decomposed |
respMatrix | The RespMatrix which holds the set of response functions to use to decompose the data spectrum |
paramSet | The DecompVector which contains the initial guess and will contain the final decomposition parameters |
minThresh | The value below which parameters are not tested for determining convergence defaults to 1.0e-6 |
convThresh | The maximum fractional change between iterations allowed before parameters are considered unconverged defaults to 0.005 |
printBadSafety | Print what failed in a safety check |
Error Value | Description |
---|---|
-1 | A row or column of the response matrix contains all zeros |
-2 | One of the initial decomposition parameters is less than or equal to zero |
-3 | The data vector is either all zeros or contains one or more negative numbers |
-4 | The number of bins in the input spectrum is not the same as the number of bins in a response function |
-5 | The number of response functions is not the same as the number of bins in the DecompVector |
-6 | The minimum value to be tested for convergence is less than or equal to zero |
-7 | The maximum change allowed to be considered converged is less than or equal to zero |
-8 | The number of bins in the input spectrum does not exceed the number of response functions |
Definition at line 79 of file Helper.h.
References DataVector< ParamType >::getLength(), DecompVector< ParamType >::getLength(), RespMatrix< ParamType >::getNumRespFuncs(), RespMatrix< ParamType >::getRespFuncsLens(), DataVector< ParamType >::isSafe(), DecompVector< ParamType >::isSafe(), and RespMatrix< ParamType >::isSafe().
Referenced by performDecomposition().