Example #1
0
        protected UnknownNumber Clone()
        {
            var result = new UnknownNumber(this.name);

            result.coefficient = this.coefficient;
            result.exponent    = this.exponent;
            return(result);
        }
Example #2
0
        public static UnknownNumber operator *(UnknownNumber one, decimal coeffi)
        {
            UnknownNumber result = one.Clone();

            //ax^2*3
            result.coefficient = one.coefficient * coeffi;

            return(result);
        }
Example #3
0
        public static UnknownNumber operator +(UnknownNumber one, UnknownNumber other)
        {
            //ax*by
            if (one.name != other.name)
            {
                throw new VarMatchException("different variable can't do add.", string.Format("var name1:{0}, var name2:{1}", one.name, other.name));
            }
            UnknownNumber result = new UnknownNumber(one.name);

            //ax^2*bx^3
            result.coefficient = one.coefficient * other.coefficient;
            result.exponent    = one.exponent + other.exponent;

            return(result);
        }