This example shows how to use the high-level API to perform a fast CBC construction for ordinary lattices.
#include "latbuilder/Parser/CommandLine.h"
#include "LatticePoints.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(const LatticePoints& lat)
{
for (size_t i = 0; i < lat.size(); i++)
std::cout << "point " << i << ":\t" << lat[i] << std::endl;
}
LatticePoints search()
{
cmd.
construction =
"fast-CBC";
cmd.
weights = std::vector<std::string>{
"product:0.1"};
cmd.
weightsPowerScale = 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 LatticePoints(lat.sizeParam().numPoints(), lat.gen());
}
int main(int argc, const char *argv[])
{
LatticePoints lat = search();
simulate(lat);
return 0;
}