예제 #1
0
        public void RoFunctionTest()
        {
            var function = new RoFunction(0, 1, n, x, k);

            Assert.AreEqual(new Fraction(1, 2), function.Calculate());

            var function1 = new RoFunction(0, 2, n, x, k);

            Assert.AreEqual(new Fraction(2, 3), function1.Calculate());

            var function2 = new RoFunction(0, 3, n, x, k);

            Assert.AreEqual(new Fraction(1, 2), function2.Calculate());

            var function3 = new RoFunction(0, 4, n, x, k);

            Assert.AreEqual(new Fraction(1), function3.Calculate());

            var function4 = new RoFunction(1, 1, n, x, k);

            Assert.AreEqual(new Fraction(1, 3), function4.Calculate());

            var function5 = new RoFunction(1, 2, n, x, k);

            Assert.AreEqual(new Fraction(1, 2), function5.Calculate());
        }
        public Fraction Calculate()
        {
            if (_s == 0)
            {
                return(StartValueCalculate());
            }
            var roFunction1 = new RoFunction(_s - 1, 2 * _t - 1, _n, _x, _k);
            var roFunction2 = new RoFunction(_s - 1, 2 * _t, _n, _x, _k);

            return(roFunction1.Calculate() * roFunction2.Calculate());
        }
        public Fraction Calculate()
        {
            if (_s == 0)
            {
                return(StartValueCalculate());
            }

            var lamdaFunction1 = new LamdaFunction(_s - 1, 2 * _t - 1, _n, _x, _k);
            var lamdaFunction2 = new LamdaFunction(_s - 1, 2 * _t, _n, _x, _k);
            var roFunction     = new RoFunction(_s - 1, 2 * _t - 1, _n, _x, _k);

            return(lamdaFunction1.Calculate() + lamdaFunction2.Calculate() * roFunction.Calculate());

            /*  return (new LamdaFunction(_s - 1, 2 * _t - 1, _n, _x, _k).Calculate()) +
             *        ((new LamdaFunction(_s - 1, 2 *_t, _n, _x, _k).Calculate()) *
             *         (new RoFunction(_s - 1, 2 *_t, _n, _x, _k).Calculate()));*/
        }