예제 #1
0
        private IProduct BuildCombination(ParseTreeNode leftNode, ParseTreeNode rightNode, string op, object[,] bag)
        {
            ICouponDecomposable left  = BuildProduct(leftNode, bag) as ICouponDecomposable;
            ICouponDecomposable right = BuildProduct(rightNode, bag) as ICouponDecomposable;

            switch (op)
            {
            case "+":
                return(DecomposableLinearCombination.Create(new[] { 1.0, 1.0 }, new[] { left, right }));

            case "-":
                return(DecomposableLinearCombination.Create(new[] { 1.0, -1.0 }, new[] { left, right }));

            default:
                throw new Exception("BUG should never get there !");
            }
        }
예제 #2
0
        private IProduct BuildWeighted(double weight, ParseTreeNode factorProductNode, object[,] bag)
        {
            var factor = BuildProduct(factorProductNode, bag) as ICouponDecomposable;

            return(DecomposableLinearCombination.Create(new[] { weight }, new[] { factor }));
        }