106 lines
No EOL
3 KiB
C++
106 lines
No EOL
3 KiB
C++
#include "utk/metrics/PCF.hpp"
|
|
#include "utk/metrics/RDF_Heck.hpp"
|
|
#include "utk/samplers/SamplerStep_Custom.hpp"
|
|
#include <filesystem>
|
|
#include <format>
|
|
#include <utk/metrics/RadialSpectrum.hpp>
|
|
#include <utk/samplers/SamplerSinglePeak.hpp>
|
|
#include <utk/samplers/SamplerStep.hpp>
|
|
#include <utk/samplers/SamplerWhitenoise.hpp>
|
|
#include <utk/utils/Pointset.hpp>
|
|
#include <utk/utils/PointsetIO.hpp>
|
|
|
|
#define DIMENSION 1025
|
|
#define NSAMPLES 4096
|
|
#define NBINS 1000
|
|
#define SEED 8970
|
|
|
|
template<typename T>
|
|
void writeSpectrumToFile(const std::string &filename, std::vector<T> spectrum) {
|
|
std::ofstream file;
|
|
file.open(filename);
|
|
|
|
file << DIMENSION << std::endl;
|
|
|
|
for (auto freq: spectrum) {
|
|
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
|
<< std::fixed;
|
|
file << freq << std::endl;
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
void writePCFToFile(const std::string &filename, std::vector<T> spectrum) {
|
|
std::ofstream file;
|
|
file.open(filename);
|
|
|
|
for (auto freq: spectrum) {
|
|
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
|
<< std::fixed;
|
|
file << freq << std::endl;
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
void writeRadspecToFile(const std::string &filename,
|
|
std::pair<std::vector<T>, std::vector<T>> radspec) {
|
|
std::ofstream file;
|
|
file.open(filename);
|
|
|
|
auto xs = radspec.first;
|
|
auto ys = radspec.second;
|
|
|
|
if (xs.size() != ys.size()) {
|
|
std::cerr << "Dimensions of radial spactrum are unequal: xDim: "
|
|
<< xs.size() << " yDim: " << ys.size() << std::endl;
|
|
std::terminate();
|
|
}
|
|
|
|
for (int i = 0; i < xs.size(); ++i) {
|
|
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
|
<< std::fixed;
|
|
file << xs[i] << ", " << ys[i] << std::endl;
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
void writeRDFtoFile(const std::string &filename,
|
|
std::pair<std::vector<T>, std::vector<T>> radspec) {
|
|
std::ofstream file;
|
|
file.open(filename);
|
|
|
|
auto xs = radspec.first;
|
|
auto ys = radspec.second;
|
|
|
|
if (xs.size() != ys.size()) {
|
|
std::cerr << "Dimensions of radial spectrum are unequal: xDim: "
|
|
<< xs.size() << " yDim: " << ys.size() << std::endl;
|
|
std::terminate();
|
|
}
|
|
|
|
for (int i = 0; i < xs.size(); ++i) {
|
|
file << std::setprecision(std::numeric_limits<long double>::digits10 + 2)
|
|
<< std::fixed;
|
|
file << xs[i] << ", " << ys[i] << std::endl;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
|
|
utk::Pointset<long double> blueNoise{};
|
|
utk::Pointset<double> whiteNoise{};
|
|
|
|
utk::Pointset<double> pointset;
|
|
float criticalFrequency = 0.606f;
|
|
float smoothing = 8.f;
|
|
utk::CustomHeckSampler sampler(criticalFrequency, smoothing, 0.5);
|
|
sampler.setRandomSeed(1024);
|
|
|
|
if (!sampler.generateSamples(pointset, 512)) {
|
|
std::cerr << "Sampler returned non-zero output" << std::endl;// No log here, must be visible whatsoever
|
|
return 1;
|
|
}
|
|
|
|
|
|
return 0;
|
|
} |