From 1d09b0775bf52049e56aaefc351689478b0cbb21 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Sat, 1 Feb 2025 02:57:59 -0500 Subject: [PATCH] matrix math speedup --- rank.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rank.js b/rank.js index 5d61c2a..bbb054b 100644 --- a/rank.js +++ b/rank.js @@ -79,7 +79,7 @@ function rankCalc(result, iterations = 10, main = [], domain_mode = false) { pr = []; matrixe = []; let msum = 1; - let intv = Math.pow(0.01 / rl, Math.pow(0.09, i / mm)); + let intv = Math.pow(0.001 / rl, Math.pow(0.09, i / mm)); console.log(`Completed ${i} iterations with ${intv} threshold`) let th = -1; @@ -95,28 +95,29 @@ function rankCalc(result, iterations = 10, main = [], domain_mode = false) { let ar = Object.keys(result); let rf = pr[una]; + let muna = matrixe[una]; for (let unb of ar) { let prb = prold[unb]; - matrixe[una][unb] = 0.03; + let munb = muna[unb] = 0.03; - if (prb * matrixf[una][unb] < intv || fnc[unb] == 0) { - let mfb = matrixf[una][unb]; + if (prb * munb < intv || fnc[unb] == 0) { + let mfb = munb; if (isNaN(mfb) || !mfb) continue; pr[una] += prb * mfb; continue; } for (let unc in result) { - let mfc = matrixf[una][unc]; + let mfc = muna[unc]; let mfb = matrixf[unc][unb]; if (isNaN(mfc) || isNaN(mfb) || !mfc || !mfb) continue; matrixe[una][unb] += mfc * mfb; } - msum += matrixe[una][unb]; - pr[una] += prb * matrixe[una][unb]; + msum += munb; + pr[una] += prb * munb; } }