# MATLAB compatibility ledger

This ledger identifies behavior that must be characterized or repaired in MATLAB before the corresponding C++/SymEngine module is ported. A repair is complete only when a MATLAB test states the intended behavior.

| Area | MATLAB evidence | Required action before C++ port |
|---|---|---|
| `SCC.m` loading | File declares `classdef SCC_node`; Octave rejects it because the class name does not match the filename. Constructor is named `SCC`. | Decide the intended legacy class identity, repair filename/class/constructor consistency, and add a load/constructor test. |
| `build_tree_old.m` loading | File declares `build_tree`, not `build_tree_old`. | Rename the function or classify the file as intentionally retired; test the chosen behavior. |
| `conv_on.m` loading | File declares `phase_conv`, which conflicts with `phase_conv.m`. | Retire or rename the legacy helper after comparing behavior with `phase_conv.m`. |
| Generic duty vector | `generic_switched_capacitor_class` assigns the last duty as `1 - obj.duty`; behavior is clear for two phases and ambiguous for more phases. | Keep two-phase behavior as the first supported scope. Reject more than two phases until an N-phase MATLAB contract exists. |
| Up-charge setter | `SCC_Phase.set_a_vector_up` writes `a_vector` rather than `a_vector_up`. | Confirm intended field, repair setter, and test getter/setter round trip. |
| Redistributed-vector guard | `SCC_Phase.get_r_vector` tests `a_vector` twice instead of testing both `a_vector` and `b_vector`. | Repair guard and test missing-vector errors plus valid `r = ac - b` behavior. |
| Generic topology option | `hybrid_topology` calls `isfield('dc_out', opt)` with reversed arguments. | Repair option parsing and test default and explicit `dc_out`. |
| Generic topology filtering | `hybrid_topology` refers to `n_caps` although it is not an argument or local variable. | Replace with the intended topology value and test output filtering. |
| Dickson half-point | `dickson_hybrid_topology` creates `ArchDef`, but the `half_point` branch later uses undefined `A_caps`, `A_sw1`, and `A_sw2`. | Restore intended matrix transformation or mark half-point unsupported; add architecture fixtures. |
| SSL ripple constraint | `dickson_optimizer_ssl` marks the condition as `NOT WORKING`; constrained branch does not complete the same optimizer path. | Define expected constraint semantics, repair, and test feasible/infeasible cases. |
| FSL weighted-current mode | `dickson_optimizer_fsl` uses `Io` in mode `-3`, but `Io` is not an input or local value. | Add the intended option/input and test weighted-output optimization. |
| Parasitic pole analysis | `get_poles` uses `Cesr` in the calculation when some argument-count branches do not initialize it. | Define zero/default ESR behavior and test every supported call shape. |
| Symbol substitution | Topology wrappers and optimizers use positional values ordered by `symvar`. | Keep MATLAB compatibility order, but add explicit symbol-vector fixtures before porting. |
| Current QFA schema | QFA wrappers export symbolic fields such as `f_ssl`, `f_fsl`, `f_esr`, `N_caps`, `N_sw`, and `g_top`. | Preserve in a dedicated QFA module and typed compatibility adapter. |
| Older Seeman schema | `generate_topology` exports `ac`, `ar`, `vc`, `vcb`, `vr`, and `vrb`, consumed by `implement_topology` and `evaluate_loss`. | Preserve in a separate module; do not add an implicit schema conversion. |

## Repair sequence

Repair only the MATLAB behavior needed by the next C++ dependency layer:

1. loading and graph helpers;
2. `SCC_Phase` and two-phase duty behavior;
3. architecture wrappers and options;
4. symbolic topology result ordering;
5. SSL/FSL optimizer branches;
6. older Seeman flow;
7. ancillary pole analysis and legacy classes.

Each repair must land with a MATLAB regression test before its C++ counterpart is implemented.
