M4 — pls4all source split plan¶
Source: Explore-agent analysis of cpp/src/core/model.cpp (4541 lines, 180 KB) +
cpp/src/core/extra_pls.cpp (1647 lines, 80 KB).
Totals¶
File |
Lines |
Functions |
Helpers (anon namespace) |
|---|---|---|---|
model.cpp |
4541 |
18 |
~1500 lines (L18–L1524) |
extra_pls.cpp |
1647 |
19 |
~290 lines (L18–L306) |
Total |
6188 |
37 |
~1790 |
Per-file function table¶
model.cpp¶
# |
Function |
Line |
Length |
Target |
|---|---|---|---|---|
1 |
|
1528 |
291 |
|
2 |
|
1819 |
10 |
|
3 |
|
1829 |
10 |
|
4 |
|
1839 |
161 |
|
5 |
|
2000 |
350 |
|
6 |
|
2350 |
265 |
|
7 |
|
2615 |
280 |
|
8 |
|
2895 |
166 |
|
9 |
|
3061 |
166 |
|
10 |
|
3227 |
170 |
|
11 |
|
3397 |
288 |
|
12 |
|
3685 |
200 |
|
13 |
|
3885 |
36 |
|
14 |
|
3921 |
242 |
|
15 |
|
4163 |
225 |
|
16 |
|
4388 |
46 |
|
17 |
|
4434 |
36 |
|
18 |
|
4470 |
72 |
|
extra_pls.cpp¶
# |
Function |
Line |
Length |
Target |
|---|---|---|---|---|
1 |
|
307 |
60 |
|
2 |
|
367 |
78 |
|
3 |
|
445 |
36 |
|
4 |
|
481 |
70 |
|
5 |
|
551 |
66 |
|
6 |
|
617 |
61 |
|
7 |
|
678 |
59 |
|
8 |
|
737 |
63 |
|
9 |
|
800 |
47 |
|
10 |
|
847 |
98 |
|
11 |
|
945 |
85 |
|
12 |
|
1030 |
111 |
|
13 |
|
1141 |
102 |
|
14 |
|
1243 |
90 |
|
15 |
|
1333 |
65 |
|
16 |
|
1398 |
79 |
|
17 |
|
1477 |
54 |
|
18 |
|
1531 |
52 |
|
19 |
|
1583 |
65 |
|
High-risk cross-cutting helpers¶
The ~1790 lines of helpers (anonymous namespaces) MUST be extracted FIRST,
into shared _common.cpp files, before any algorithm extraction:
Helper |
Location |
Used by |
Extract to |
|---|---|---|---|
|
extra_pls.cpp:97 |
model.cpp |
|
|
model.cpp:161 |
~15 model.cpp functions |
|
|
model.cpp helpers |
SVD / Kernel / Canonical / OPLS |
|
|
model.cpp:274,691,772,919,953,1064,1086,1175,3801 |
SVD variants + OPLS chassis |
|
|
extra_pls.cpp:87 |
all 4 sparse variants |
|
|
extra_pls.cpp helpers |
sparse + specialized |
|
|
model.cpp helpers |
most algorithms |
|
|
model.cpp helpers |
all fit_* functions |
|
Proposed extraction order (7 phases)¶
Phase |
Scope |
Commits |
|---|---|---|
1 |
Helpers → |
3 |
2 |
Core PLS solvers (nipals, simpls, svd, plssvd, power, randomized_svd, kernel, canonical) |
8 |
3 |
PCR + OPLS |
2 |
4 |
Classification (pls_da, pls_qda, pls_cox) |
3 |
5 |
Sparse (4 files) |
4 |
6 |
Specialized (6) + ensembles (3) + transfer (2) + local + glm |
12 |
7 |
Core dispatch + header consolidation |
2 |
Total: ~34 commits if each extraction is its own commit (best for blame
preservation). Per-commit gate: n4m_tests 265/265 still green and no
function moves are functional changes.
Notes from the agent’s analysis¶
Lines 18–1524 of model.cpp form a tight ~1500-line anonymous-namespace helper block with a clear boundary; lines 18–306 of extra_pls.cpp form a ~290-line one. Both extract cleanly.
No explicit
// === ALGORITHM ===section dividers exist; functions appear in topological order by dependency.The 18 model.cpp functions reach line 4541; the 19 extra_pls.cpp functions end at line 1647. Both files have no unaccounted top-level definitions.
Helpers do not cross between the two source files (each set is file-local). The
simple_simplscross-call from model.cpp → extra_pls.cpp viafit_pls_sparse_simplsis the ONE exception — extracting it first tomodels/pls/_common.cppresolves it cleanly.