This example shows how to use the high-level API to perform a fast CBC construction for embedded lattices.
#include "latbuilder/Parser/CommandLine.h"
#include "EmbeddedLatticePoints.h"
#include <iostream>
std::ostream& operator<<(std::ostream& os, const std::vector<double>& point)
{
auto old_prec = os.precision();
os.precision(3);
os << "(";
for (size_t j = 0; j < point.size(); j++) {
if (j > 0) os << ", ";
os << point[j];
}
os << ")";
os.precision(old_prec);
return os;
}
void simulate(EmbeddedLatticePoints lat)
{
while (lat.level() <= lat.maxLevel()) {
std::cout << "==> level " << lat.level() << std::endl;
for (size_t i = 0; i < lat.size(); i++)
std::cout << "point " << i << ":\t" << lat[i] << std::endl;
lat.extend();
}
}
EmbeddedLatticePoints search()
{
cmd.
construction =
"fast-CBC";
cmd.
weights = std::vector<std::string>{
"product:0.1"};
cmd.
weightsPowerScale = 1.0;
cmd.
multilevelFilters = std::vector<std::string>{
"norm:P2-SL10",
"low-pass:1.0"};
auto search = cmd.
parse();
std::cout << *search << std::endl;
search->execute();
std::cout << "BEST LATTICE: " << search->bestLattice() << std::endl;
std::cout << "MERIT: " << search->bestMeritValue() << std::endl;
const auto& lat = search->bestLattice();
return EmbeddedLatticePoints(lat.sizeParam().base(), lat.sizeParam().maxLevel(), lat.gen());
}
int main(int argc, const char *argv[])
{
EmbeddedLatticePoints lat = search();
simulate(lat);
return 0;
}