Loading...
Searching...
No Matches
timeblockencoder.h
Go to the documentation of this file.
#ifndef DYSCO_TIME_BLOCK_ENCODER_H
#define DYSCO_TIME_BLOCK_ENCODER_H
#include "stochasticencoder.h"
#include "timeblockbuffer.h"
#include "uvector.h"
#include <complex>
#include <random>
#include <vector>
class RMSMeasurement {
public:
RMSMeasurement() : _count(0), _value(0.0) {}
void Include(const std::complex<double> &val) {
if (isfinite(val)) {
_count++;
_value += val.real() * val.real() + val.imag() * val.imag();
}
}
double RMS() const { return sqrt(_value / (_count * 2)); }
private:
static bool isfinite(const std::complex<double> &val) {
return std::isfinite(val.real()) && std::isfinite(val.imag());
}
size_t _count;
double _value;
};
class TimeBlockEncoder {
public:
typedef TimeBlockBuffer<std::complex<float>> FBuffer;
typedef typename TimeBlockBuffer<std::complex<float>>::DataRow FBufferRow;
typedef TimeBlockBuffer<std::complex<double>> DBuffer;
typedef typename TimeBlockBuffer<std::complex<double>>::DataRow DBufferRow;
typedef unsigned symbol_t;
virtual ~TimeBlockEncoder() {}
virtual void EncodeWithDithering(
const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount,
std::mt19937 &rnd) = 0;
virtual void EncodeWithoutDithering(
const dyscostman::StochasticEncoder<float> &gausEncoder, FBuffer &buffer,
float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount) = 0;
virtual void InitializeDecode(const float *metaBuffer, size_t nRow,
size_t nAntennae) = 0;
virtual void Decode(const dyscostman::StochasticEncoder<float> &gausEncoder,
FBuffer &buffer, const symbol_t *symbolBuffer,
size_t blockRow, size_t antenna1, size_t antenna2) = 0;
virtual size_t SymbolCount(size_t nRow, size_t nPol,
size_t nChannels) const = 0;
virtual size_t SymbolCount(size_t nRow) const = 0;
virtual size_t SymbolsPerRow() const = 0;
virtual size_t MetaDataCount(size_t nRow, size_t nPol, size_t nChannels,
size_t nAntennae) const = 0;
protected:
TimeBlockEncoder() {}
};
#endif
RMSMeasurement::_value
double _value
Definition timeblockencoder.h:31
RMSMeasurement::RMS
double RMS() const
Definition timeblockencoder.h:23
RMSMeasurement::isfinite
static bool isfinite(const std::complex< double > &val)
Definition timeblockencoder.h:26
RMSMeasurement::Include
void Include(const std::complex< double > &val)
Definition timeblockencoder.h:16
RMSMeasurement::_count
size_t _count
Definition timeblockencoder.h:30
RMSMeasurement::RMSMeasurement
RMSMeasurement()
Definition timeblockencoder.h:14
TimeBlockBuffer
Definition timeblockbuffer.h:10
TimeBlockEncoder::SymbolCount
virtual size_t SymbolCount(size_t nRow, size_t nPol, size_t nChannels) const =0
TimeBlockEncoder::SymbolCount
virtual size_t SymbolCount(size_t nRow) const =0
TimeBlockEncoder::DBufferRow
TimeBlockBuffer< std::complex< double > >::DataRow DBufferRow
Definition timeblockencoder.h:39
TimeBlockEncoder::FBuffer
TimeBlockBuffer< std::complex< float > > FBuffer
Definition timeblockencoder.h:36
TimeBlockEncoder::~TimeBlockEncoder
virtual ~TimeBlockEncoder()
Definition timeblockencoder.h:43
TimeBlockEncoder::MetaDataCount
virtual size_t MetaDataCount(size_t nRow, size_t nPol, size_t nChannels, size_t nAntennae) const =0
TimeBlockEncoder::symbol_t
unsigned symbol_t
Definition timeblockencoder.h:41
TimeBlockEncoder::EncodeWithDithering
virtual void EncodeWithDithering(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount, std::mt19937 &rnd)=0
TimeBlockEncoder::DBuffer
TimeBlockBuffer< std::complex< double > > DBuffer
Definition timeblockencoder.h:38
TimeBlockEncoder::SymbolsPerRow
virtual size_t SymbolsPerRow() const =0
TimeBlockEncoder::InitializeDecode
virtual void InitializeDecode(const float *metaBuffer, size_t nRow, size_t nAntennae)=0
TimeBlockEncoder::TimeBlockEncoder
TimeBlockEncoder()
Definition timeblockencoder.h:72
TimeBlockEncoder::FBufferRow
TimeBlockBuffer< std::complex< float > >::DataRow FBufferRow
Definition timeblockencoder.h:37
TimeBlockEncoder::Decode
virtual void Decode(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, const symbol_t *symbolBuffer, size_t blockRow, size_t antenna1, size_t antenna2)=0
TimeBlockEncoder::EncodeWithoutDithering
virtual void EncodeWithoutDithering(const dyscostman::StochasticEncoder< float > &gausEncoder, FBuffer &buffer, float *metaBuffer, symbol_t *symbolBuffer, size_t antennaCount)=0
dyscostman::StochasticEncoder
Lossy encoder for stochastic values.
Definition stochasticencoder.h:32
stochasticencoder.h
timeblockbuffer.h
uvector.h
Header file for UVector and its relational and swap functions.