PSCF v1.3
AutoCorrelation.h
1#ifndef UTIL_AUTOCORRELATION_H
2#define UTIL_AUTOCORRELATION_H
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 <util/global.h>
12#include "AutoCorrStage.h" // base class
13#include <util/param/ParamComposite.h> // base class
14#include <util/containers/GArray.h> // member
15
16namespace Util
17{
18
28 template <typename Data, typename Product>
29 class AutoCorrelation : public AutoCorrStage<Data, Product>,
30 public ParamComposite
31 {
32
33 public:
34
39
45 virtual void readParameters(std::istream& in);
46
52 virtual void load(Serializable::IArchive &ar);
53
59 virtual void save(Serializable::OArchive &ar);
60
64 int maxDelay() const;
65
66 using AutoCorrStage<Data, Product>::setParam;
67 using AutoCorrStage<Data, Product>::sample;
68 using AutoCorrStage<Data, Product>::clear;
69 using AutoCorrStage<Data, Product>::serialize;
70 using AutoCorrStage<Data, Product>::output;
71 using AutoCorrStage<Data, Product>::bufferCapacity;
72 using AutoCorrStage<Data, Product>::nSample;
73 using AutoCorrStage<Data, Product>::stageInterval;
74 using AutoCorrStage<Data, Product>::autoCorrelation;
75 using AutoCorrStage<Data, Product>::corrTime;
76
77 protected:
78
79 using AutoCorrStage<Data, Product>::bufferCapacity_;
80 using AutoCorrStage<Data, Product>::maxStageId_;
81 using AutoCorrStage<Data, Product>::blockFactor_;
82 using AutoCorrStage<Data, Product>::allocate;
83 using AutoCorrStage<Data, Product>::serializePrivate;
84
93
94 private:
95
96 // Pointers to descendant AutoCorrStage objects
98
99 };
100
101}
102#endif
long stageInterval() const
Return the number of primary values per block at this stage.
int bufferCapacity() const
Return capacity of history buffer.
void output(std::ostream &out)
Output the autocorrelation function, assuming zero mean.
AutoCorrStage()
Constructor.
void serialize(Archive &ar, const unsigned int version)
Serialize to/from an archive.
void clear()
Clear accumulators and destroy descendants.
void serializePrivate(Archive &ar, const unsigned int version)
Serialize private data members, and descendants.
virtual void sample(Data value)
Sample a value.
Product autoCorrelation(int t) const
Return autocorrelation at a given time, assuming zero average.
double corrTime() const
Estimate of autocorrelation time, in samples.
long nSample() const
Return the number of sampled values.
int bufferCapacity_
Physical capacity (# of elements) of buffer, corr, and nCorr.
int maxStageId_
Maximum allowed stage index (controls maximum degree of blocking).
int blockFactor_
Number of values per block (ratio of intervals for successive stages).
void allocate()
Allocate memory and initialize to empty state.
void setParam(int bufferCapacity=64, int maxStageId=0, int blockFactor=2)
Set all parameters and allocate to initialize state.
int maxDelay() const
Return maximum delay, in primary samples.
virtual void registerDescendant(AutoCorrStage< Data, Product > *ptr)
Register a descendant stage.
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.
An automatically growable array, analogous to a std::vector.
Definition GArray.h:34
ParamComposite()
Constructor.
BinaryFileIArchive IArchive
Type of input archive used by load method.
BinaryFileOArchive OArchive
Type of output archive used by save method.
File containing preprocessor macros for error handling.
Utility classes for scientific computation.