ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TTN::DoubleBuffer_t Class Reference

The temporary buffer for internal computations which is split into two halves. More...

#include <TargetBuffer_t.h>

Collaboration diagram for TTN::DoubleBuffer_t:

Public Member Functions

void clear (unsigned int max_buffer)
 
Buffer_t operator[] (unsigned int fold_idx)
 
std::vector< double > releaseData (std::vector< double >::size_type final_size, unsigned int fold_idx)
 move the final result to its destination More...
 

Private Member Functions

void resize (unsigned int max_buffer)
 

Private Attributes

std::vector< double > m_buffer
 

Detailed Description

The temporary buffer for internal computations which is split into two halves.

The buffer can be used in iterative computations which uses in each iteration the output of the previous one. For such computations, the input is stored in one half and the output in the other half, and the two buffers are swapped after each iteration. Finally the output half of the last iteration is copied to the beginning of the buffer and the buffer is shrunken to its final size.

Definition at line 163 of file TargetBuffer_t.h.

Member Function Documentation

◆ clear()

void TTN::DoubleBuffer_t::clear ( unsigned int  max_buffer)
inline

Definition at line 166 of file TargetBuffer_t.h.

166  {
167  resize(max_buffer);
168  std::fill(m_buffer.begin(),m_buffer.end(),double{});
169  }

◆ operator[]()

Buffer_t TTN::DoubleBuffer_t::operator[] ( unsigned int  fold_idx)
inline

Definition at line 171 of file TargetBuffer_t.h.

171  {
172  std::vector<double>::size_type max_idx=m_buffer.size()/2;
173  return Buffer_t(&(m_buffer[(fold_idx%2) * max_idx ]), max_idx,m_buffer);
174  }

◆ releaseData()

std::vector<double> TTN::DoubleBuffer_t::releaseData ( std::vector< double >::size_type  final_size,
unsigned int  fold_idx 
)
inline

move the final result to its destination

copy the indicated half to the beginning (if necessary) and shrink the buffer to its final size Finally "move" the internal buffer to its final destination.

Definition at line 181 of file TargetBuffer_t.h.

181  {
182  if (fold_idx%2 !=0 ) {
183  std::vector<double>::size_type max_idx=m_buffer.size()/2;
184  std::vector<double>::const_iterator first_iter(m_buffer.begin()+max_idx);
185  std::vector<double>::const_iterator last_iter(first_iter+max_idx);
186  std::copy(first_iter,last_iter, m_buffer.begin());
187  }
188  m_buffer.resize(final_size);
189  return std::move(m_buffer);
190  }

◆ resize()

void TTN::DoubleBuffer_t::resize ( unsigned int  max_buffer)
inlineprivate

Definition at line 193 of file TargetBuffer_t.h.

193  {
194  max_buffer*=2;
195  if (max_buffer>m_buffer.size()) {
196  m_buffer.resize(max_buffer,double{});
197  }
198  }

Member Data Documentation

◆ m_buffer

std::vector<double> TTN::DoubleBuffer_t::m_buffer
private

Definition at line 200 of file TargetBuffer_t.h.


The documentation for this class was generated from the following file:
TTN::DoubleBuffer_t::resize
void resize(unsigned int max_buffer)
Definition: TargetBuffer_t.h:193
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
calibdata.copy
bool copy
Definition: calibdata.py:27
TTN::DoubleBuffer_t::m_buffer
std::vector< double > m_buffer
Definition: TargetBuffer_t.h:200