コード例 #1
0
        public EmitSyntax Build(EmitSyntax emit)
        {
            int rows = table.RowCount;
            int columns = table.ColumnCount;

            Ref<Labels> END = emit.Labels.Generate().GetRef();
            Ref<Labels>[] labels = new Ref<Labels>[rows];
            for (int i = 0; i != rows; ++i)
            {
                labels[i] = emit.Labels.Generate().GetRef();
            }

            emit
                .Do(LdRow)
                .Switch(labels)
                .Ldc_I4(-1)
                .Br(END)
                ;

            var columnRange = new IntInterval(0, columns - 1);
            var columnFrequency = new UniformIntFrequency(columnRange);
            for (int i = 0; i != rows; ++i)
            {
                var switchEmitter = SwitchGenerator.Sparse(table.GetRow(i), columnRange, columnFrequency);

                emit.Label(labels[i].Def);
                switchEmitter.Build(emit, LdCol, SwitchGenerator.LdValueAction(END));
            }

            return emit .Label(END.Def);
        }
コード例 #2
0
        public void TestElementaryChecks()
        {
            const int DefaultValue = -100;
            var elementToAction = new MutableIntMap<int>();
            elementToAction.DefaultValue = DefaultValue;
            var bounds = new IntInterval(0, 9);
            var frequency = new UniformIntFrequency(bounds);
            elementToAction.Set(new IntArrow<int>(2, 100));
            elementToAction.Set(new IntArrow<int>(5, 200));

            var target = new DecisionTreeBuilder(platformInfo);
            var node = target.Build(elementToAction, bounds, frequency);
            PrintProgram(node, target.DefaultActionDecision);
        }
コード例 #3
0
        public void TestSameActionUnification()
        {
            var frequency = new UniformIntFrequency(new IntInterval(-100, 100));

            const int DefaultValue = -100;
            var elementToAction = new MutableIntMap<int>();
            elementToAction.DefaultValue = DefaultValue;
            elementToAction.Set(new IntArrow<int>(1, 1));
            elementToAction.Set(new IntArrow<int>(3, 49, 1));
            elementToAction.Set(new IntArrow<int>(51, 1));
            elementToAction.Set(new IntArrow<int>(54, 100, 1));

            var target = new DecisionTreeBuilder(platformInfo);
            var bounds = new IntInterval(0, 1000);
            var node = target.Build(elementToAction, bounds, frequency);
            PrintProgram(node);
        }