![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Classes | |
| class | Args |
| Named-argument reader over the parsed JSON object. More... | |
| struct | ArithSpec |
| The arithmetic a call runs at: Real also carries the precision tier. More... | |
| struct | EncodeScalar |
| struct | EncodeScalar< double > |
| struct | EncodeScalar< Rational > |
| struct | EncodeScalar< Real< D > > |
| struct | NumFromDecimal |
| struct | NumFromDecimal< double > |
| struct | NumFromDecimal< Rational > |
| struct | NumFromDecimal< Real< D > > |
Typedefs | |
| using | Json = nlohmann::json |
Functions | |
| ArithSpec | parse_arith (const std::string &text) |
| Parse –arith. | |
| std::vector< std::string > | api_exposed_functions () |
| Names exposed over this boundary, sorted; a subset of the registry. | |
| bool | api_is_exposed (const std::string &name) |
| True when the named function has a dispatch entry. | |
| Json | api_invoke (const std::string &name, const std::string &arith, const Json &args) |
| Invoke one API function. | |
| std::string | api_render_readable (const Json &result) |
| Human-readable rendering of the object api_invoke returns, for -o readable. | |
| std::string | shortest_decimal (double v) |
| The shortest decimal literal that round-trips to v. | |
| BigInt | pow10_bigint (unsigned e) |
| Rational | rational_from_decimal (const std::string &text) |
| Exact value of a decimal literal, with no rounding anywhere: sign, digits, optional fraction and optional exponent are read symbolically and assembled as numerator over a power of ten. | |
| double | double_from_decimal (const std::string &text) |
| double value of a decimal literal, including the "a/b" fraction form. | |
| std::string | decimal_text (const Json &j, const std::string &where) |
| The decimal literal behind a JSON scalar, per the policy in the file header. | |
| template<class T> | |
| T | number_from_json (const Json &j, const std::string &where) |
| template<class T> | |
| Matrix< T > | matrix_from_json (const Json &j, const std::string &where) |
| A matrix from a JSON value: 2-D array as rows, 1-D array as a row vector, scalar as 1x1, empty array as the empty matrix. | |
| template<class T> | |
| std::vector< T > | vector_from_json (const Json &j, const std::string &where) |
| A flat numeric vector: 1-D array, or a 1-row / 1-column 2-D array. | |
| std::vector< int > | int_vector_from_json (const Json &j, const std::string &where) |
| An integer vector; a non-integral entry is an error, never a truncation. | |
| template<class T> | |
| Json | encode_scalar (const T &v) |
| template<class T> | |
| Json | encode_vector (const std::vector< T > &v) |
| template<class T> | |
| Json | encode_matrix (const Matrix< T > &m) |
| Json | encode_ints (const std::vector< int > &v) |
| template<class T> | |
| Json | encode_matrices (const std::vector< Matrix< T > > &v) |
| A list of matrices, the shape the MMAP/BMAP families return as {D0,D1,...}. | |
| template<class T> | |
| Json | encode_vectors (const std::vector< std::vector< T > > &v) |
| A list of vectors, the shape a per-class or per-segment result returns. | |
| Json | encode_count (std::size_t n) |
| A count. | |
| using line::reg::Json = nlohmann::json |
Definition at line 63 of file api_json.h.
| std::vector< std::string > line::reg::api_exposed_functions | ( | ) |
Names exposed over this boundary, sorted; a subset of the registry.
Definition at line 2847 of file api_dispatch.cpp.
References api_exposed_functions().
Referenced by api_exposed_functions(), and api_invoke().
| Json line::reg::api_invoke | ( | const std::string & | name, |
| const std::string & | arith, | ||
| const Json & | args ) |
Invoke one API function.
| name | MATLAB function name, e.g. "pfqn_ca" |
| arith | text of –arith, e.g. "exact" or "real:50" |
| args | object keyed by the MATLAB parameter names |
| UnsupportedError,InputError,NumericError |
Definition at line 2857 of file api_dispatch.cpp.
References api_exposed_functions(), api_invoke(), line::api_supports(), line::ApiEntry::arith, line::arith_name(), line::ApiEntry::domain, line::find_api(), line::reg::ArithSpec::mode, parse_arith(), line::reg::ArithSpec::str(), and line::UnsupportedError::UnsupportedError().
Referenced by api_invoke(), and run_invocation().
| bool line::reg::api_is_exposed | ( | const std::string & | name | ) |
True when the named function has a dispatch entry.
Definition at line 2853 of file api_dispatch.cpp.
References api_is_exposed().
Referenced by api_is_exposed().
| std::string line::reg::api_render_readable | ( | const Json & | result | ) |
Human-readable rendering of the object api_invoke returns, for -o readable.
Definition at line 2950 of file api_dispatch.cpp.
References api_render_readable().
Referenced by api_render_readable(), and run_invocation().
|
inline |
The decimal literal behind a JSON scalar, per the policy in the file header.
Definition at line 199 of file api_json.h.
References decimal_text(), line::InputError::InputError(), and shortest_decimal().
Referenced by decimal_text(), int_vector_from_json(), and number_from_json().
|
inline |
double value of a decimal literal, including the "a/b" fraction form.
Definition at line 154 of file api_json.h.
References double_from_decimal(), and line::InputError::InputError().
Referenced by double_from_decimal(), line::reg::NumFromDecimal< double >::parse(), and line::reg::NumFromDecimal< Real< D > >::parse().
|
inline |
A count.
Written as a plain JSON integer at every arithmetic: an iteration count or a dimension is exact in all of them, so wrapping it in the {"double",...} envelope the scalars use would suggest a precision question that a cardinal number does not have.
Definition at line 378 of file api_json.h.
References encode_count().
Referenced by encode_count().
|
inline |
A list of matrices, the shape the MMAP/BMAP families return as {D0,D1,...}.
Definition at line 358 of file api_json.h.
References encode_matrices(), and encode_matrix().
Referenced by encode_matrices().
Definition at line 340 of file api_json.h.
References line::Matrix< T >::cols(), encode_matrix(), encode_scalar(), and line::Matrix< T >::rows().
Referenced by encode_matrices(), and encode_matrix().
| Json line::reg::encode_scalar | ( | const T & | v | ) |
Definition at line 328 of file api_json.h.
References encode_scalar().
Referenced by encode_matrix(), encode_scalar(), and encode_vector().
| Json line::reg::encode_vector | ( | const std::vector< T > & | v | ) |
Definition at line 333 of file api_json.h.
References encode_scalar(), and encode_vector().
Referenced by encode_vector(), and encode_vectors().
| Json line::reg::encode_vectors | ( | const std::vector< std::vector< T > > & | v | ) |
A list of vectors, the shape a per-class or per-segment result returns.
Definition at line 366 of file api_json.h.
References encode_vector(), and encode_vectors().
Referenced by encode_vectors().
|
inline |
An integer vector; a non-integral entry is an error, never a truncation.
Definition at line 267 of file api_json.h.
References decimal_text(), line::InputError::InputError(), int_vector_from_json(), and rational_from_decimal().
Referenced by line::reg::Args::boolean(), int_vector_from_json(), line::reg::Args::integer(), line::reg::Args::ints(), line::reg::Args::ints_or_empty(), and line::reg::Args::required_integer().
| Matrix< T > line::reg::matrix_from_json | ( | const Json & | j, |
| const std::string & | where ) |
A matrix from a JSON value: 2-D array as rows, 1-D array as a row vector, scalar as 1x1, empty array as the empty matrix.
Ragged rows are an error.
Definition at line 223 of file api_json.h.
References line::InputError::InputError(), line::Matrix< T >::Matrix(), matrix_from_json(), and number_from_json().
Referenced by line::reg::Args::matrices(), line::reg::Args::matrix(), matrix_from_json(), line::reg::Args::matrix_or_empty(), and vector_from_json().
| T line::reg::number_from_json | ( | const Json & | j, |
| const std::string & | where ) |
Definition at line 210 of file api_json.h.
References decimal_text(), and number_from_json().
Referenced by matrix_from_json(), line::reg::Args::number(), number_from_json(), and line::reg::Args::scalar().
| ArithSpec line::reg::parse_arith | ( | const std::string & | text | ) |
Parse –arith.
Accepts "double", "exact" and "real:<digits>"; anything else is an InputError listing the accepted forms. The port instantiates the high-precision backend at three fixed tiers (50, 100, 200 digits), so a request between tiers is rounded UP to the next one – never down, so a caller never silently receives less precision than asked – and str() reports the tier actually used. Above 200 digits the call is refused.
Definition at line 196 of file api_dispatch.cpp.
References line::reg::ArithSpec::digits, line::Double, line::Exact, line::InputError::InputError(), line::reg::ArithSpec::mode, parse_arith(), line::Real, and line::UnsupportedError::UnsupportedError().
Referenced by api_invoke(), parse_arith(), and run_invocation().
|
inline |
Definition at line 86 of file api_json.h.
References pow10_bigint().
Referenced by pow10_bigint(), and rational_from_decimal().
|
inline |
Exact value of a decimal literal, with no rounding anywhere: sign, digits, optional fraction and optional exponent are read symbolically and assembled as numerator over a power of ten.
Definition at line 97 of file api_json.h.
References line::InputError::InputError(), pow10_bigint(), and rational_from_decimal().
Referenced by int_vector_from_json(), line::reg::NumFromDecimal< Rational >::parse(), and rational_from_decimal().
|
inline |
The shortest decimal literal that round-trips to v.
nlohmann::json does not retain the text of a number, so this reconstructs the literal a human wrote: for every double that came from a short decimal in the file, the reconstruction IS that decimal, because a double has at most one shortest round-tripping representation.
Definition at line 76 of file api_json.h.
References shortest_decimal().
Referenced by decimal_text(), and shortest_decimal().
| std::vector< T > line::reg::vector_from_json | ( | const Json & | j, |
| const std::string & | where ) |
A flat numeric vector: 1-D array, or a 1-row / 1-column 2-D array.
Definition at line 255 of file api_json.h.
References line::Matrix< T >::cols(), line::Matrix< T >::empty(), line::InputError::InputError(), matrix_from_json(), line::Matrix< T >::rows(), line::Matrix< T >::size(), and vector_from_json().
Referenced by line::reg::Args::vector(), vector_from_json(), and line::reg::Args::vector_or_empty().