15 #ifndef __python_test__
16 #include <utl/AugerException.h>
19 #include <Eigen/Dense>
20 using namespace Eigen;
22 #ifndef __python_test__
28 LinearPredictor::LinearPredictor(
unsigned int numCoeffPerChannel,
unsigned int delayLine,
unsigned int numChannels,
unsigned int optimization)
30 numCoeffPerChannel(numCoeffPerChannel),
31 numChannels(numChannels),
34 dimCovMatr((numCoeffPerChannel + 1)*numChannels),
35 dimPredictorCoefficients(numCoeffPerChannel*numChannels),
36 totalPredictorOffset(numCoeffPerChannel + delayLine),
37 optimization(optimization),
38 covMatr(dimCovMatr, dimCovMatr),
39 predictorCoefficients()
42 #ifndef __python_test__
45 cout <<
"Need at least one channel to work on." << endl;
54 #ifndef __python_test__
57 cout <<
"The number of provided (active) channels is not equal to the number of configured channels." << endl;
61 unsigned int channelLength = channels[0].size();
79 #define dimX dimPredictorCoefficients
81 #define dimA numChannels
84 for (
unsigned int traceStartIndex = 0; traceStartIndex < maxTraceStartIndex; ++traceStartIndex) {
86 unsigned int samplingIndex = 0;
87 unsigned int traceIndex = 0;
89 traceIndex = traceStartIndex;
93 for (
unsigned int channelNum = 0; channelNum <
numChannels; ++channelNum) {
94 samplingVector(samplingIndex++) = channels[channelNum][traceIndex];
99 for (
unsigned int channelNum = 0; channelNum <
numChannels; ++channelNum, ++samplingIndex) {
100 samplingVector(samplingIndex) = channels[channelNum][traceIndex];
103 covMatr += samplingVector * samplingVector.transpose();
106 #define S samplingVector
131 subMatrixX(i*numChannels+
a, i*numChannels+
b) *= (1.0+fudgeFactor);
149 #ifndef __python_test__
152 cout <<
"The number of provided (active) channels is not equal to the number of configured channels." << endl;
156 unsigned int channelLength = channels[0].size();
160 std::vector< std::vector<double> > predicted(
numChannels, vector<double>(channelLength, 0.0));
162 for (
unsigned int traceStartIndex = 0; traceStartIndex < maxTraceStartIndex; ++traceStartIndex) {
164 for (
unsigned int channelNum1 = 0; channelNum1 <
numChannels; ++channelNum1) {
165 unsigned int samplingIndex = 0;
167 unsigned int traceIndex = traceStartIndex;
171 for (
unsigned int channelNum2 = 0; channelNum2 <
numChannels; ++channelNum2) {
172 predicted[channelNum1][traceIndexPredict] +=
predictorCoefficients(samplingIndex++, channelNum1) * channels[channelNum2][traceIndex];
std::vector< std::vector< double > > predict(std::vector< std::vector< double > > const &channels) const
Base class for exceptions arising because configuration data are not valid.
unsigned int optimization
void train(std::vector< std::vector< double > > const &channels, double fudgeFactor)
unsigned int numCoeffPerChannel
MatrixXd predictorCoefficients
unsigned int totalPredictorOffset