PSCF v1.1
AutoCorrelation.tpp
1#ifndef UTIL_AUTOCORRELATION_TPP
2#define UTIL_AUTOCORRELATION_TPP
3
4/*
5* Util Package - C++ Utilities for Scientific Computation
6*
7* Copyright 2010 - 2017, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11#include "AutoCorrelation.h"
12#include "AutoCorrStage.tpp"
13
14#include <string>
15
16namespace Util
17{
18
19 /*
20 * Constructor
21 */
22 template <typename Data, typename Product>
24 : AutoCorrStage<Data, Product>()
25 {
26 descendants_.append(this);
27 }
28
29 /*
30 * Read parameters and initialize.
31 */
32 template <typename Data, typename Product>
34 {
35 readOptional(in, "bufferCapacity", bufferCapacity_);
36 readOptional(in, "maxStageId", maxStageId_);
37 readOptional(in, "blockFactor", blockFactor_);
38 allocate();
39 }
40
41 /*
42 * Load internal state from archive.
43 */
44 template <typename Data, typename Product>
46 {
47 loadParameter<int>(ar, "bufferCapacity", bufferCapacity_);
48 loadParameter<int>(ar, "maxStageId", maxStageId_);
49 loadParameter<int>(ar, "blockFactor", blockFactor_);
50 serializePrivate(ar, 0);
51 }
52
53 /*
54 * Save internal state to archive.
55 */
56 template <typename Data, typename Product>
58 { ar & *this; }
59
60 /*
61 * Return the maximum delay.
62 */
63 template <typename Data, typename Product>
65 {
66 int iStage = descendants_.size() - 1;
67 AutoCorrStage<Data, Product>* stagePtr = descendants_[iStage];
68 int interval = stagePtr->stageInterval();
69 int size = stagePtr->bufferSize();
70 return (size - 1)*interval;
71 }
72
73 /*
74 * Register the creation of a descendant stage.
75 */
76 template <typename Data, typename Product>
77 void
80 { descendants_.append(ptr); }
81
82}
83#endif
Hierarchical auto-correlation function algorithm.
Definition: AutoCorrStage.h:54
long stageInterval() const
Return the number of primary values per block at this stage.
int bufferSize() const
Return current size of history buffer.
Auto-correlation function, using hierarchical algorithm.
int maxDelay() const
Return maximum delay, in primary samples.
virtual void readParameters(std::istream &in)
Read parameters from file and initialize.
virtual void load(Serializable::IArchive &ar)
Load internal state from an archive.
AutoCorrelation()
Constructor.
virtual void save(Serializable::OArchive &ar)
Save internal state to an archive.
Saving archive for binary istream.
Saving / output archive for binary ostream.
Utility classes for scientific computation.
Definition: accumulators.mod:1