BornAgain  1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
OutputData< T > Class Template Reference

Description

template<class T>
class OutputData< T >

Templated class to store data in multi-dimensional space. Used with type T = double, CumulativeValue, bool.

Public Types

using const_iterator = OutputDataIterator< const T, const OutputData< T > >
 Read-only iterator type. More...
 
using iterator = OutputDataIterator< T, OutputData< T > >
 Read/write iterator type. More...
 
using value_type = T
 

Public Member Functions

 OutputData ()
 
 OutputData (const OutputData &)=delete
 
 OutputData (OutputData &&)
 
 ~OutputData ()
 
void addAxis (const IAxis &new_axis)
 
void addAxis (const std::string &name, size_t size, double start, double end)
 
void allocate ()
 Allocates memory for current dimensions configuration. More...
 
const IAxis & axis (size_t serial_number) const
 Returns axis with given serial number. More...
 
iterator begin ()
 Returns read/write iterator that points to the first element. More...
 
const_iterator begin () const
 Returns read-only iterator that points to the first element. More...
 
void clear ()
 Sets object into initial state (no dimensions, data) More...
 
OutputDataclone () const
 
void copyFrom (const OutputData< T > &other)
 
template<class U >
void copyShapeFrom (const OutputData< U > &other)
 
iterator end ()
 Returns read/write iterator that points to the one past last element. More...
 
const_iterator end () const
 Returns read-only iterator that points to the one past last element. More...
 
size_t findGlobalIndex (const std::vector< double > &coordinates) const
 Returns global index for specified axes values. More...
 
size_t getAllocatedSize () const
 Returns total size of data buffer (product of bin number in every dimension). More...
 
std::vector< size_t > getAllSizes () const
 Returns all sizes of its axes. More...
 
PyObject * getArray () const
 Returns data as Python numpy array. More...
 
std::vector< int > getAxesBinIndices (size_t global_index) const
 Returns vector of axes indices for given global index. More...
 
std::vector< double > getAxesValues (size_t global_index) const
 Returns values on all defined axes for given globalbin number. More...
 
Bin1D getAxisBin (size_t global_index, const std::string &axis_name) const
 Returns bin of selected axis for given global_index. More...
 
Bin1D getAxisBin (size_t global_index, size_t i_selected_axis) const
 Returns bin of selected axis for given global_index. More...
 
size_t getAxisBinIndex (size_t global_index, const std::string &axis_name) const
 Returns axis bin index for given global index. More...
 
size_t getAxisBinIndex (size_t global_index, size_t i_selected_axis) const
 Returns axis bin index for given global index. More...
 
double getAxisValue (size_t global_index, const std::string &axis_name) const
 Returns the value of selected axis for given global_index. More...
 
double getAxisValue (size_t global_index, size_t i_selected_axis) const
 Returns the value of selected axis for given global_index. More...
 
std::vector< T > getRawDataVector () const
 Returns copy of raw data vector. More...
 
double getValue (size_t index) const
 Returns value or summed value, depending on T. More...
 
template<class U >
bool hasSameDimensions (const OutputData< U > &right) const
 Returns true if object have same dimensions and number of axes bins. More...
 
template<class U >
bool hasSameShape (const OutputData< U > &right) const
 Returns true if objects a) have same dimensions b) bin boundaries of axes coincide. More...
 
bool isInitialized () const
 Returns true if object is correctly initialized. More...
 
max () const
 Returns maximum value in the data structure. More...
 
OutputData< double > * meanValues () const
 
const OutputData< double > & normalizedToMaximum ()
 
const OutputData< T > & operator*= (const OutputData< T > &right)
 multiplication-assignment operator for two output data More...
 
const OutputData< T > & operator+= (const OutputData< T > &right)
 addition-assignment operator for two output data More...
 
const OutputData< T > & operator-= (const OutputData< T > &right)
 substraction-assignment operator for two output data More...
 
const OutputData< T > & operator/= (const OutputData< T > &right)
 division-assignment operator for two output data More...
 
const OutputDataoperator= (const OutputData &)=delete
 
T & operator[] (size_t index)
 indexed accessor More...
 
const T & operator[] (size_t index) const
 indexed accessor (const) More...
 
size_t rank () const
 Returns number of dimensions. More...
 
void setAllTo (const T &value)
 Sets content of output data to specific value. More...
 
void setAxisSizes (size_t rank, int *n_dims)
 Adds 'rank' axes with indicated sizes. More...
 
void setRawDataArray (const T *source)
 Sets new values to raw data array. More...
 
void setRawDataVector (const std::vector< T > &data_vector)
 Sets new values to raw data vector. More...
 
size_t toGlobalIndex (const std::vector< unsigned > &axes_indices) const
 Returns global index for specified indices of axes. More...
 
totalSum () const
 Returns sum of all values in the data structure. More...
 

Friends

class OutputDataIterator< const T, const OutputData< T > >
 
class OutputDataIterator< T, OutputData< T > >
 

Member Typedef Documentation

◆ const_iterator

template<class T >
using OutputData< T >::const_iterator = OutputDataIterator<const T, const OutputData<T> >

Read-only iterator type.

◆ iterator

template<class T >
using OutputData< T >::iterator = OutputDataIterator<T, OutputData<T> >

Read/write iterator type.

◆ value_type

template<class T >
using OutputData< T >::value_type = T

Constructor & Destructor Documentation

◆ OutputData() [1/3]

template<class T >
OutputData< T >::OutputData ( )

◆ OutputData() [2/3]

template<class T >
OutputData< T >::OutputData ( const OutputData< T > &  )
delete

◆ OutputData() [3/3]

template<class T >
OutputData< T >::OutputData ( OutputData< T > &&  )

◆ ~OutputData()

template<class T >
OutputData< T >::~OutputData ( )

Member Function Documentation

◆ addAxis() [1/2]

template<class T >
void OutputData< T >::addAxis ( const IAxis &  new_axis)

◆ addAxis() [2/2]

template<class T >
void OutputData< T >::addAxis ( const std::string &  name,
size_t  size,
double  start,
double  end 
)

◆ allocate()

template<class T >
void OutputData< T >::allocate ( )

Allocates memory for current dimensions configuration.

◆ axis()

template<class T >
const IAxis& OutputData< T >::axis ( size_t  serial_number) const

Returns axis with given serial number.

◆ begin() [1/2]

template<class T >
iterator OutputData< T >::begin ( )

Returns read/write iterator that points to the first element.

◆ begin() [2/2]

template<class T >
const_iterator OutputData< T >::begin ( ) const

Returns read-only iterator that points to the first element.

◆ clear()

template<class T >
void OutputData< T >::clear ( )

Sets object into initial state (no dimensions, data)

◆ clone()

template<class T >
OutputData* OutputData< T >::clone ( ) const

◆ copyFrom()

template<class T >
void OutputData< T >::copyFrom ( const OutputData< T > &  other)

◆ copyShapeFrom()

template<class T >
template<class U >
void OutputData< T >::copyShapeFrom ( const OutputData< U > &  other)

◆ end() [1/2]

template<class T >
iterator OutputData< T >::end ( )

Returns read/write iterator that points to the one past last element.

◆ end() [2/2]

template<class T >
const_iterator OutputData< T >::end ( ) const

Returns read-only iterator that points to the one past last element.

◆ findGlobalIndex()

template<class T >
size_t OutputData< T >::findGlobalIndex ( const std::vector< double > &  coordinates) const

Returns global index for specified axes values.

Parameters
coordinatesVector of axes coordinates for all specified axes in this dataset
Returns
Closest global index

◆ getAllocatedSize()

template<class T >
size_t OutputData< T >::getAllocatedSize ( ) const

Returns total size of data buffer (product of bin number in every dimension).

◆ getAllSizes()

template<class T >
std::vector<size_t> OutputData< T >::getAllSizes ( ) const

Returns all sizes of its axes.

◆ getArray()

template<class T >
PyObject* OutputData< T >::getArray ( ) const

Returns data as Python numpy array.

◆ getAxesBinIndices()

template<class T >
std::vector<int> OutputData< T >::getAxesBinIndices ( size_t  global_index) const

Returns vector of axes indices for given global index.

Parameters
global_indexThe global index of this data structure.
Returns
Vector of bin indices for all axes defined

◆ getAxesValues()

template<class T >
std::vector<double> OutputData< T >::getAxesValues ( size_t  global_index) const

Returns values on all defined axes for given globalbin number.

Parameters
global_indexThe global index of this data structure.
Returns
Vector of corresponding bin centers

◆ getAxisBin() [1/2]

template<class T >
Bin1D OutputData< T >::getAxisBin ( size_t  global_index,
const std::string &  axis_name 
) const

Returns bin of selected axis for given global_index.

Parameters
global_indexThe global index of this data structure.
axis_nameThe name of selected axis.
Returns
Corresponding Bin1D object

◆ getAxisBin() [2/2]

template<class T >
Bin1D OutputData< T >::getAxisBin ( size_t  global_index,
size_t  i_selected_axis 
) const

Returns bin of selected axis for given global_index.

Parameters
global_indexThe global index of this data structure.
i_selected_axisSerial number of selected axis.
Returns
Corresponding Bin1D object

◆ getAxisBinIndex() [1/2]

template<class T >
size_t OutputData< T >::getAxisBinIndex ( size_t  global_index,
const std::string &  axis_name 
) const

Returns axis bin index for given global index.

Parameters
global_indexThe global index of this data structure.
axis_nameThe name of selected axis.
Returns
Corresponding bin index for selected axis

◆ getAxisBinIndex() [2/2]

template<class T >
size_t OutputData< T >::getAxisBinIndex ( size_t  global_index,
size_t  i_selected_axis 
) const

Returns axis bin index for given global index.

Parameters
global_indexThe global index of this data structure.
i_selected_axisSerial number of selected axis.
Returns
Corresponding bin index for selected axis

◆ getAxisValue() [1/2]

template<class T >
double OutputData< T >::getAxisValue ( size_t  global_index,
const std::string &  axis_name 
) const

Returns the value of selected axis for given global_index.

Parameters
global_indexThe global index of this data structure.
axis_nameThe name of selected axis.
Returns
corresponding bin center of selected axis

◆ getAxisValue() [2/2]

template<class T >
double OutputData< T >::getAxisValue ( size_t  global_index,
size_t  i_selected_axis 
) const

Returns the value of selected axis for given global_index.

Parameters
global_indexThe global index of this data structure.
i_selected_axisSerial number of selected axis.
Returns
corresponding bin center of selected axis

◆ getRawDataVector()

template<class T >
std::vector<T> OutputData< T >::getRawDataVector ( ) const

Returns copy of raw data vector.

◆ getValue()

template<class T >
double OutputData< T >::getValue ( size_t  index) const

Returns value or summed value, depending on T.

◆ hasSameDimensions()

template<class T >
template<class U >
bool OutputData< T >::hasSameDimensions ( const OutputData< U > &  right) const

Returns true if object have same dimensions and number of axes bins.

◆ hasSameShape()

template<class T >
template<class U >
bool OutputData< T >::hasSameShape ( const OutputData< U > &  right) const

Returns true if objects a) have same dimensions b) bin boundaries of axes coincide.

◆ isInitialized()

template<class T >
bool OutputData< T >::isInitialized ( ) const

Returns true if object is correctly initialized.

◆ max()

template<class T >
T OutputData< T >::max ( ) const

Returns maximum value in the data structure.

◆ meanValues()

template<class T >
OutputData<double>* OutputData< T >::meanValues ( ) const

◆ normalizedToMaximum()

template<class T >
const OutputData<double>& OutputData< T >::normalizedToMaximum ( )

◆ operator*=()

template<class T >
const OutputData<T>& OutputData< T >::operator*= ( const OutputData< T > &  right)

multiplication-assignment operator for two output data

◆ operator+=()

template<class T >
const OutputData<T>& OutputData< T >::operator+= ( const OutputData< T > &  right)

addition-assignment operator for two output data

◆ operator-=()

template<class T >
const OutputData<T>& OutputData< T >::operator-= ( const OutputData< T > &  right)

substraction-assignment operator for two output data

◆ operator/=()

template<class T >
const OutputData<T>& OutputData< T >::operator/= ( const OutputData< T > &  right)

division-assignment operator for two output data

◆ operator=()

template<class T >
const OutputData& OutputData< T >::operator= ( const OutputData< T > &  )
delete

◆ operator[]() [1/2]

template<class T >
T& OutputData< T >::operator[] ( size_t  index)

indexed accessor

◆ operator[]() [2/2]

template<class T >
const T& OutputData< T >::operator[] ( size_t  index) const

indexed accessor (const)

◆ rank()

template<class T >
size_t OutputData< T >::rank ( ) const

Returns number of dimensions.

◆ setAllTo()

template<class T >
void OutputData< T >::setAllTo ( const T &  value)

Sets content of output data to specific value.

◆ setAxisSizes()

template<class T >
void OutputData< T >::setAxisSizes ( size_t  rank,
int *  n_dims 
)

Adds 'rank' axes with indicated sizes.

◆ setRawDataArray()

template<class T >
void OutputData< T >::setRawDataArray ( const T *  source)

Sets new values to raw data array.

◆ setRawDataVector()

template<class T >
void OutputData< T >::setRawDataVector ( const std::vector< T > &  data_vector)

Sets new values to raw data vector.

◆ toGlobalIndex()

template<class T >
size_t OutputData< T >::toGlobalIndex ( const std::vector< unsigned > &  axes_indices) const

Returns global index for specified indices of axes.

Parameters
axes_indicesVector of axes indices for all specified axes in this dataset
Returns
Corresponding global index

◆ totalSum()

template<class T >
T OutputData< T >::totalSum ( ) const

Returns sum of all values in the data structure.

Friends And Related Function Documentation

◆ OutputDataIterator< const T, const OutputData< T > >

template<class T >
friend class OutputDataIterator< const T, const OutputData< T > >
friend

◆ OutputDataIterator< T, OutputData< T > >

template<class T >
friend class OutputDataIterator< T, OutputData< T > >
friend