Example #1
0
        public static IUnaryOperator Parse(ISyntaxNode parent, ref string Input, IRightValue firstOperand)
        {
            string temp = Input;

            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "(\\+|-|!|~|\\*|&)");//|\\("+Provider.type+"\\)

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Success)
            {
                Input = temp;
                return null;
            }

            Input = Input.Remove(0, match.Index + match.Length);

            string Operator = match.Groups["def"].Value;

            switch (Operator)
            {

                default:
                    Input = temp;
                    throw new NotImplementedException();
            }
        }
Example #2
0
        public static IBinaryOperator Parse(ISyntaxNode parent, ref string Input, IRightValue firstOperand)
        {
            string temp = Input;

            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "(\\+|\\*|-|/|==|!=|>=|<=|<|>|\\||\\|\\||&|&&|\\^|%|<<|>>)");

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Groups["def"].Success)
            {
                Input = temp;
                return(null);
            }

            Input = Input.Remove(0, match.Index + match.Length);

            string Operator = match.Groups["def"].Value;

            IRightValue secondOperand = IRightValue.Parse(parent, ref Input);

            switch (Operator)
            {
            case "+":
                return(new AdditionOperator(parent, firstOperand, secondOperand));

            case "-":
                return(new SubtractionOperator(parent, firstOperand, secondOperand));

            case "*":
                return(new MultiplicationOperator(parent, firstOperand, secondOperand));

            case "/":
                return(new DivisionOperator(parent, firstOperand, secondOperand));

            case "==":
                return(new EqualOperator(parent, firstOperand, secondOperand));

            case "!=":
                return(new UnequalOperator(parent, firstOperand, secondOperand));

            case ">=":
                return(new GreaterEqualOperator(parent, firstOperand, secondOperand));

            case "<=":
                return(new LessEqualOperator(parent, firstOperand, secondOperand));

            case ">":
                return(new GreaterOperator(parent, firstOperand, secondOperand));

            case "<":
                return(new LessOperator(parent, firstOperand, secondOperand));

            default:
                Input = temp;
                throw new NotImplementedException();
            }
        }
Example #3
0
        public Brackets(ISyntaxNode parent, ref string Input)
            : base(parent)
        {
            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "\\(");

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Success)
            {
                throw new ParseException();
            }

            Input = Input.Remove(0, match.Index + match.Length);

            this.Operand = IRightValue.Parse(this, ref Input);


            Pattern regExClosePattern = "^\\s*\\)";

            regEx = new System.Text.RegularExpressions.Regex(regExClosePattern);
            match = regEx.Match(Input);

            if (!match.Success)
            {
                throw new ParseException();
            }
            Input             = Input.Remove(0, match.Index + match.Length);
            regExClosePattern = "^\\s*\\)";
        }
Example #4
0
        public static IUnaryOperator Parse(ISyntaxNode parent, ref string Input, IRightValue firstOperand)
        {
            string temp = Input;

            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "(\\+|-|!|~|\\*|&)");                //|\\("+Provider.type+"\\)

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Success)
            {
                Input = temp;
                return(null);
            }

            Input = Input.Remove(0, match.Index + match.Length);

            string Operator = match.Groups["def"].Value;


            switch (Operator)
            {
            default:
                Input = temp;
                throw new NotImplementedException();
            }
        }
Example #5
0
        public IBinaryOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
            : base(parent)
        {
            this.FirstOperand = firstOperand;
            this.SecondOperand = secondOperand;

            this.FirstOperand.Parent = this;
            this.SecondOperand.Parent = this;
        }
Example #6
0
        public IBinaryOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
            : base(parent)
        {
            this.FirstOperand  = firstOperand;
            this.SecondOperand = secondOperand;

            this.FirstOperand.Parent  = this;
            this.SecondOperand.Parent = this;
        }
Example #7
0
 public IUnaryOperator(ISyntaxNode parent, IRightValue operand)
     : base(parent)
 {
     this.Operand = operand;
     this.Operand.Parent = this;
 }
Example #8
0
        /// <summary>
        /// Constructs a new CPointFunction2D through evaluation of IRightValues
        /// in order to fill the data used to evaluate the function.
        /// </summary>
        /// <param name="cordinatesX">
        /// An array of IRightValue whose result is ordered from lower to greater and will
        /// represent the x parameter of the function.
        /// </param>
        /// <param name="cordinatesY">
        /// An array of IRightValue whose result is ordered from lower to greater and will
        /// represent the y parameter of the function.
        /// </param>
        /// <param name="values">
        /// A bi-dimensional array containing the defined data points for
        /// all the coordinates specified by cordinatesX and cordinatesY.
        /// </param>
        /// <param name="interpolationType">
        /// The interpolation to apply when evaluating the function
        /// in case the requested coordinates aren't represented, but inside them.
        /// </param>
        /// <param name="extrapolationType">
        /// The extrapolation to apply when evaluating the function,
        /// in case the requested coordinates are outside the represented ones.
        /// </param>
        public CPointFunction2D(IRightValue[] cordinatesX,
                                IRightValue[] cordinatesY,
                                IRightValue[,] values,
                                EInterpolationType interpolationType,
                                ExtrapolationType extrapolationType)
            : this()
        {
            this.interpolationType = interpolationType;
            this.extrapolationType = extrapolationType;

            // Sets the sizes depending on the passed arrays length.
            SetSizes(cordinatesX.Length, cordinatesY.Length);

            // First copy the parsed elements for the x coordinates.
            for (int i = cordinatesX.Length - 1; i >= 0; i--)
            {
                this[i, -1] = cordinatesX[i].V();
            }

            // Then copy the parsed elements for the y coordinates.
            for (int i = cordinatesY.Length - 1; i >= 0; i--)
            {
                this[-1, i] = cordinatesY[i].V();
            }

            // Finally populate the values matrix with the provided data.
            for (int x = 0; x < values.GetLength(0); x++)
            {
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    this[x, y] = values[x, y].V();
                }
            }
        }
Example #9
0
 public LessOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #10
0
 public MultiplicationOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #11
0
 public IUnaryOperator(ISyntaxNode parent, IRightValue operand)
     : base(parent)
 {
     this.Operand        = operand;
     this.Operand.Parent = this;
 }
Example #12
0
 public LessEqualOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #13
0
 public GreaterEqualOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #14
0
        public static IBinaryOperator Parse(ISyntaxNode parent, ref string Input, IRightValue firstOperand)
        {
            string temp = Input;

            Pattern regExPattern =
                "^\\s*" +
                new Group("def", "(\\+|\\*|-|/|==|!=|>=|<=|<|>|\\||\\|\\||&|&&|\\^|%|<<|>>)");

            System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(regExPattern);
            System.Text.RegularExpressions.Match match = regEx.Match(Input);

            if (!match.Groups["def"].Success)
            {
                Input = temp;
                return null;
            }

            Input = Input.Remove(0, match.Index + match.Length);

            string Operator = match.Groups["def"].Value;

            IRightValue secondOperand = IRightValue.Parse(parent, ref Input);

            switch (Operator)
            {
                case "+":
                    return new AdditionOperator(parent, firstOperand, secondOperand);
                case "-":
                    return new SubtractionOperator(parent, firstOperand, secondOperand);
                case "*":
                    return new MultiplicationOperator(parent, firstOperand, secondOperand);
                case "/":
                    return new DivisionOperator(parent, firstOperand, secondOperand);
                case "==":
                    return new EqualOperator(parent, firstOperand, secondOperand);
                case "!=":
                    return new UnequalOperator(parent, firstOperand, secondOperand);
                case ">=":
                    return new GreaterEqualOperator(parent, firstOperand, secondOperand);
                case "<=":
                    return new LessEqualOperator(parent, firstOperand, secondOperand);
                case ">":
                    return new GreaterOperator(parent, firstOperand, secondOperand);
                case "<":
                    return new LessOperator(parent, firstOperand, secondOperand);

                default:
                    Input = temp;
                    throw new NotImplementedException();
            }
        }
Example #15
0
 public AdditionOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #16
0
 public SubtractionOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }
Example #17
0
        /// <summary>
        /// Constructs a new CPointFunction2D through evaluation of IRightValues
        /// in order to fill the data used to evaluate the function.
        /// </summary>
        /// <param name="coordinatesX">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the x parameter of the function.
        /// </param>
        /// <param name="coordinatesY">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the y parameter of the function.
        /// </param>
        /// <param name="values">
        /// A bi-dimensional array containing the defined data points for
        /// all the coordinates specified by coordinatesX and coordinatesY.
        /// </param>
        /// <param name="interpolationType">
        /// The interpolation to apply when evaluating the function
        /// in case the requested coordinates aren't represented, but inside them.
        /// </param>
        /// <param name="extrapolationType">
        /// The extrapolation to apply when evaluating the function,
        /// in case the requested coordinates are outside the represented ones.
        /// </param>
        public CPointFunction2D(IRightValue[] coordinatesX,
                                IRightValue[] coordinatesY,
                                IRightValue[,] values,
                                EInterpolationType interpolationType,
                                ExtrapolationType extrapolationType)
            : this()
        {
            this.interpolationType = interpolationType;
            this.extrapolationType = extrapolationType;

            // Check if the interpolation and extrapolation methods are available.
            if (extrapolationType == ExtrapolationType.USEMODEL &&
               interpolationType != EInterpolationType.LEAST_SQUARES)
            {
                throw new Exception("Use model extrapolation method is " +
                                    "supported only for Least Squares");
            }

            // Sets the sizes depending on the passed arrays length.
            SetSizes(coordinatesX.Length, coordinatesY.Length);

            // First copy the parsed elements for the x coordinates.
            for (int i = coordinatesX.Length - 1; i >= 0; i--)
            {
                this[i, -1] = coordinatesX[i].V();
            }

            // Then copy the parsed elements for the y coordinates.
            for (int i = coordinatesY.Length - 1; i >= 0; i--)
            {
                this[-1, i] = coordinatesY[i].V();
            }

            // Finally populate the values matrix with the provided data.
            for (int x = 0; x < values.GetLength(0); x++)
            {
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    this[x, y] = values[x, y].V();
                }
            }

            UpdateModel();
        }
Example #18
0
 public GreaterOperator(ISyntaxNode parent, IRightValue firstOperand, IRightValue secondOperand)
     : base(parent, firstOperand, secondOperand)
 {
 }