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

Templated class to store data of type double or CumulativeValue in multi-dimensional space. More...

Collaboration diagram for OutputData< T >:
[legend]

Public Types

typedef OutputDataIterator< const T, const OutputData< T > > const_iterator
 Read-only iterator type. More...
 
typedef OutputDataIterator< T, OutputData< T > > iterator
 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 ()
 memory allocation for current dimensions configuration More...
 
const IAxisaxis (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 > &x)
 
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...
 
PyObjectgetArray () 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...
 
OutputData< double > * meanValues () const
 
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 scaleAll (const T &factor)
 multiply every item of this output data by value 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...
 

Private Member Functions

bool axisNameExists (const std::string &axis_name) const
 checks if given axis name exists More...
 
size_t getAxisIndex (const std::string &axis_name) const
 returns serial number of axis with given name More...
 

Private Attributes

LLData< T > * m_ll_data
 
SafePointerVector< IAxism_value_axes
 

Friends

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

Detailed Description

template<class T>
class OutputData< T >

Templated class to store data of type double or CumulativeValue in multi-dimensional space.

Definition at line 32 of file OutputData.h.

Member Typedef Documentation

◆ const_iterator

template<class T >
typedef OutputDataIterator<const T, const OutputData<T> > OutputData< T >::const_iterator

Read-only iterator type.

Definition at line 84 of file OutputData.h.

◆ iterator

template<class T >
typedef OutputDataIterator<T, OutputData<T> > OutputData< T >::iterator

Read/write iterator type.

Definition at line 81 of file OutputData.h.

◆ value_type

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

Definition at line 34 of file OutputData.h.

Constructor & Destructor Documentation

◆ OutputData() [1/3]

template<class T >
OutputData< T >::OutputData

Definition at line 248 of file OutputData.h.

248  : m_value_axes(), m_ll_data(nullptr)
249 {
250  allocate();
251 }
void allocate()
memory allocation for current dimensions configuration
Definition: OutputData.h:542
LLData< T > * m_ll_data
Definition: OutputData.h:232
SafePointerVector< IAxis > m_value_axes
Definition: OutputData.h:231

References OutputData< T >::allocate().

Here is the call graph for this function:

◆ OutputData() [2/3]

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

◆ OutputData() [3/3]

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

Definition at line 239 of file OutputData.h.

240 {
241  m_value_axes = std::move(other.m_value_axes);
242  m_ll_data = other.m_ll_data;
243 
244  other.m_ll_data = nullptr;
245  other.allocate();
246 }

◆ ~OutputData()

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

Definition at line 253 of file OutputData.h.

254 {
255  clear();
256  delete m_ll_data;
257 }
void clear()
Sets object into initial state (no dimensions, data)
Definition: OutputData.h:470

Member Function Documentation

◆ addAxis() [1/2]

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

Definition at line 295 of file OutputData.h.

296 {
297  if (axisNameExists(new_axis.getName()))
298  throw std::runtime_error("OutputData<T>::addAxis(const IAxis& new_axis) -> "
299  "Error! Attempt to add axis with already existing name '"
300  + new_axis.getName() + "'");
301  if (new_axis.size() > 0) {
302  m_value_axes.push_back(new_axis.clone());
303  allocate();
304  }
305 }
virtual IAxis * clone() const =0
clone function
virtual size_t size() const =0
retrieve the number of bins
std::string getName() const
retrieve the label of the axis
Definition: IAxis.h:40
bool axisNameExists(const std::string &axis_name) const
checks if given axis name exists
Definition: OutputData.h:619
void push_back(T *pointer)

References IAxis::clone(), IAxis::getName(), and IAxis::size().

Referenced by Histogram1D::Histogram1D(), Histogram2D::Histogram2D(), IHistogram::IHistogram(), QREDataLoader::createOutputDataFromParsingResult(), Histogram2D::initFromShape(), DetectorMask::initMaskData(), OutputDataReadReflectometry::readOutputData(), OutputDataReadWriteINT::readOutputData(), SpecularSimulation::result(), OffSpecularSimulation::transferDetectorImage(), and OffSpecularSimulation::updateIntensityMap().

Here is the call graph for this function:

◆ addAxis() [2/2]

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

Definition at line 308 of file OutputData.h.

309 {
310  if (axisNameExists(name))
311  throw std::runtime_error("OutputData<T>::addAxis(std::string name) -> "
312  "Error! Attempt to add axis with already existing name '"
313  + name + "'");
314  FixedBinAxis new_axis(name, size, start, end);
315  addAxis(new_axis);
316 }
Axis with fixed bin size.
Definition: FixedBinAxis.h:23
iterator end()
Returns read/write iterator that points to the one past last element.
Definition: OutputData.h:93
void addAxis(const IAxis &new_axis)
Definition: OutputData.h:295
QString const & name(EShape k)
Definition: particles.cpp:21

References RealSpace::Particles::name().

Here is the call graph for this function:

◆ allocate()

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

memory allocation for current dimensions configuration

Definition at line 542 of file OutputData.h.

543 {
544  delete m_ll_data;
545  size_t rank = m_value_axes.size();
546  int* dims = new int[rank];
547  for (size_t i = 0; i < rank; ++i) {
548  dims[i] = (int)axis(i).size();
549  }
550  m_ll_data = new LLData<T>(rank, dims);
551  T default_value = {};
552  m_ll_data->setAll(default_value);
553  delete[] dims;
554 }
Template class to store data of any type in multi-dimensional space (low-level).
Definition: LLData.h:31
size_t rank() const
Returns number of dimensions.
Definition: OutputData.h:56
const IAxis & axis(size_t serial_number) const
returns axis with given serial number
Definition: OutputData.h:318
size_t size() const

Referenced by OutputData< T >::OutputData().

◆ axis()

◆ axisNameExists()

template<class T >
bool OutputData< T >::axisNameExists ( const std::string &  axis_name) const
private

checks if given axis name exists

Definition at line 619 of file OutputData.h.

620 {
621  for (size_t i = 0; i < m_value_axes.size(); ++i)
622  if (m_value_axes[i]->getName() == axis_name)
623  return true;
624  return false;
625 }

◆ begin() [1/2]

◆ begin() [2/2]

template<class T >
OutputData< T >::const_iterator OutputData< T >::begin

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

Definition at line 349 of file OutputData.h.

350 {
351  typename OutputData<T>::const_iterator result(this);
352  return result;
353 }

◆ clear()

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

Sets object into initial state (no dimensions, data)

Definition at line 470 of file OutputData.h.

471 {
473  allocate();
474 }

Referenced by DetectorMask::addMask(), DetectorMask::initMaskData(), and OffSpecularSimulation::updateIntensityMap().

◆ clone()

◆ copyFrom()

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

Definition at line 267 of file OutputData.h.

268 {
269  clear();
270  m_value_axes = other.m_value_axes;
271  delete m_ll_data;
272  m_ll_data = 0;
273  if (other.m_ll_data)
274  m_ll_data = new LLData<T>(*other.m_ll_data);
275 }

References OutputData< T >::m_ll_data, and OutputData< T >::m_value_axes.

Referenced by DetectorMask::DetectorMask(), IHistogram::IHistogram(), OffSpecularSimulation::OffSpecularSimulation(), and DetectorMask::operator=().

◆ copyShapeFrom()

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

Definition at line 277 of file OutputData.h.

278 {
279  clear();
280  size_t rank = other.rank();
281  for (size_t i = 0; i < rank; ++i)
282  addAxis(other.axis(i));
283 }

References OutputData< T >::axis(), and OutputData< T >::rank().

Referenced by DetectorMask::createHistogram(), IHistogram::createOutputData(), and IHistogram::init_from_data().

Here is the call graph for this function:

◆ end() [1/2]

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

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

Definition at line 93 of file OutputData.h.

93 { return iterator(this, getAllocatedSize()); }
OutputDataIterator< T, OutputData< T > > iterator
Read/write iterator type.
Definition: OutputData.h:81
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
Definition: OutputData.h:59

References OutputData< T >::getAllocatedSize().

Referenced by ConvolutionDetectorResolution::apply2dConvolution(), DataUtils::createClippedDataSet(), Histogram1D::crop(), Histogram2D::crop(), IntensityDataItem::dataRange(), SpecularDataItem::dataRange(), Data1DViewItem::dataRange(), DataFormatUtils::fillOutputData(), IHistogram::getMaximum(), IHistogram::getMaximumBinIndex(), IHistogram::getMinimum(), IHistogram::getMinimumBinIndex(), and OutputDataReadWriteINT::writeOutputDataDoubles().

Here is the call graph for this function:

◆ end() [2/2]

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

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

Definition at line 96 of file OutputData.h.

96 { return const_iterator(this, getAllocatedSize()); }
OutputDataIterator< const T, const OutputData< T > > const_iterator
Read-only iterator type.
Definition: OutputData.h:84

References OutputData< T >::getAllocatedSize().

Here is the call graph for this function:

◆ 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 416 of file OutputData.h.

417 {
418  ASSERT(m_ll_data);
419  if (coordinates.size() != m_ll_data->rank())
420  throw std::runtime_error("OutputData<T>::findClosestIndex() -> "
421  "Error! Number of coordinates must match rank of data structure");
422  std::vector<unsigned> axes_indexes;
423  axes_indexes.resize(m_ll_data->rank());
424  for (size_t i = 0; i < m_ll_data->rank(); ++i)
425  axes_indexes[i] = static_cast<unsigned>(m_value_axes[i]->findClosestIndex(coordinates[i]));
426  return toGlobalIndex(axes_indexes);
427 }
#define ASSERT(condition)
Definition: Assert.h:31
size_t toGlobalIndex(const std::vector< unsigned > &axes_indices) const
Returns global index for specified indices of axes.
Definition: OutputData.h:392

References ASSERT.

Referenced by Histogram2D::fill(), and IHistogram::findGlobalBin().

◆ getAllocatedSize()

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

◆ getAllSizes()

template<class T >
std::vector< size_t > OutputData< T >::getAllSizes
inline

Returns all sizes of its axes.

Definition at line 323 of file OutputData.h.

324 {
325  ASSERT(m_ll_data);
326  std::vector<size_t> result;
327  for (size_t i = 0; i < rank(); ++i) {
328  int dim = m_ll_data->dimensions()[i];
329  result.push_back(dim);
330  }
331  return result;
332 }

References ASSERT.

◆ 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

Definition at line 355 of file OutputData.h.

356 {
357  ASSERT(m_ll_data);
358  size_t remainder = global_index;
359  std::vector<int> result;
360  result.resize(m_ll_data->rank());
361  for (size_t i = 0; i < m_ll_data->rank(); ++i) {
362  result[m_ll_data->rank() - 1 - i] =
363  (int)(remainder % m_value_axes[m_ll_data->rank() - 1 - i]->size());
364  remainder /= m_value_axes[m_ll_data->rank() - 1 - i]->size();
365  }
366  return result;
367 }

References ASSERT.

Referenced by DataUtils::createRearrangedDataSet().

◆ 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 442 of file OutputData.h.

443 {
444  std::vector<int> indices = getAxesBinIndices(global_index);
445  std::vector<double> result;
446  for (size_t i_axis = 0; i_axis < indices.size(); ++i_axis)
447  result.push_back((*m_value_axes[i_axis])[indices[i_axis]]);
448  return result;
449 }
std::vector< int > getAxesBinIndices(size_t global_index) const
Returns vector of axes indices for given global index.
Definition: OutputData.h:355

◆ 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

Definition at line 459 of file OutputData.h.

460 {
461  return getAxisBin(global_index, getAxisIndex(axis_name));
462 }
Bin1D getAxisBin(size_t global_index, size_t i_selected_axis) const
Returns bin of selected axis for given global_index.
Definition: OutputData.h:452
size_t getAxisIndex(const std::string &axis_name) const
returns serial number of axis with given name
Definition: OutputData.h:609

◆ 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

Definition at line 452 of file OutputData.h.

453 {
454  auto axis_index = getAxisBinIndex(global_index, i_selected_axis);
455  return m_value_axes[i_selected_axis]->bin(axis_index);
456 }
size_t getAxisBinIndex(size_t global_index, size_t i_selected_axis) const
Returns axis bin index for given global index.
Definition: OutputData.h:370

Referenced by DetectorMask::process_masks().

◆ 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

Definition at line 386 of file OutputData.h.

387 {
388  return getAxisBinIndex(global_index, getAxisIndex(axis_name));
389 }

◆ 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

Definition at line 370 of file OutputData.h.

371 {
372  ASSERT(m_ll_data);
373  size_t remainder(global_index);
374  for (size_t i = 0; i < m_ll_data->rank(); ++i) {
375  size_t i_axis = m_ll_data->rank() - 1 - i;
376  size_t result = remainder % m_value_axes[i_axis]->size();
377  if (i_selected_axis == i_axis)
378  return result;
379  remainder /= m_value_axes[i_axis]->size();
380  }
381  throw std::runtime_error("OutputData<T>::getAxisBinIndex() -> "
382  "Error! No axis with given number");
383 }

References ASSERT.

Referenced by IHistogram::xAxisIndex(), and IHistogram::yAxisIndex().

◆ getAxisIndex()

template<class T >
size_t OutputData< T >::getAxisIndex ( const std::string &  axis_name) const
private

returns serial number of axis with given name

Definition at line 609 of file OutputData.h.

610 {
611  for (size_t i = 0; i < m_value_axes.size(); ++i)
612  if (m_value_axes[i]->getName() == axis_name)
613  return i;
614  throw std::runtime_error("OutputData<T>::getAxisIndex() -> "
615  "Error! Axis with given name not found '"
616  + axis_name + "'");
617 }

◆ 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

Definition at line 437 of file OutputData.h.

438 {
439  return getAxisValue(global_index, getAxisIndex(axis_name));
440 }
double getAxisValue(size_t global_index, size_t i_selected_axis) const
Returns the value of selected axis for given global_index.
Definition: OutputData.h:430

◆ 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

Definition at line 430 of file OutputData.h.

431 {
432  auto axis_index = getAxisBinIndex(global_index, i_selected_axis);
433  return (*m_value_axes[i_selected_axis])[axis_index];
434 }

Referenced by DataUtils::createClippedDataSet(), Histogram1D::crop(), Histogram2D::crop(), SpecularPlot::setDataFromItem(), IHistogram::xAxisValue(), and IHistogram::yAxisValue().

◆ getRawDataVector()

template<class T >
std::vector< T > OutputData< T >::getRawDataVector
inline

Returns copy of raw data vector.

Definition at line 334 of file OutputData.h.

335 {
336  ASSERT(m_ll_data);
337  std::vector<T> result;
338  for (size_t i = 0; i < getAllocatedSize(); ++i)
339  result.push_back((*m_ll_data)[i]);
340  return result;
341 }

References ASSERT.

Referenced by ConvolutionDetectorResolution::apply1dConvolution(), ConvolutionDetectorResolution::apply2dConvolution(), ISimulation::convertData(), IUnitConverter::createConvertedData(), UnitConverter1D::createConvertedData(), ImportDataUtils::CreateSimplifiedOutputData(), DataViewUtils::getTranslatedData(), and JobItemUtils::updateDataAxes().

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

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

Returns true if object have same dimensions.

Definition at line 575 of file OutputData.h.

576 {
577  if (!isInitialized())
578  return false;
579  if (!right.isInitialized())
580  return false;
581  if (rank() != right.rank())
582  return false;
583  for (size_t i_axis = 0; i_axis < rank(); ++i_axis)
584  if (axis(i_axis).size() != right.axis(i_axis).size())
585  return false;
586  return true;
587 }
bool isInitialized() const
returns true if object is correctly initialized
Definition: OutputData.h:524

References OutputData< T >::axis(), OutputData< T >::isInitialized(), OutputData< T >::rank(), and IAxis::size().

Referenced by DataUtils::createRelativeDifferenceData(), IHistogram::hasSameDimensions(), and DataUtils::relativeDataDifference().

Here is the call graph for this function:

◆ 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 592 of file OutputData.h.

593 {
594  if (!hasSameDimensions(right))
595  return false;
596 
597  for (size_t i = 0; i < m_value_axes.size(); ++i)
598  if (!HaveSameNameAndShape(axis(i), right.axis(i)))
599  return false;
600  return true;
601 }
bool HaveSameNameAndShape(const IAxis &left, const IAxis &right)
global helper function for comparison of axes
Definition: IAxis.h:100
bool hasSameDimensions(const OutputData< U > &right) const
Returns true if object have same dimensions and number of axes bins.
Definition: OutputData.h:575

References OutputData< T >::axis(), and HaveSameNameAndShape().

Referenced by IHistogram::hasSameShape().

Here is the call graph for this function:

◆ isInitialized()

template<class T >
bool OutputData< T >::isInitialized

returns true if object is correctly initialized

Definition at line 524 of file OutputData.h.

525 {
526  if (!m_ll_data)
527  return false;
528  if (rank() != m_ll_data->rank())
529  return false;
530  if (!rank())
531  return false;
532  return true;
533 }

Referenced by OutputData< T >::hasSameDimensions().

◆ meanValues()

template<class T >
OutputData< double > * OutputData< T >::meanValues

Definition at line 285 of file OutputData.h.

286 {
287  auto* ret = new OutputData<double>();
288  ret->copyShapeFrom(*this);
289  ret->allocate();
290  for (size_t i = 0; i < m_ll_data->getTotalSize(); ++i)
291  (*ret)[i] = getValue(i);
292  return ret;
293 }
double getValue(size_t index) const
Returns value or summed value, depending on T.

Referenced by HistoUtils::getRelativeDifference().

◆ operator*=()

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

multiplication-assignment operator for two output data

Definition at line 517 of file OutputData.h.

518 {
519  ASSERT(m_ll_data);
520  *this->m_ll_data *= *right.m_ll_data;
521  return *this;
522 }

References ASSERT, and OutputData< T >::m_ll_data.

◆ operator+=()

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

addition-assignment operator for two output data

Definition at line 503 of file OutputData.h.

504 {
505  ASSERT(m_ll_data);
506  *this->m_ll_data += *right.m_ll_data;
507  return *this;
508 }

References ASSERT, and OutputData< T >::m_ll_data.

◆ operator-=()

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

substraction-assignment operator for two output data

Definition at line 510 of file OutputData.h.

511 {
512  ASSERT(m_ll_data);
513  *this->m_ll_data -= *right.m_ll_data;
514  return *this;
515 }

References ASSERT, and OutputData< T >::m_ll_data.

◆ operator/=()

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

division-assignment operator for two output data

Definition at line 535 of file OutputData.h.

536 {
537  ASSERT(m_ll_data);
538  *this->m_ll_data /= *right.m_ll_data;
539  return *this;
540 }

References ASSERT, and OutputData< T >::m_ll_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)
inline

indexed accessor

Definition at line 192 of file OutputData.h.

193  {
194  ASSERT(m_ll_data);
195  return (*m_ll_data)[index];
196  }

References ASSERT, and OutputData< T >::m_ll_data.

◆ operator[]() [2/2]

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

indexed accessor (const)

Definition at line 199 of file OutputData.h.

200  {
201  ASSERT(m_ll_data);
202  return (*m_ll_data)[index];
203  }

References ASSERT, and OutputData< T >::m_ll_data.

◆ rank()

◆ scaleAll()

template<class T >
void OutputData< T >::scaleAll ( const T &  factor)

multiply every item of this output data by value

Definition at line 484 of file OutputData.h.

485 {
486  if (!m_ll_data)
487  throw std::runtime_error(
488  "OutputData::scaleAll() -> Error! Low-level data object was not yet initialized.");
489  m_ll_data->scaleAll(factor);
490 }

◆ setAllTo()

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

Sets content of output data to specific value.

Definition at line 476 of file OutputData.h.

477 {
478  if (!m_ll_data)
479  throw std::runtime_error(
480  "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized.");
481  m_ll_data->setAll(value);
482 }

Referenced by DetectorMaskDelegate::createIntensityDataItem(), DataFormatUtils::fillOutputData(), DetectorMask::process_masks(), IHistogram::reset(), SpecularSimulation::result(), and OffSpecularSimulation::updateIntensityMap().

◆ setAxisSizes()

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

Adds 'rank' axes with indicated sizes.

Definition at line 492 of file OutputData.h.

493 {
494  clear();
495  std::string basename("axis");
496  for (size_t i = 0; i < rank; ++i) {
497  std::ostringstream name;
498  name << basename << i;
499  addAxis(name.str(), n_dims[i], 0.0, (double)(n_dims[i] - 1));
500  }
501 }

References RealSpace::Particles::name().

Here is the call graph for this function:

◆ setRawDataArray()

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

Sets new values to raw data array.

Definition at line 566 of file OutputData.h.

567 {
568  for (size_t i = 0; i < getAllocatedSize(); ++i)
569  (*m_ll_data)[i] = source[i];
570 }

◆ setRawDataVector()

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

Sets new values to raw data vector.

Definition at line 556 of file OutputData.h.

557 {
558  if (data_vector.size() != getAllocatedSize())
559  throw std::runtime_error(
560  "OutputData<T>::setRawDataVector() -> Error! "
561  "setRawDataVector can only be called with a data vector of the correct size.");
562  for (size_t i = 0; i < getAllocatedSize(); ++i)
563  (*m_ll_data)[i] = data_vector[i];
564 }

Referenced by ConvolutionDetectorResolution::apply1dConvolution(), IDetector::applyDetectorResolution(), QREDataLoader::createOutputDataFromParsingResult(), OutputDataReadReflectometry::readOutputData(), and SpecularSimulation::result().

◆ 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 392 of file OutputData.h.

393 {
394  ASSERT(m_ll_data);
395  if (axes_indices.size() != m_ll_data->rank())
396  throw std::runtime_error("size_t OutputData<T>::toGlobalIndex() -> "
397  "Error! Number of coordinates must match rank of data structure");
398  size_t result = 0;
399  size_t step_size = 1;
400  for (size_t i = m_ll_data->rank(); i > 0; --i) {
401  if (axes_indices[i - 1] >= m_value_axes[i - 1]->size()) {
402  std::ostringstream message;
403  message << "size_t OutputData<T>::toGlobalIndex() -> Error. Index ";
404  message << axes_indices[i - 1] << " is out of range. Axis ";
405  message << m_value_axes[i - 1]->getName();
406  message << " size " << m_value_axes[i - 1]->size() << ".\n";
407  throw std::runtime_error(message.str());
408  }
409  result += axes_indices[i - 1] * step_size;
410  step_size *= m_value_axes[i - 1]->size();
411  }
412  return result;
413 }

References ASSERT.

Referenced by IHistogram::getGlobalBin().

◆ totalSum()

template<class T >
T OutputData< T >::totalSum
inline

Returns sum of all values in the data structure.

Definition at line 464 of file OutputData.h.

465 {
466  ASSERT(m_ll_data);
467  return m_ll_data->getTotalSum();
468 }

References ASSERT.

Friends And Related Function Documentation

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

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

Definition at line 73 of file OutputData.h.

◆ OutputDataIterator< T, OutputData< T > >

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

Definition at line 73 of file OutputData.h.

Member Data Documentation

◆ m_ll_data

◆ m_value_axes

template<class T >
SafePointerVector<IAxis> OutputData< T >::m_value_axes
private

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