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

Public Types

using value_type = T
 
typedef OutputDataIterator< T, OutputData< T > > iterator
 
typedef OutputDataIterator< const T, const OutputData< T > > const_iterator
 

Public Member Functions

 OutputData ()
 
 OutputData (const OutputData &)=delete
 
const OutputDataoperator= (const OutputData &)=delete
 
 ~OutputData ()
 
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
 
const IAxisgetAxis (const std::string &axis_name) const
 
size_t getRank () const
 
size_t getAllocatedSize () const
 
std::vector< size_t > getAllSizes () const
 
std::vector< T > getRawDataVector () const
 
totalSum () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
std::vector< int > getAxesBinIndices (size_t global_index) const
 
size_t getAxisBinIndex (size_t global_index, size_t i_selected_axis) const
 
size_t getAxisBinIndex (size_t global_index, const std::string &axis_name) const
 
size_t toGlobalIndex (const std::vector< unsigned > &axes_indices) const
 
size_t findGlobalIndex (const std::vector< double > &coordinates) const
 
double getAxisValue (size_t global_index, size_t i_selected_axis) const
 
double getAxisValue (size_t global_index, const std::string &axis_name) const
 
std::vector< double > getAxesValues (size_t global_index) const
 
Bin1D getAxisBin (size_t global_index, size_t i_selected_axis) const
 
Bin1D getAxisBin (size_t global_index, const std::string &axis_name) const
 
void clear ()
 
void setAllTo (const T &value)
 
void scaleAll (const T &factor)
 
void setAxisSizes (size_t rank, int *n_dims)
 
void setRawDataVector (const std::vector< T > &data_vector)
 
void setRawDataArray (const T *source)
 
const OutputData< T > & operator+= (const OutputData< T > &right)
 
const OutputData< T > & operator-= (const OutputData< T > &right)
 
const OutputData< T > & operator/= (const OutputData< T > &right)
 
const OutputData< T > & operator*= (const OutputData< T > &right)
 
double getValue (size_t index) const
 
T & operator[] (size_t index)
 
const T & operator[] (size_t index) const
 
template<class U >
bool hasSameDimensions (const OutputData< U > &right) const
 
template<class U >
bool hasSameShape (const OutputData< U > &right) const
 
PyObjectgetArray () const
 
bool isInitialized () const
 
void allocate ()
 

Private Member Functions

size_t getAxisIndex (const std::string &axis_name) const
 
bool axisNameExists (const std::string &axis_name) const
 

Private Attributes

SafePointerVector< IAxism_value_axes
 
LLData< T > * mp_ll_data
 

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 Typedef Documentation

◆ value_type

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

Definition at line 35 of file OutputData.h.

◆ iterator

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

Read/write iterator type.

Definition at line 84 of file OutputData.h.

◆ const_iterator

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

Read-only iterator type.

Definition at line 87 of file OutputData.h.

Constructor & Destructor Documentation

◆ OutputData() [1/2]

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

Definition at line 242 of file OutputData.h.

242  : m_value_axes(), mp_ll_data(nullptr)
243 {
244  allocate();
245 }
void allocate()
memory allocation for current dimensions configuration
Definition: OutputData.h:545
LLData< T > * mp_ll_data
Definition: OutputData.h:235
SafePointerVector< IAxis > m_value_axes
Definition: OutputData.h:234

References OutputData< T >::allocate().

Here is the call graph for this function:

◆ OutputData() [2/2]

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

◆ ~OutputData()

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

Definition at line 247 of file OutputData.h.

248 {
249  clear();
250  delete mp_ll_data;
251 }
void clear()
Sets object into initial state (no dimensions, data)
Definition: OutputData.h:473

Member Function Documentation

◆ operator=()

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

◆ clone()

template<class T >
OutputData< T > * OutputData< T >::clone

Definition at line 253 of file OutputData.h.

254 {
255  OutputData<T>* ret = new OutputData<T>();
256  ret->m_value_axes = m_value_axes;
257  (*ret->mp_ll_data) = *mp_ll_data;
258  return ret;
259 }
Template class to store data of any type in multi-dimensional space.
Definition: OutputData.h:33

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

Referenced by IntensityDataFunctions::createRearrangedDataSet(), IntensityDataFunctions::createRelativeDifferenceData(), and OffSpecSimulation::result().

◆ copyFrom()

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

Definition at line 261 of file OutputData.h.

262 {
263  clear();
264  m_value_axes = other.m_value_axes;
265  delete mp_ll_data;
266  mp_ll_data = 0;
267  if (other.mp_ll_data)
268  mp_ll_data = new LLData<T>(*other.mp_ll_data);
269 }
Template class to store data of any type in multi-dimensional space (low-level).
Definition: LLData.h:28

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

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

◆ copyShapeFrom()

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

Definition at line 271 of file OutputData.h.

272 {
273  clear();
274  size_t rank = other.getRank();
275  for (size_t i = 0; i < rank; ++i)
276  addAxis(other.getAxis(i));
277 }
size_t getRank() const
Returns number of dimensions.
Definition: OutputData.h:59
void addAxis(const IAxis &new_axis)
Definition: OutputData.h:289
const IAxis & getAxis(size_t serial_number) const
returns axis with given serial number
Definition: OutputData.h:314

References OutputData< T >::getAxis(), and OutputData< T >::getRank().

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

Here is the call graph for this function:

◆ meanValues()

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

Definition at line 279 of file OutputData.h.

280 {
281  auto* ret = new OutputData<double>();
282  ret->copyShapeFrom(*this);
283  ret->allocate();
284  for (size_t i = 0; i < mp_ll_data->getTotalSize(); ++i)
285  (*ret)[i] = getValue(i);
286  return ret;
287 }
double getValue(size_t index) const
Returns value or summed value, depending on T.

Referenced by IntensityDataFunctions::getRelativeDifference().

◆ addAxis() [1/2]

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

Definition at line 289 of file OutputData.h.

290 {
291  if (axisNameExists(new_axis.getName()))
293  "OutputData<T>::addAxis(const IAxis& new_axis) -> "
294  "Error! Attempt to add axis with already existing name '"
295  + new_axis.getName() + "'");
296  if (new_axis.size() > 0) {
297  m_value_axes.push_back(new_axis.clone());
298  allocate();
299  }
300 }
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:622
void push_back(T *pointer)

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

Referenced by Histogram1D::Histogram1D(), Histogram2D::Histogram2D(), IHistogram::IHistogram(), Histogram2D::initFromShape(), DetectorMask::initMaskData(), OutputDataReadINTStrategy::readOutputData(), OutputDataReadReflectometryStrategy::readOutputData(), SpecularSimulation::result(), OffSpecSimulation::transferDetectorImage(), and OffSpecSimulation::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 303 of file OutputData.h.

304 {
305  if (axisNameExists(name))
307  "OutputData<T>::addAxis(std::string name) -> "
308  "Error! Attempt to add axis with already existing name '"
309  + name + "'");
310  FixedBinAxis new_axis(name, size, start, end);
311  addAxis(new_axis);
312 }
Axis with fixed bin size.
Definition: FixedBinAxis.h:24
iterator end()
Returns read/write iterator that points to the one past last element.
Definition: OutputData.h:96

◆ getAxis() [1/2]

◆ getAxis() [2/2]

template<class T >
const IAxis & OutputData< T >::getAxis ( const std::string &  axis_name) const

returns axis with given name

Definition at line 319 of file OutputData.h.

320 {
321  return getAxis(getAxisIndex(axis_name));
322 }
size_t getAxisIndex(const std::string &axis_name) const
returns serial number of axis with given name
Definition: OutputData.h:612

◆ getRank()

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

325 {
327  std::vector<size_t> result;
328  for (size_t i = 0; i < getRank(); ++i) {
329  int dim = mp_ll_data->getDimensions()[i];
330  result.push_back(dim);
331  }
332  return result;
333 }
#define ASSERT(condition)
Definition: Assert.h:26

References ASSERT.

◆ getRawDataVector()

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

Returns copy of raw data vector.

Definition at line 335 of file OutputData.h.

336 {
338  std::vector<T> result;
339  for (size_t i = 0; i < getAllocatedSize(); ++i)
340  result.push_back((*mp_ll_data)[i]);
341  return result;
342 }
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
Definition: OutputData.h:62

References ASSERT.

Referenced by ConvolutionDetectorResolution::apply1dConvolution(), ConvolutionDetectorResolution::apply2dConvolution(), Simulation::convertData(), IUnitConverter::createConvertedData(), and UnitConverter1D::createConvertedData().

◆ totalSum()

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

Returns sum of all values in the data structure.

Definition at line 467 of file OutputData.h.

468 {
470  return mp_ll_data->getTotalSum();
471 }

References ASSERT.

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

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

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

96 { return iterator(this, getAllocatedSize()); }
OutputDataIterator< T, OutputData< T > > iterator
Read/write iterator type.
Definition: OutputData.h:84

References OutputData< T >::getAllocatedSize().

Referenced by ConvolutionDetectorResolution::apply2dConvolution(), IntensityDataFunctions::createClippedDataSet(), Histogram1D::crop(), Histogram2D::crop(), DataFormatUtils::fillOutputData(), IHistogram::getMaximum(), IHistogram::getMaximumBinIndex(), IHistogram::getMinimum(), IHistogram::getMinimumBinIndex(), and anonymous_namespace{OutputDataWriteStrategy.cpp}::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 99 of file OutputData.h.

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

References OutputData< T >::getAllocatedSize().

Here is the call graph for this function:

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

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

References ASSERT.

Referenced by IntensityDataFunctions::createRearrangedDataSet().

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

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

References ASSERT.

Referenced by IHistogram::getXaxisIndex(), and IHistogram::getYaxisIndex().

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

388 {
389  return getAxisBinIndex(global_index, getAxisIndex(axis_name));
390 }
size_t getAxisBinIndex(size_t global_index, size_t i_selected_axis) const
Returns axis bin index for given global index.
Definition: OutputData.h:371

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

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

References ASSERT.

Referenced by IHistogram::getGlobalBin().

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

419 {
421  if (coordinates.size() != mp_ll_data->getRank())
423  "OutputData<T>::findClosestIndex() -> "
424  "Error! Number of coordinates must match rank of data structure");
425  std::vector<unsigned> axes_indexes;
426  axes_indexes.resize(mp_ll_data->getRank());
427  for (size_t i = 0; i < mp_ll_data->getRank(); ++i)
428  axes_indexes[i] = static_cast<unsigned>(m_value_axes[i]->findClosestIndex(coordinates[i]));
429  return toGlobalIndex(axes_indexes);
430 }
size_t toGlobalIndex(const std::vector< unsigned > &axes_indices) const
Returns global index for specified indices of axes.
Definition: OutputData.h:393

References ASSERT.

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

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

434 {
435  auto axis_index = getAxisBinIndex(global_index, i_selected_axis);
436  return (*m_value_axes[i_selected_axis])[axis_index];
437 }

Referenced by IntensityDataFunctions::createClippedDataSet(), Histogram1D::crop(), Histogram2D::crop(), IHistogram::getXaxisValue(), and IHistogram::getYaxisValue().

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

441 {
442  return getAxisValue(global_index, getAxisIndex(axis_name));
443 }
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:433

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

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

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

456 {
457  auto axis_index = getAxisBinIndex(global_index, i_selected_axis);
458  return m_value_axes[i_selected_axis]->getBin(axis_index);
459 }

Referenced by DetectorMask::process_masks().

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

463 {
464  return getAxisBin(global_index, getAxisIndex(axis_name));
465 }
Bin1D getAxisBin(size_t global_index, size_t i_selected_axis) const
Returns bin of selected axis for given global_index.
Definition: OutputData.h:455

◆ clear()

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

Sets object into initial state (no dimensions, data)

Definition at line 473 of file OutputData.h.

474 {
476  allocate();
477 }

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

◆ setAllTo()

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

Sets content of output data to specific value.

Definition at line 479 of file OutputData.h.

480 {
481  if (!mp_ll_data)
483  "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized.");
484  mp_ll_data->setAll(value);
485 }

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

◆ scaleAll()

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

multiply every item of this output data by value

Definition at line 487 of file OutputData.h.

488 {
489  if (!mp_ll_data)
491  "OutputData::scaleAll() -> Error! Low-level data object was not yet initialized.");
492  mp_ll_data->scaleAll(factor);
493 }

◆ setAxisSizes()

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

Adds 'rank' axes with indicated sizes.

Definition at line 495 of file OutputData.h.

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

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

560 {
561  if (data_vector.size() != getAllocatedSize())
563  "OutputData<T>::setRawDataVector() -> Error! "
564  "setRawDataVector can only be called with a data vector of the correct size.");
565  for (size_t i = 0; i < getAllocatedSize(); ++i)
566  (*mp_ll_data)[i] = data_vector[i];
567 }

Referenced by ConvolutionDetectorResolution::apply1dConvolution(), IDetector::applyDetectorResolution(), OutputDataReadReflectometryStrategy::readOutputData(), and SpecularSimulation::result().

◆ setRawDataArray()

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

Sets new values to raw data array.

Definition at line 569 of file OutputData.h.

570 {
571  for (size_t i = 0; i < getAllocatedSize(); ++i)
572  (*mp_ll_data)[i] = source[i];
573 }

◆ operator+=()

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

addition-assignment operator for two output data

Definition at line 506 of file OutputData.h.

507 {
509  *this->mp_ll_data += *right.mp_ll_data;
510  return *this;
511 }

References ASSERT, and OutputData< T >::mp_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 513 of file OutputData.h.

514 {
516  *this->mp_ll_data -= *right.mp_ll_data;
517  return *this;
518 }

References ASSERT, and OutputData< T >::mp_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 538 of file OutputData.h.

539 {
541  *this->mp_ll_data /= *right.mp_ll_data;
542  return *this;
543 }

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

◆ operator*=()

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

multiplication-assignment operator for two output data

Definition at line 520 of file OutputData.h.

521 {
523  *this->mp_ll_data *= *right.mp_ll_data;
524  return *this;
525 }

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

◆ getValue()

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

Returns value or summed value, depending on T.

◆ operator[]() [1/2]

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

indexed accessor

Definition at line 195 of file OutputData.h.

196  {
198  return (*mp_ll_data)[index];
199  }

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

◆ operator[]() [2/2]

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

indexed accessor (const)

Definition at line 202 of file OutputData.h.

203  {
205  return (*mp_ll_data)[index];
206  }

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

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

579 {
580  if (!isInitialized())
581  return false;
582  if (!right.isInitialized())
583  return false;
584  if (getRank() != right.getRank())
585  return false;
586  for (size_t i_axis = 0; i_axis < getRank(); ++i_axis)
587  if (getAxis(i_axis).size() != right.getAxis(i_axis).size())
588  return false;
589  return true;
590 }
bool isInitialized() const
returns true if object is correctly initialized
Definition: OutputData.h:527

References OutputData< T >::getAxis(), OutputData< T >::getRank(), OutputData< T >::isInitialized(), and IAxis::size().

Referenced by IntensityDataFunctions::createRelativeDifferenceData(), IntensityDataFunctions::getRelativeDifference(), and IHistogram::hasSameDimensions().

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

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

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

Referenced by IHistogram::hasSameShape().

Here is the call graph for this function:

◆ getArray()

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

returns data as Python numpy array

◆ isInitialized()

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

returns true if object is correctly initialized

Definition at line 527 of file OutputData.h.

528 {
529  if (!mp_ll_data)
530  return false;
531  if (getRank() != mp_ll_data->getRank())
532  return false;
533  if (!getRank())
534  return false;
535  return true;
536 }

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

◆ allocate()

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

memory allocation for current dimensions configuration

Definition at line 545 of file OutputData.h.

546 {
547  delete mp_ll_data;
548  size_t rank = m_value_axes.size();
549  int* dims = new int[rank];
550  for (size_t i = 0; i < rank; ++i) {
551  dims[i] = (int)getAxis(i).size();
552  }
553  mp_ll_data = new LLData<T>(rank, dims);
554  T default_value = {};
555  mp_ll_data->setAll(default_value);
556  delete[] dims;
557 }

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

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

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

◆ axisNameExists()

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

checks if given axis name exists

Definition at line 622 of file OutputData.h.

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

Friends And Related Function Documentation

◆ OutputDataIterator< T, OutputData< T > >

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

Definition at line 76 of file OutputData.h.

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

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

Definition at line 76 of file OutputData.h.

Member Data Documentation

◆ m_value_axes

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

◆ mp_ll_data


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