DecompLib
A simple library for decomposition of spectra using a response matrix.
DecompVector< ParamType > Class Template Reference

A representation of the vector of decomposition parameters that is passed into the decomposition as an initial guess and passed out as the final answer. More...

#include <DecompVector.h>

Public Member Functions

 DecompVector (int length, bool printBadSafety=true)
 Constructor. More...
 
 DecompVector (const DecompVector< ParamType > &dv)
 Copy Constructor. More...
 
ParamType getElement (int index) const
 Returns the value of the vector at index. More...
 
int getLength () const
 Gets the size of the vector. More...
 
ParamType * getRawDataPtr ()
 Gives access to the underlying vector pointer. More...
 
void initWithConstant (const ParamType &val)
 Initializes this vector with a constant parameter. More...
 
void initWithDataVector (const DataVector< ParamType > &val, const ParamType &factor, const ParamType &offset=0.0)
 Initializes this vector by subsampling a DataVector. More...
 
bool isSafe ()
 Checks if the decomp vector guess is safe for usage in the decomposition. More...
 
DecompVector< ParamType > & operator= (const DecompVector< ParamType > &dv)
 Assignment Operator. More...
 
void setElement (int index, ParamType value)
 Places a given value into a specific index in the vector. More...
 

Private Attributes

bool printErrors
 Stores if errors should be printed during safety checks.
 
int size
 The number of cells in the input data vector.
 
double TinyValue = 1.0e-10
 Tiny value to use where the input spectrum is zero / too small in initialization.
 
ParamType * vec
 The data vector itself.
 

Detailed Description

template<typename ParamType>
class DecompVector< ParamType >

A representation of the vector of decomposition parameters that is passed into the decomposition as an initial guess and passed out as the final answer.

Template Parameters
ParamTypeThe floating point type for which this calculation will be carried out

Definition at line 32 of file DecompVector.h.

Constructor & Destructor Documentation

template<typename ParamType>
DecompVector< ParamType >::DecompVector ( int  length,
bool  printBadSafety = true 
)
inline

Constructor.

Parameters
lengththe number of values in the vector
printBadSafetyWhether or not to print locations of errors in safety checks

Definition at line 40 of file DecompVector.h.

References DecompVector< ParamType >::operator=(), and DecompVector< ParamType >::vec.

template<typename ParamType >
DecompVector< ParamType >::DecompVector ( const DecompVector< ParamType > &  dv)

Copy Constructor.

Parameters
dvThe original DecompVector to copy

Definition at line 121 of file DecompVector.h.

References DecompVector< ParamType >::size, and DecompVector< ParamType >::vec.

Member Function Documentation

template<typename ParamType>
ParamType DecompVector< ParamType >::getElement ( int  index) const
inline

Returns the value of the vector at index.

Parameters
indexThe index into the vector
Returns
the value of the vector at index
Remarks
if index is negative or greater than the length of the vector, behavior is undefined

Definition at line 73 of file DecompVector.h.

References DecompVector< ParamType >::vec.

Referenced by performDecomposition().

template<typename ParamType>
int DecompVector< ParamType >::getLength ( ) const
inline

Gets the size of the vector.

Returns
The number of cells in the vector

Definition at line 79 of file DecompVector.h.

References DecompVector< ParamType >::initWithConstant(), DecompVector< ParamType >::initWithDataVector(), and DecompVector< ParamType >::size.

Referenced by testSafety().

template<typename ParamType>
ParamType* DecompVector< ParamType >::getRawDataPtr ( )
inline

Gives access to the underlying vector pointer.

Returns
The underlying vector pointer
Remarks
This function should only be used within decomp library

Definition at line 102 of file DecompVector.h.

References DecompVector< ParamType >::isSafe(), and DecompVector< ParamType >::vec.

template<typename ParamType >
void DecompVector< ParamType >::initWithConstant ( const ParamType &  val)

Initializes this vector with a constant parameter.

Parameters
valThe value that every element of the vector should contain

Definition at line 176 of file DecompVector.h.

References DecompVector< ParamType >::size, and DecompVector< ParamType >::vec.

Referenced by DecompVector< ParamType >::getLength().

template<typename ParamType >
void DecompVector< ParamType >::initWithDataVector ( const DataVector< ParamType > &  val,
const ParamType &  factor,
const ParamType &  offset = 0.0 
)

Initializes this vector by subsampling a DataVector.

Parameters
valThe data vector that this decomp vector should be initialized from, the length of this vector should be greater than or equal to the length of this vector
factorA factor to multiply the values from the data vector by
offsetAn offset to add to the values from the data vector

Definition at line 145 of file DecompVector.h.

References DataVector< ParamType >::getElement(), DataVector< ParamType >::getLength(), DecompVector< ParamType >::size, DecompVector< ParamType >::TinyValue, and DecompVector< ParamType >::vec.

Referenced by DecompVector< ParamType >::getLength().

template<typename ParamType >
bool DecompVector< ParamType >::isSafe ( )

Checks if the decomp vector guess is safe for usage in the decomposition.

Returns
True if safe, False if unsafe

Checking the vector's safety involves testing that every element is greater than zero

Definition at line 185 of file DecompVector.h.

References DecompVector< ParamType >::printErrors, DecompVector< ParamType >::size, and DecompVector< ParamType >::vec.

Referenced by DecompVector< ParamType >::getRawDataPtr(), and testSafety().

template<typename ParamType >
DecompVector< ParamType > & DecompVector< ParamType >::operator= ( const DecompVector< ParamType > &  dv)

Assignment Operator.

Parameters
dvThe DecompVector whose contents is to be copied into this one

Definition at line 131 of file DecompVector.h.

References DecompVector< ParamType >::printErrors, DecompVector< ParamType >::size, and DecompVector< ParamType >::vec.

Referenced by DecompVector< ParamType >::DecompVector().

template<typename ParamType>
void DecompVector< ParamType >::setElement ( int  index,
ParamType  value 
)
inline

Places a given value into a specific index in the vector.

Parameters
indexThe index into the vector
valueThe value to place at index
Remarks
if index is negative or greater than the length of the vector, behavior is undefined

Definition at line 64 of file DecompVector.h.

References DecompVector< ParamType >::vec.

Referenced by performDecomposition().


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