Function utils::romanToInt

Function Documentation

inline auto utils::romanToInt(const std::string &s) -> int

Generate a logarithmically spaced grid of points.

)

Equivalent to numpy’s logspace function (with base = e, i.e. numpy’s logspace(log(xMin), log(xMax), n, base=e)). xMin and xMax must both be strictly positive, and n must be >= 2, since the spacing between points is (log(xMax) - log(xMin)) / (n - 1); neither is checked here. Every interior point is computed as exp(log(xMin) + i * dLogX); the first and last points would be exp(log(xMin)) and exp(log(xMax)) respectively if computed the same way, neither of which is guaranteed to be bit-identical to xMin/xMax (exp and log are not exact inverses at the level of individual floating-point rounding), so both are instead set directly to xMin/xMax. This matters because a caller may rely on the returned grid never straying outside [xMin, xMax] – e.g. to stay within some other interpolant’s valid range – which a few ULPs of round-off on either end could otherwise violate.

Convert a Roman numeral string to an integer

Parameters:
  • xMin – The minimum value of the grid

  • xMax – The maximum value of the grid

  • n – The number of points in the grid

  • s – Roman numeral string (e.g. “III”, “IV”, “XXVI”); must consist only of the characters I, V, X, L, C, D, M

Returns:

A vector of n points, logarithmically spaced from xMin to xMax inclusive; result.front() == xMin and result.back() == xMax exactly (see

Returns:

The integer value, or 0 if s is empty or contains any unrecognized character