/** * ********************************************************************* * * <p>Synopsis [ ] * * <p>********************************************************************* */ public static void simulateHistogramREU(Gate g, GateLibrary gate_library, Args options) { if (g.is_unvisited()) { g.set_unvisited(false); ArrayList<Gate> children = g.getChildren(); for (Gate child : children) { if (child.is_unvisited()) { simulateHistogramREU(child, gate_library, options); } } // initialize g.get_histogram_reus().clear(); for (int i = 0; i < g.get_logics().size(); ++i) { // rows in truth table g.get_histogram_reus().add(new double[g.get_histogram_bins().get_NBINS()]); for (int j = 0; j < g.get_histogram_bins().get_NBINS(); ++j) { g.get_histogram_reus().get(i)[j] = 0.0; } } if (g.Type == GateType.OUTPUT_OR || g.Type == GateType.OUTPUT) { g.set_histogram_reus(GateUtil.getSumOfGateInputHistograms(g, gate_library, options)); } else if (g.Type == GateType.AND) { g.set_histogram_reus(GateUtil.getANDOfGateInputHistograms(g)); } else if (g.Type == GateType.NOT || g.Type == GateType.NOR) { // 2. For each row: for each bin: for each output bin: add normalizeToValue ArrayList<double[]> input_convreus = GateUtil.getSumOfGateInputHistograms(g, gate_library, options); g.set_in_histogram_reus(input_convreus); for (int i = 0; i < input_convreus.size(); ++i) { /*if(Args.dontcare_rows.contains(i)) { for(int bin=0; bin< g.get_histogram_reus().get(i).length; ++bin) { g.get_histogram_reus().get(i)[bin] = 0.0; } continue; }*/ double[] convhist = input_convreus.get(i); for (int bin = 0; bin < g.get_histogram_bins().get_NBINS(); ++bin) { double fractional_counts = convhist[bin]; double[] xslice = g.get_xfer_hist().get_xfer_interp().get(bin); for (int xslice_bin = 0; xslice_bin < g.get_histogram_bins().get_NBINS(); ++xslice_bin) { g.get_histogram_reus().get(i)[xslice_bin] += xslice[xslice_bin] * fractional_counts; } } } } // evaluateGateHistogramOverlap(g); //to compute gate scores } }