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 165 of file TargetBuffer_t.h.

Member Function Documentation

◆ clear()

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

Definition at line 168 of file TargetBuffer_t.h.

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

◆ operator[]()

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

Definition at line 173 of file TargetBuffer_t.h.

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

◆ 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 183 of file TargetBuffer_t.h.

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

◆ resize()

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

Definition at line 195 of file TargetBuffer_t.h.

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

Member Data Documentation

◆ m_buffer

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

Definition at line 202 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:195
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:202