Create() public static method

public static Create ( Function num, Function denom ) : Function
num Function
denom Function
return Function
Esempio n. 1
0
        public override Function Multiply(Function f)
        {
            if (f is Fraction)
            {
                Fraction frac = f as Fraction;
                return(Fraction.Create(this.num * frac.num, this.denom * frac.denom));
            }

            return(Fraction.Create(this.num * f, this.denom));
        }
Esempio n. 2
0
        public override Function Divide(Function f)
        {
            if (f is Fraction)
            {
                Fraction frac = f as Fraction;
                return(Fraction.Create(this.num * frac.denom, this.denom * frac.num));
            }

            return(Fraction.Create(this.num, this.denom * f));
        }
Esempio n. 3
0
        /// <summary>
        /// 除算。
        /// </summary>
        /// <param name="f">オペランド</param>
        /// <returns>除算結果</returns>
        public virtual Function Divide(Function f)
        {
            Constant c = f as Constant;

            if (c != null)
            {
                return(new Multiple(1 / c.Value, this));
            }

            return(Fraction.Create(this, f));
        }
Esempio n. 4
0
        public override Function Optimize()
        {
            Function num   = this.num.Optimize();
            Function denom = this.denom.Optimize();

            if (num.Equals(denom))
            {
                return((Constant)1);
            }

            return(Fraction.Create(num, denom));
        }
Esempio n. 5
0
        public override Function Bind(params Parameter[] x)
        {
            Function num   = this.num.Bind(x);
            Function denom = this.denom.Bind(x);

            if (denom is Constant)
            {
                Constant  c   = denom as Constant;
                ValueType val = 1 / c.Value;

                if (num is Constant)
                {
                    c    = num as Constant;
                    val *= c.Value;
                    return((Constant)val);
                }

                c = (Constant)val;
                return(c * num);
            }

            return(Fraction.Create(num, denom));
        }