本文整理汇总了C#中xFunc.Maths.Expressions.Mul类的典型用法代码示例。如果您正苦于以下问题:C# Mul类的具体用法?C# Mul怎么用?C# Mul使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mul类属于xFunc.Maths.Expressions命名空间,在下文中一共展示了Mul类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteTest4
public void ExecuteTest4()
{
var exp = new Mul(new Number(2), new ComplexNumber(3, 2));
var expected = new Complex(6, 4);
Assert.Equal(expected, exp.Execute());
}
示例2: 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());
}
示例3: ExecuteTest6
public void ExecuteTest6()
{
var exp = new Mul(new Number(2), new Sqrt(new Number(-9)));
var expected = new Complex(0, 6);
Assert.Equal(expected, exp.Execute());
}
示例4: ExecuteTest2
public void ExecuteTest2()
{
var exp = new Mul(new ComplexNumber(2, 5), new ComplexNumber(3, 2));
var expected = new Complex(-4, 19);
Assert.Equal(expected, exp.Execute());
}
示例5: ExecuteTest3
public void ExecuteTest3()
{
var exp = new Mul(new ComplexNumber(2, 5), new Number(2));
var expected = new Complex(4, 10);
Assert.Equal(expected, exp.Execute());
}
示例6: DerivativeTest1
public void DerivativeTest1()
{
IExpression exp = new Mul(new Number(2), new Variable("x"));
IExpression deriv = exp.Differentiate();
Assert.AreEqual("2 * 1", deriv.ToString());
}
示例7: PartialDerivativeTest4
public void PartialDerivativeTest4()
{
// (x + 1) * (3 + x)
IExpression exp = new Mul(new Add(new Variable("x"), new Number(1)), new Add(new Number(3), new Variable("x")));
IExpression deriv = exp.Differentiate(new Variable("y"));
Assert.AreEqual("0", deriv.ToString());
}
示例8: MultiOpMulMul
public void MultiOpMulMul()
{
// ({1, 2, 3} * 2) * 4
var vector = new Vector(new[] { new Number(1), new Number(2), new Number(3) });
var mul1 = new Mul(vector, new Number(2));
var mul2 = new Mul(mul1, new Number(4));
var expected = new Vector(new[] { new Number(8), new Number(16), new Number(24) });
var result = mul2.Calculate();
Assert.AreEqual(expected, result);
}
示例9: MultiOpAddMul
public void MultiOpAddMul()
{
// ({2, 3, 4} + {1, 2, 3}) * 4
var vector1 = new Vector(new[] { new Number(1), new Number(2), new Number(3) });
var vector2 = new Vector(new[] { new Number(2), new Number(3), new Number(4) });
var add = new Add(vector2, vector1);
var mul = new Mul(add, new Number(4));
var expected = new Vector(new[] { new Number(12), new Number(20), new Number(28) });
var result = mul.Execute();
Assert.Equal(expected, result);
}
示例10: MultiOpMulAdd
public void MultiOpMulAdd()
{
// ({1, 2, 3} * 4) + {2, 3, 4}
var vector1 = new Vector(new[] { new Number(1), new Number(2), new Number(3) });
var vector2 = new Vector(new[] { new Number(2), new Number(3), new Number(4) });
var mul = new Mul(vector1, new Number(4));
var add = new Add(mul, vector2);
var expected = new Vector(new[] { new Number(6), new Number(11), new Number(16) });
var result = add.Calculate();
Assert.AreEqual(expected, result);
}
示例11: DerivativeTest3
public void DerivativeTest3()
{
Number num = new Number(2);
Variable x = new Variable("x");
Mul mul = new Mul(num, x);
IExpression exp = new Tan(mul);
IExpression deriv = exp.Differentiate();
Assert.AreEqual("(2 * 1) / (cos(2 * x) ^ 2)", deriv.ToString());
num.Value = 5;
Assert.AreEqual("tan(5 * x)", exp.ToString());
Assert.AreEqual("(2 * 1) / (cos(2 * x) ^ 2)", deriv.ToString());
}
示例12: AbsDerivativeTest2
public void AbsDerivativeTest2()
{
Number num = new Number(2);
Variable x = new Variable("x");
Mul mul = new Mul(num, x);
IExpression exp = new Abs(mul);
IExpression deriv = Differentiate(exp);
Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());
num.Value = 3;
Assert.AreEqual("abs(3 * x)", exp.ToString());
Assert.AreEqual("(2 * 1) * ((2 * x) / abs(2 * x))", deriv.ToString());
}
示例13: AbsDerivativeTest2
public void AbsDerivativeTest2()
{
var num = new Number(2);
var x = new Variable("x");
var mul = new Mul(num, x);
var exp = new Abs(mul);
var deriv = Differentiate(exp);
Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());
num.Value = 3;
Assert.Equal("abs(3 * x)", exp.ToString());
Assert.Equal("2 * 1 * ((2 * x) / abs(2 * x))", deriv.ToString());
}
示例14: EqualsTest1
public void EqualsTest1()
{
Variable x1 = "x";
Number num1 = 2;
Mul mul1 = new Mul(num1, x1);
Abs abs1 = new Abs(mul1);
Variable x2 = "x";
Number num2 = 2;
Mul mul2 = new Mul(num2, x2);
Abs abs2 = new Abs(mul2);
Assert.IsTrue(abs1.Equals(abs2));
Assert.IsTrue(abs1.Equals(abs1));
}
示例15: DerivativeTest3
public void DerivativeTest3()
{
// exp(2x)
Number num = new Number(2);
Variable x = new Variable("x");
Mul mul = new Mul(num, x);
IExpression exp = new Exp(mul);
IExpression deriv = exp.Differentiate();
Assert.AreEqual("(2 * 1) * exp(2 * x)", deriv.ToString());
num.Value = 6;
Assert.AreEqual("exp(6 * x)", exp.ToString());
Assert.AreEqual("(2 * 1) * exp(2 * x)", deriv.ToString());
}