Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
random.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/io/parsing/settings_parsers/random.hpp is free software: you can redistribute it
4//and/or modify it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//bertini2/io/parsing/settings_parsers/random.hpp is distributed in the hope that it will be
9//useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with bertini2/io/parsing/settings_parsers/random.hpp. If not, see
15//<http://www.gnu.org/licenses/>.
16//
17// Copyright(C) Bertini2 Development Team
18
24
25#pragma once
26
29
30namespace bertini {
31 namespace parsing {
32 namespace classic {
33
34 template<typename Iterator, typename Skipper>
36 struct ConfigSettingParser<Iterator, algorithm::RandomConfig, Skipper>
37 : qi::grammar<Iterator, algorithm::RandomConfig(), Skipper>
38 {
39 ConfigSettingParser() : ConfigSettingParser::base_type(root_rule_, "config::Random")
40 {
41 namespace phx = boost::phoenix;
42 using qi::_1;
43 using qi::_val;
44 using qi::lit;
45 using qi::char_;
46 using qi::ulong_;
47 using boost::spirit::ascii::no_case;
48
49 std::string seed_name = "randomseed";
50
51 root_rule_.name("config::Random");
52 root_rule_ = (random_seed_[phx::bind(
53 [](algorithm::RandomConfig& S, unsigned long v) {
54 S.random_seed = v;
55 }, _val, _1)]
56 >> -no_setting_)
57 | no_setting_;
58
59 all_names_ = no_case[seed_name] >> ':';
60
61 random_seed_.name("random_seed_");
62 random_seed_ = *(char_ - all_names_)
63 >> (no_case[seed_name] >> ':')
64 >> ulong_[_val = _1]
65 >> ';';
66
67 no_setting_.name("no_setting_");
68 no_setting_ = *(char_ - all_names_);
69 }
70
71 private:
72 qi::rule<Iterator, algorithm::RandomConfig(), Skipper> root_rule_;
73 qi::rule<Iterator, unsigned long(), Skipper> random_seed_;
74 qi::rule<Iterator, Skipper, std::string()> no_setting_, all_names_;
75 };
76
77 } // namespace classic
78 } // namespace parsing
79} // namespace bertini
Provides the base type for config settings parsers.
Definition algorithm_base.hpp:34
Definition classic_utilities.hpp:41
Definition classic_utilities.hpp:40
Definition algorithm_builder.hpp:36
The RNG seed a classic Bertini input file asks for, via randomseed: N;.
Definition config.hpp:264
unsigned long random_seed
The classic input's seed; 0 means draw one from entropy and report it.
Definition config.hpp:265