BornAgain  1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OutputData< T > Class Template Reference

Template class to store data of any type in multi-dimensional space. More...

Public Types

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

Public Member Functions

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

Friends

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

Detailed Description

template<class T>
class OutputData< T >

Template class to store data of any type in multi-dimensional space.

Definition at line 32 of file OutputData.h.

Member Function Documentation

◆ 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

Definition at line 356 of file OutputData.h.

◆ getAxisBinIndex() [1/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

Definition at line 371 of file OutputData.h.

◆ getAxisBinIndex() [2/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

Definition at line 387 of file OutputData.h.

◆ 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

Definition at line 393 of file OutputData.h.

◆ 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

Definition at line 418 of file OutputData.h.

◆ getAxisValue() [1/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

Definition at line 433 of file OutputData.h.

◆ getAxisValue() [2/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

Definition at line 440 of file OutputData.h.

◆ 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

Definition at line 445 of file OutputData.h.

◆ getAxisBin() [1/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

Definition at line 455 of file OutputData.h.

◆ getAxisBin() [2/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

Definition at line 462 of file OutputData.h.

◆ hasSameDimensions()

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

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

Returns true if object have same dimensions.

Definition at line 578 of file OutputData.h.

◆ 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.

Returns true if object have same dimensions and shape of axis.

Definition at line 595 of file OutputData.h.


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