static boolean computeLogMi( FeatureGenerator featureGen, double lambda[], DoubleMatrix2D Mi_YY, DoubleMatrix1D Ri_Y, boolean takeExp, boolean reuseM, boolean initMDone) { if (reuseM && initMDone) { Mi_YY = null; } else initMDone = false; if (Mi_YY != null) Mi_YY.assign(0); Ri_Y.assign(0); while (featureGen.hasNext()) { Feature feature = featureGen.next(); int f = feature.index(); int yp = feature.y(); int yprev = feature.yprev(); float val = feature.value(); // System.out.println(feature.toString()); if (yprev < 0) { // this is a single state feature. double oldVal = Ri_Y.getQuick(yp); Ri_Y.setQuick(yp, oldVal + lambda[f] * val); } else if (Mi_YY != null) { Mi_YY.setQuick(yprev, yp, Mi_YY.getQuick(yprev, yp) + lambda[f] * val); initMDone = true; } } if (takeExp) { for (int r = Ri_Y.size() - 1; r >= 0; r--) { Ri_Y.setQuick(r, expE(Ri_Y.getQuick(r))); if (Mi_YY != null) for (int c = Mi_YY.columns() - 1; c >= 0; c--) { Mi_YY.setQuick(r, c, expE(Mi_YY.getQuick(r, c))); } } } return initMDone; }