permanent of square matrix
|
01-10-2024, 02:50 PM
(This post was last modified: 01-10-2024 08:20 PM by Albert Chan.)
Post: #9
|
|||
|
|||
RE: permanent of square matrix
(01-10-2024 08:32 AM)Werner Wrote: Just do v/2, use dj=+/-1 again and double the result. If all vi are odd, this will not help ;-) Numerical issue is not 2^(n-1) scaling factor (even for OP 9×9 matrix, factor is only 2^8=256). It is really catastrophic cancellation of p's during its iterations. For illustration purpose, I scaled lua code final result of -p/terms to simply return p For base 2, this scaling served no purpose, except reduce tiny chance of overflow. For base 10, this scaling may make numerical issue worse (some vi may be odd) Code: function permanent(M) Debug with print((-1)^k*p) (★) inside for k loop, tested with OP 9×9 random matrix. lua> permanent(m) -5556546744184800 20429002103295824 55255400982040850 31542151598286920 ... 314811585639751230 -119381930932063740 -81181015636135740 -81169499916475780 -73135689828461120 -241381971380131900 248282227143724100 ... 528128789659814300 524276224665997300 -2888266392290130400 -2753810694416846000 ... -3101014455289180000 -3584102548532368000 -3432517605155301000 -3500631868051796000 -- final p = permanent(m) This is probably a bad example, with final p very close to true result. (error = 3 ULP) But if true result is tiny, we could see why this algorithm have cancellation issues. (★) (-1)^k factor to account for p = t - p sign reversal. In other words, if rest of t's contributed nothing, this is the final p we get. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 9 Guest(s)