当前位置: 首页>>代码示例>>C#>>正文


C# Variable.Clone方法代码示例

本文整理汇总了C#中xFunc.Maths.Expressions.Variable.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Variable.Clone方法的具体用法?C# Variable.Clone怎么用?C# Variable.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xFunc.Maths.Expressions.Variable的用法示例。


在下文中一共展示了Variable.Clone方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DerivativeTest3

        public void DerivativeTest3()
        {
            // x ^ 3
            Variable x = new Variable("x");
            Number num1 = new Number(3);

            IExpression exp = new Pow(x, num1);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("x ^ 4", exp.ToString());
            Assert.AreEqual("1 * (3 * (x ^ (3 - 1)))", deriv.ToString());

            // 2 ^ (3x)
            Number num2 = new Number(2);
            num1 = new Number(3);
            Mul mul = new Mul(num1, x.Clone());

            exp = new Pow(num2, mul);
            deriv = exp.Differentiate();

            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());

            num1.Value = 4;
            Assert.AreEqual("2 ^ (4 * x)", exp.ToString());
            Assert.AreEqual("(ln(2) * (2 ^ (3 * x))) * (3 * 1)", deriv.ToString());
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:29,代码来源:ExponentiationTest.cs

示例2: DerivativeTest2

        public void DerivativeTest2()
        {
            Number num1 = new Number(2);
            Variable x = new Variable("x");
            Mul mul1 = new Mul(num1, x);

            Number num2 = new Number(3);
            Mul mul2 = new Mul(num2, x.Clone());

            IExpression exp = new Sub(mul1, mul2);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(2 * 1) - (3 * 1)", deriv.ToString());

            num1.Value = 5;
            num2.Value = 4;
            Assert.AreEqual("(5 * x) - (4 * x)", exp.ToString());
            Assert.AreEqual("(2 * 1) - (3 * 1)", deriv.ToString());
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:19,代码来源:SubtractionTest.cs

示例3: DerivativeTest3

        public void DerivativeTest3()
        {
            // (2x) / (3x)
            Number num1 = new Number(2);
            Variable x = new Variable("x");
            Mul mul1 = new Mul(num1, x);

            Number num2 = new Number(3);
            Mul mul2 = new Mul(num2, x.Clone());

            IExpression exp = new Div(mul1, mul2);
            IExpression deriv = exp.Differentiate();

            Assert.AreEqual("(((2 * 1) * (3 * x)) - ((2 * x) * (3 * 1))) / ((3 * x) ^ 2)", deriv.ToString());

            num1.Value = 4;
            num2.Value = 5;
            Assert.AreEqual("(4 * x) / (5 * x)", exp.ToString());
            Assert.AreEqual("(((2 * 1) * (3 * x)) - ((2 * x) * (3 * 1))) / ((3 * x) ^ 2)", deriv.ToString());
        }
开发者ID:ronnycsharp,项目名称:xFunc,代码行数:20,代码来源:DivisionTest.cs

示例4: DivDerivativeTest3

        public void DivDerivativeTest3()
        {
            // (2x) / (3x)
            var num1 = new Number(2);
            var x = new Variable("x");
            var mul1 = new Mul(num1, x);

            var num2 = new Number(3);
            var mul2 = new Mul(num2, x.Clone());

            var exp = new Div(mul1, mul2);
            var deriv = Differentiate(exp);

            Assert.Equal("((2 * 1 * 3 * x) - (2 * x * 3 * 1)) / ((3 * x) ^ 2)", deriv.ToString());

            num1.Value = 4;
            num2.Value = 5;
            Assert.Equal("(4 * x) / (5 * x)", exp.ToString());
            Assert.Equal("((2 * 1 * 3 * x) - (2 * x * 3 * 1)) / ((3 * x) ^ 2)", deriv.ToString());
        }
开发者ID:sys27,项目名称:xFunc,代码行数:20,代码来源:DifferentiatorTest.cs

示例5: SubDerivativeTest2

        public void SubDerivativeTest2()
        {
            var num1 = new Number(2);
            var x = new Variable("x");
            var mul1 = new Mul(num1, x);

            var num2 = new Number(3);
            var mul2 = new Mul(num2, x.Clone());

            var exp = new Sub(mul1, mul2);
            var deriv = Differentiate(exp);

            Assert.Equal("(2 * 1) - (3 * 1)", deriv.ToString());

            num1.Value = 5;
            num2.Value = 4;
            Assert.Equal("(5 * x) - (4 * x)", exp.ToString());
            Assert.Equal("(2 * 1) - (3 * 1)", deriv.ToString());
        }
开发者ID:sys27,项目名称:xFunc,代码行数:19,代码来源:DifferentiatorTest.cs

示例6: PowDerivativeTest3

        public void PowDerivativeTest3()
        {
            // x ^ 3
            var x = new Variable("x");
            var num1 = new Number(3);

            var exp = new Pow(x, num1);
            var deriv = Differentiate(exp);

            Assert.Equal("1 * 3 * (x ^ (3 - 1))", deriv.ToString());

            num1.Value = 4;
            Assert.Equal("x ^ 4", exp.ToString());
            Assert.Equal("1 * 3 * (x ^ (3 - 1))", deriv.ToString());

            // 2 ^ (3x)
            var num2 = new Number(2);
            num1 = new Number(3);
            var mul = new Mul(num1, x.Clone());

            exp = new Pow(num2, mul);
            deriv = Differentiate(exp);

            Assert.Equal("ln(2) * (2 ^ (3 * x)) * 3 * 1", deriv.ToString());

            num1.Value = 4;
            Assert.Equal("2 ^ (4 * x)", exp.ToString());
            Assert.Equal("ln(2) * (2 ^ (3 * x)) * 3 * 1", deriv.ToString());
        }
开发者ID:sys27,项目名称:xFunc,代码行数:29,代码来源:DifferentiatorTest.cs

示例7: Variable

        /// <summary>
        /// Differentiates the specified expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="variable">The variable.</param>
        /// <returns>Returns the derivative.</returns>
        protected virtual IExpression Variable(Variable expression, Variable variable)
        {
            if (expression.Equals(variable))
                return new Number(1);

            return expression.Clone();
        }
开发者ID:smwentum,项目名称:xFunc,代码行数:13,代码来源:Differentiator.cs


注:本文中的xFunc.Maths.Expressions.Variable.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。