Commit 334cd94
committed
Fix add_low_rank to only compute roots when cached roots exist
This fixes a numerical instability bug where add_low_rank would speculatively
compute root decompositions even when no cached roots existed. This caused
SVD failures on ill-conditioned matrices (e.g., when using LinearKernel).
Changes:
- Change early exit condition from 'not generate_roots and not has_roots'
to 'not (generate_roots and has_roots)' - exit early if EITHER
generate_roots=False OR no cached roots exist
- Pass generate_roots parameter through in RootLinearOperator.add_low_rank
(was being silently ignored)
- Update docstrings for cat_rows to clarify new generate_roots behavior
- Add regression test to verify root_decomposition is not called when
no roots are cached
- Update test_cat_rows to handle operators that return different types
from cat_rows (e.g., CatLinearOperator) that don't preserve cache1 parent 0f31521 commit 334cd94
4 files changed
Lines changed: 88 additions & 17 deletions
File tree
- linear_operator
- operators
- test
- test/operators
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1074 | 1074 | | |
1075 | 1075 | | |
1076 | 1076 | | |
1077 | | - | |
| 1077 | + | |
| 1078 | + | |
1078 | 1079 | | |
1079 | | - | |
| 1080 | + | |
1080 | 1081 | | |
1081 | 1082 | | |
1082 | 1083 | | |
| |||
1218 | 1219 | | |
1219 | 1220 | | |
1220 | 1221 | | |
1221 | | - | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1222 | 1226 | | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
1223 | 1230 | | |
1224 | 1231 | | |
1225 | 1232 | | |
| |||
1253 | 1260 | | |
1254 | 1261 | | |
1255 | 1262 | | |
1256 | | - | |
| 1263 | + | |
| 1264 | + | |
1257 | 1265 | | |
1258 | 1266 | | |
1259 | 1267 | | |
1260 | 1268 | | |
1261 | 1269 | | |
1262 | 1270 | | |
1263 | 1271 | | |
1264 | | - | |
| 1272 | + | |
1265 | 1273 | | |
1266 | 1274 | | |
1267 | 1275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
745 | 760 | | |
746 | 761 | | |
747 | | - | |
748 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
749 | 765 | | |
750 | 766 | | |
751 | 767 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
33 | 76 | | |
34 | 77 | | |
35 | 78 | | |
| |||
0 commit comments