Example to generate Halton nodes in 2D.
#include <iostream>
#include <string>
#include <Eigen/Core>
#include <fmt/format.h>
#include <lyra/lyra.hpp>
#include <plotly_plotter/data_table.h>
#include <plotly_plotter/figure_builders/scatter.h>
#include <plotly_plotter/write_html.h>
#include <plotly_plotter/write_png.h>
auto main(int argc, char** argv) -> int {
const auto cli = lyra::cli().add_argument(lyra::opt(num_nodes, "Number")
.name("--num_nodes")
.name("-n")
.optional()
.help("Set the number of nodes."));
const auto result = cli.parse({argc, argv});
if (!result) {
std::cerr << result.message() << "\n\n";
std::cerr << cli << std::endl;
return 1;
}
const auto nodes =
plotly_plotter::data_table data;
auto x_list = data.emplace<double>("x");
auto y_list = data.emplace<double>("y");
for (const auto& node : nodes) {
x_list->push_back(node.x());
y_list->push_back(node.y());
}
const auto figure =
plotly_plotter::figure_builders::scatter(data)
.x("x")
.y("y")
.title(fmt::format("{} Halton nodes in 2D", num_nodes))
.create();
plotly_plotter::write_html("2d_halton_nodes.html", figure);
if (plotly_plotter::is_png_supported()) {
plotly_plotter::write_png("2d_halton_nodes.png", figure);
}
}
Definition of generate_halton_nodes function.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
auto generate_halton_nodes(index_type num_nodes) -> std::vector< Eigen::Vector< Scalar, Dimensions > >
Generate Halton nodes fornberg2015.