API — ICoreBlocks/ICoreMath/SyntaxFromatting
The public contract of 5 header(s) under src/ICoreBlocks/ICoreMath/SyntaxFromatting — 5 class/struct definition(s), 27 declaration(s). Each section shows the header's banner and its public (and protected-virtual) surface exactly as the file writes it.
ICoreControlSystemsFormatting.h#
src/ICoreBlocks/ICoreMath/SyntaxFromatting/ICoreControlSystemsFormatting.h
ICoreControlSystemsFormatting#
ICoreControlSystemsFormatting.h:29 · class · 16 declaration(s)
String <-> object conversions for the control-systems types, the analog of ICoreMatlabFormatting for ICoreMatrix.
class ICoreControlSystemsFormatting {
public:
static std::pair<bool, ICorePolynomial> parsePolynomial(const std::string& s);
static std::pair<bool, ICoreTransferFunction> parseTransferFunction(const std::string& s);
static std::pair<bool, ICoreStateSpace> parseStateSpace(const std::string& s);
static std::pair<bool, ICoreZpk> parseZpk(const std::string& s);
static std::string toCanonical(const ICorePolynomial& p);
static std::string toCanonical(const ICoreTransferFunction& tf);
static std::string toCanonical(const ICoreStateSpace& ss);
static std::string toCanonical(const ICoreZpk& zpk);
static std::string pretty(const ICorePolynomial& p);
static std::string pretty(const ICoreTransferFunction& tf);
static std::string pretty(const ICoreStateSpace& ss);
static std::string pretty(const ICoreZpk& zpk);
// MATLAB's display of a model (the toolbox board's T0.2 (7), T1.1,
// T1.2), measured against R2026a and reproduced line for line except for
// the blank spacer lines and the trailing space MATLAB leaves after
// "A = ". A transfer function is its numerator centred over a rule of
// dashes over its denominator, indented two, with the coefficients at
// four significant digits ("s^2 + 2 s + 5", "1e06 s + 2.5"); a static
// gain is one number; a model with the denominator 1 is its numerator
// alone. A state-space model is its four matrices with MATLAB's x/u/y
// labels, every column the same width. Under either comes MATLAB's own
// trailer: "Continuous-time transfer function.", "Sample time: 0.1
// seconds" then "Discrete-time transfer function.", or "Static gain."
// The console's echo is this block with its kind tag on the last line.
static std::string matlabDisplay(const ICoreTransferFunction& tf);
// MATLAB's display of a `pid`/`pidstd` controller (T1.30) -- three lines
// of ASCII formula, a `with` line of gains and MATLAB's own trailer. Read
// by matlabDisplay() above for any model carrying the PID facet; a caller
// that wants the FRACTION asks for `tf(C)` first, which is what MATLAB
// requires too.
static std::string matlabPidDisplay(const ICoreTransferFunction& model);
static std::string matlabDisplay(const ICoreStateSpace& ss);
// MATLAB's display of a `zpk` model (T1.3), measured against R2026a the
// same way: the FACTORED numerator centred over a rule of dashes over the
// factored denominator, then "Continuous-time zero/pole/gain model.",
// "Sample time: ... seconds" + "Discrete-time zero/pole/gain model.", or
// "Static gain.".
//
// ⚠ THE FACTOR SPELLING IS NOT THE TRANSFER FUNCTION'S. A zpk prints a
// conjugate pair as the real quadratic `(s^2 + 2s + 5)` -- no space
// between the coefficient and the variable -- where the same model as a
// `tf` prints `s^2 + 2 s + 5` WITH the space. Both were read off R2026a;
// sharing matlabPolyBody() between the two displays would have been
// wrong in one of them.
static std::string matlabDisplay(const ICoreZpk& zpk);
};
};
ICoreCppFormatting.h#
src/ICoreBlocks/ICoreMath/SyntaxFromatting/ICoreCppFormatting.h
Convert ICoreMatrix to C++ initializer list format Example: { {1, 2}, {3, 4} }
ICoreCppFormatting#
ICoreCppFormatting.h:6 · class · 2 declaration(s)
class ICoreCppFormatting {
public:
// Convert ICoreMatrix to C++ initializer list format
// Example: { {1, 2}, {3, 4} }
static std::string convertToCppFormat(const ICoreMatrix& matrix);
// Convert C++ initializer list string to ICoreMatrix
// Returns: {matrix, error_message}
static std::pair<ICoreMatrix, std::string> convertFromCppFormat(const std::string& input);
};
};
ICoreMatlabFormatting.h#
src/ICoreBlocks/ICoreMath/SyntaxFromatting/ICoreMatlabFormatting.h
ICoreMatlabFormatting#
ICoreMatlabFormatting.h:9 · class · 4 declaration(s)
class ICoreMatlabFormatting {
public:
// Pattern for matching valid Matlab number strings
inline static const std::regex NUMBER_PATTERN =
std::regex(R"(^[+-]?(NaN|Inf|(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$))");
// Convert 2D vector of doubles to MATLAB string format, for READING: the
// stream's default 6 significant digits, which is the console's display
// precision. Not a round trip -- 1/3 comes back as 0.333333.
static std::string convertToMatlabFormat(const ICoreMatrix& mat);
// The same text at full round-trip precision (max_digits10), for STORING:
// parsing this back yields the identical double, every element.
//
// The two are separate functions and not one with a flag because they
// answer different questions and the wrong answer is silent either way: a
// display that prints 17 digits is unreadable, and a STORE that prints 6
// is a value quietly replaced by a nearby one -- which is what the console's
// variables space did until 2026-09-02, so that `inv(S) * S` read back
// through it was not the identity.
static std::string convertToMatlabFormatExact(const ICoreMatrix& mat);
// Convert Matlab string format to a pair of 2D double vector and error string
static std::pair<ICoreMatrix, std::string> convertFromMatlabFormat(const std::string& matlabStr);
};
};
ICorePythonFormatting.h#
src/ICoreBlocks/ICoreMath/SyntaxFromatting/ICorePythonFormatting.h
ICorePythonFormatting#
ICorePythonFormatting.h:6 · class · 2 declaration(s)
class ICorePythonFormatting {
public:
static std::string convertToPythonFormat(const ICoreMatrix& matrix);
static std::pair<ICoreMatrix, std::string> convertFromPythonFormat(const std::string& str);
};
};
ICoreTimeSeriesFormatting.h#
src/ICoreBlocks/ICoreMath/SyntaxFromatting/ICoreTimeSeriesFormatting.h
ICoreTimeSeriesFormatting#
ICoreTimeSeriesFormatting.h:22 · class · 3 declaration(s)
String <-> ICoreTimeSeries conversion, the same three roles as ICoreControlSystemsFormatting has for tf/ss/poly: parse : detect + build from a stored/console string (for assignType) toCanonical: re...
class ICoreTimeSeriesFormatting {
public:
static std::pair<bool, ICoreTimeSeries> parse(const std::string& s);
static std::string toCanonical(const ICoreTimeSeries& series);
// "Time Series (241 samples, t = 0 .. 2.4)" -- the table shows this rather
// than thousands of numbers.
static std::string pretty(const ICoreTimeSeries& series);
};
};