コード例 #1
0
        public void BeforeMathFunction(MathFunctionType mathFunctionType)
        {
            switch (mathFunctionType)
            {
            case MathFunctionType.Abs:
                AppendAfterSpace("ABS(");
                break;

            case MathFunctionType.Cos:
                AppendAfterSpace("COS(");
                break;

            case MathFunctionType.Max:
                AppendAfterSpace("MAX(");
                break;

            case MathFunctionType.Sin:
                AppendAfterSpace("SIN(");
                break;

            case MathFunctionType.Sum:
                AppendAfterSpace("SUM(");
                break;

            case MathFunctionType.IsNull:
                AppendAfterSpace("ISNULL(");
                break;
            }
        }
コード例 #2
0
        public MathFunction(double coef, MathFunctionType type, params MathFunction[] functions)
        {
            this.functions = new List <MathFunction>();

            this.coef = coef;
            this.type = type;

            switch (type)
            {
            case MathFunctionType.Sum:
                bool allZero = true;

                foreach (MathFunction func in functions)
                {
                    if (!func.IsZero())
                    {
                        this.functions.Add(func);
                        allZero = false;
                    }
                }

                if (allZero)
                {
                    this.coef = 0;
                }
                break;

            case MathFunctionType.Multiplication:
                for (int i = 0; i < functions.Length; i++)
                {
                    if (functions[i].IsZero())
                    {
                        coef = 0;
                        break;
                    }
                }

                foreach (MathFunction func in functions)
                {
                    this.functions.Add(func);
                }
                break;

            case MathFunctionType.Division:
                InitializeDivision(functions);

                if (functions[0].IsZero())
                {
                    coef = 0;
                    this.functions.Clear();
                    break;
                }

                break;
            }
        }
コード例 #3
0
        public IMathFunction WithFunctionType(MathFunctionType type)
        {
            if (type == MathFunctionType.pow || type == MathFunctionType.hypot || type == MathFunctionType.rem || type == MathFunctionType.mod)
            {
                _Ports = "[2 1]";
            }
            else
            {
                _Ports = "[1 1]";
            }

            _Operator = type;
            return(this);
        }
コード例 #4
0
 public MathFunction()
 {
     functions = new List <MathFunction>();
     type      = MathFunctionType.Sum;
     coef      = 0.0d;
 }
コード例 #5
0
 public MathFunction(MathFunctionType type, params IVisitable[] parameters)
 {
     this.parameters = parameters;
     Type            = type;
 }