Symbolic Matrix Inverse — Control Systems/Symbolic
Control_Systems/Symbolic/Symbolic_Matrix_Inverse · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
Symbolic Matrix Inverse
Control Systems / Symbolic
Inverts a square matrix of expressions symbolically and evaluates the
result on the input at every sample: Y = M(x)−1. This is
MATLAB's inv on a sym matrix.
The inverse is taken once, when the configuration loads, as adj(M) / det(M) over exact rational arithmetic. What runs per sample is n×n closed-form expressions of the input – no elimination, no pivot search, no branch. That fixed arithmetic is the reason to reach for this block instead of a numeric inverse: a numeric one chooses its pivots from the numbers, so its operation order changes with the signal, and three of the ten export targets cannot carry that.
The factory setting is [x+2, y; y, x+3], whose inverse is [x+3, −y; −y, x+2] / ((x+2)(x+3) − y²) – non-singular at the origin, so the block out of the library is a worked one.
Ports
- x – the variables, a vector of n entries (a column [n,1] or a row [1,n]) where n is the number of names in Variables: entry k is the k-th name. A Mux in front builds it from scalar signals. ⚠ n is the number of VARIABLES, not the size of the matrix – the two are unrelated, and a 2×2 matrix over one variable takes a [1,1] input.
- y – the inverse, an [m,m] matrix, the shape of Expression.
Parameters
- Expression – a SQUARE matrix literal over the names in
Variables, written with semicolons between rows and commas
between the entries of a row:
[x+2, y; y, x+3]. A non-square matrix is refused with its shape, and so is a scalar – for a scalar the inverse is1/f, which Symbolic Expression already writes. Entries may use numbers,pi,+ - * / ^, parentheses and the functionssin cos tan sec csc cot asin acos atan acot sinh cosh tanh asinh acosh atanh exp log log2 log10 sqrt abs sign heaviside. - Variables – the names of the input's entries, in order, separated
by spaces or commas:
x y. Each is a MATLAB identifier, none may repeat, and none may be a function name orpi,e,i,j,Inf,NaNoreps. At most 12. - Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust,
C, C++, VHDL, Verilog, SystemVerilog and
PLC Structured Text. The algebra is done once, at configuration load; what
each target carries is the RESULT, printed as one inline expression per entry with
its constants folded to 17 significant digits, so a generated core inverts nothing
and has no parameter to tune. Where a target lacks a function it gets the identity
– Java has no inverse hyperbolic functions and PLC Structured Text no
hyperbolic functions at all, so those are written through log,
exp and sqrt. The three HDL targets are
simulation-only real arithmetic, quantized to Q16.16 only at
the ports: the entries share a determinant in the denominator, and a reciprocal
across many orders of magnitude is not a fixed-point datapath.
Simulink bridge
None (Support::None). inv on a
sym is a Symbolic Math Toolbox function, and that toolbox ships no
Simulink library at all, so there is no library path a diagram could name; the
bridge reports this block rather than dropping it, and it therefore has no
parity testbench. Code export verification covers it across all ten
languages. No configuration crosses, including "Sampling Time (s)".
Notes
- ⚠ A SINGULAR matrix is answered, not refused. Every entry of the adjugate is divided by a determinant that is exactly zero, so the output is infinities – which is the block saying the matrix has no inverse at that input. MATLAB warns and answers infinities in the entries whose adjugate is non-zero and 0 elsewhere; this block answers infinities everywhere, because the division happens entry by entry. Neither set of numbers means anything, and a matrix that is singular only at SOME inputs is the ordinary case: the determinant is an expression, and it has zeros.
- ⚠
abs,signandheavisideARE accepted here, unlike everywhere else in this family. Nothing is differentiated, so the engine's objection – thatdiff(abs(x))needs an assumption the console would have to hold – does not arise, and an opaque function is carried the way a variable is. - Algebraic, with no state: the output depends only on the current input.
- Size limits are on the generated code: 144 entries, 4000 operations per entry. The adjugate of an n×n matrix holds n² determinants of order n−1, so the expressions grow fast in n; a matrix whose inverse outgrows the limit is refused with that reason rather than truncated.
- No state space: the map is nonlinear in general, so model reduction correctly declines the block.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Symbolic/Symbolic_Matrix_Inverse |
| family | Control_Systems/Symbolic |
| solver environment class | ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Matrix_Inverse |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Matrix_Inverse/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Matrix_Inverse.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Symbolic_Matrix_Inverse/ICoreBlock_0_Control_Systems_1_Symbolic_2_Symbolic_Matrix_Inverse.h |
| default size on canvas | 140 × 70 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | x |
| 2 | out | ICoreDouble | y |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
Expression | [x + 2, y; y, x + 3] | — |
Variables | x y | — |
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): inv on a sym is a Symbolic Math Toolbox function, and that toolbox ships no Simulink library at all, so there is no library path a diagram could name; the block is reported rather than dropped when a model crosses
Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The checker has a blind spot here — it could not resolve something (a grouped port bullet, a computed config name), which is reported and never counted as a pass. A reader has to settle it:
B0every stimulus in the sample errored — cross-checks skipped
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
Symbolic Matrix Inverse -- inv on a matrix of EXPRESSIONS, inverted once at config load Y = M(x)^-1 = adj(M(x)) / det(M(x))
The inverse is taken ONCE, symbolically, when the configuration loads; what runs per sample is n*n closed-form expressions of the input. That is the whole point of this block rather than a numeric inverse: there is no elimination, no pivot search and no branch anywhere in the emitted body, so the arithmetic is FIXED -- the same operations in the same order on every sample, in all ten targets, which is what a hardware target and a PLC can carry. Control_Systems/Base_Blocks' numeric matrix inverse cannot make that promise, because its pivoting depends on the numbers.
The reading, the sizing contract, compute_h and all ten generators are ICoreSymbolicBlockBase's; the adjugate and the determinant are the console's own symbolic engine's, over exact rational arithmetic, reached through ICoreSymbolicProgram. This file is what is genuinely this block's: its operation, its ports, its configs, its description, its icon and its Simulink entry.
⚠ IT IS THE FAMILY'S ONE ALGEBRA BLOCK, NOT A CALCULUS ONE, and two things follow that no other block here can say.
absandsignare ACCEPTED, because nothing is differentiated and the engine carries an opaque function the way it carries a variable -- every other transformation in this family refuses them by name. And a SINGULAR matrix is ANSWERED rather than refused: every entry of the adjugate is divided by an exact zero, so the answer is infinities, which is a statement that the matrix has no inverse.VERIFIED OUTSIDE ICORE, because code-export verification compares the block with itself: the block's own C++ evaluation was compared with MATLAB R2026a's
inv(sym(...))on the same matrices at the same points -- the toolbox-blocks plan's row records the counts.
Sample results#
No stimulus produced a sampled output in this rig — Invalid input size at Symbolic Matrix Inverse block: ICore Blocks/Home/Symbolic Matrix Inverse. That is a fact about the single-block rig, not a verdict on the block: an offline batch fit, a block whose output only appears at onSolverFinish, or one that needs a driven environment cannot be exercised alone.
Category unsampled · sample time 0.1 · 60 steps · commit b5ce05a7a · produced by docsSample --out <folder> --blocks Symbolic_Matrix_Inverse --steps 60
Sample data: docs/generated/samples/Control_Systems__Symbolic__Symbolic_Matrix_Inverse.json