@Override public Pair<Integer, Double> process(Pair<Integer, List<Integer>> threadIDAndDocIndices) { int tID = threadIDAndDocIndices.first(); if (tID < 0 || tID >= multiThreadGrad) throw new IllegalArgumentException("threadID must be with in range 0 <= tID < multiThreadGrad(="+multiThreadGrad+")"); List<Integer> docIDs = threadIDAndDocIndices.second(); double[][] partE; // initialized below double[][] partEhat = null; // initialized below if (multiThreadGrad == 1) { partE = E; if (calculateEmpirical) partEhat = Ehat; } else { partE = parallelE[tID]; // TODO: if we put this on the heap, this clearing will be unnecessary clear2D(partE); if (calculateEmpirical) { partEhat = parallelEhat[tID]; clear2D(partEhat); } } double probSum = 0; for (int docIndex: docIDs) { if (calculateEmpirical) probSum += expectedAndEmpiricalCountsAndValueForADoc(partE, partEhat, docIndex); else probSum += expectedCountsAndValueForADoc(partE, docIndex); } return new Pair<>(tID, probSum); }
@Override public Pair<Integer, Double> process(Pair<Integer, List<Integer>> threadIDAndDocIndices) { int tID = threadIDAndDocIndices.first(); if (tID < 0 || tID >= multiThreadGrad) throw new IllegalArgumentException("threadID must be with in range 0 <= tID < multiThreadGrad(="+multiThreadGrad+")"); List<Integer> docIDs = threadIDAndDocIndices.second(); double[][] partE; // initialized below double[][] partEhat = null; // initialized below if (multiThreadGrad == 1) { partE = E; if (calculateEmpirical) partEhat = Ehat; } else { partE = parallelE[tID]; clear2D(partE); if (calculateEmpirical) { partEhat = parallelEhat[tID]; clear2D(partEhat); } } double probSum = 0; for (int docIndex: docIDs) { if (calculateEmpirical) probSum += expectedAndEmpiricalCountsAndValueForADoc(partE, partEhat, docIndex); else probSum += expectedCountsAndValueForADoc(partE, docIndex); } return new Pair<Integer, Double>(tID, probSum); }
@Override public Pair<Integer, Double> process(Pair<Integer, List<Integer>> threadIDAndDocIndices) { int tID = threadIDAndDocIndices.first(); if (tID < 0 || tID >= multiThreadGrad) throw new IllegalArgumentException("threadID must be with in range 0 <= tID < multiThreadGrad(="+multiThreadGrad+")"); List<Integer> docIDs = threadIDAndDocIndices.second(); double[][] partE; // initialized below double[][] partEhat = null; // initialized below if (multiThreadGrad == 1) { partE = E; if (calculateEmpirical) partEhat = Ehat; } else { partE = parallelE[tID]; // TODO: if we put this on the heap, this clearing will be unnecessary clear2D(partE); if (calculateEmpirical) { partEhat = parallelEhat[tID]; clear2D(partEhat); } } double probSum = 0; for (int docIndex: docIDs) { if (calculateEmpirical) probSum += expectedAndEmpiricalCountsAndValueForADoc(partE, partEhat, docIndex); else probSum += expectedCountsAndValueForADoc(partE, docIndex); } return new Pair<>(tID, probSum); }