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

A representation of the vector of data that is the object of the decomposition. More...

#include <DataVector.h>

Public Member Functions

 DataVector (int length, bool printBadSafety=true)
 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...
 
bool isSafe ()
 Checks if the data vector is safe for usage in the decomposition. 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.
 
ParamType * vec
 The data vector itself.
 

Detailed Description

template<typename ParamType>
class DataVector< ParamType >

A representation of the vector of data that is the object of the decomposition.

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

Definition at line 29 of file DataVector.h.

Constructor & Destructor Documentation

template<typename ParamType>
DataVector< ParamType >::DataVector ( 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 37 of file DataVector.h.

References DataVector< ParamType >::vec.

Member Function Documentation

template<typename ParamType>
ParamType DataVector< 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 58 of file DataVector.h.

References DataVector< ParamType >::vec.

Referenced by DecompVector< ParamType >::initWithDataVector(), and performDecomposition().

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

Gets the size of the vector.

Returns
The number of cells in the vector

Definition at line 64 of file DataVector.h.

References DataVector< ParamType >::size.

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

template<typename ParamType>
ParamType* DataVector< 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 72 of file DataVector.h.

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

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

Checks if the data vector 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 or equal to zero and that the sum of all the elements is greater than zero (i.e. the vector is not a zero vector)

Definition at line 91 of file DataVector.h.

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

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

template<typename ParamType>
void DataVector< 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 49 of file DataVector.h.

References DataVector< ParamType >::vec.


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