本文整理汇总了C#中ComplexNumber.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ComplexNumber.Add方法的具体用法?C# ComplexNumber.Add怎么用?C# ComplexNumber.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComplexNumber
的用法示例。
在下文中一共展示了ComplexNumber.Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Simple1
public void Simple1()
{
var complexNumber1 = new ComplexNumber(4, 3);
var complexNumber2 = new ComplexNumber(6, 2);
var complexNumber3 = new ComplexNumber(-2, -4);
var complexNumber4 = new ComplexNumber(3, -8);
var complexNumber5 = new ComplexNumber(8, 3);
var resultComplexNumber = complexNumber1.Add(complexNumber2);
Assert.AreEqual(10, resultComplexNumber.Real);
Assert.AreEqual(5, resultComplexNumber.Imaginary);
resultComplexNumber = complexNumber1.Add(complexNumber3);
Assert.AreEqual(2, resultComplexNumber.Real);
Assert.AreEqual(-1, resultComplexNumber.Imaginary);
resultComplexNumber = complexNumber1.Add(complexNumber4);
Assert.AreEqual(7, resultComplexNumber.Real);
Assert.AreEqual(-5, resultComplexNumber.Imaginary);
resultComplexNumber = complexNumber1.Add(complexNumber5);
Assert.AreEqual(12, resultComplexNumber.Real);
Assert.AreEqual(6, resultComplexNumber.Imaginary);
}
示例2: AddExample
public void AddExample()
{
var complexNumber1 = new ComplexNumber(4, 3);
var complexNumber2 = new ComplexNumber(6, 2);
var result = complexNumber1.Add(complexNumber2);
Assert.AreEqual(result.Real, 10);
Assert.AreEqual(result.Imaginary, 5);
}
示例3: ComputeIterationDepthFor
public IterationValue ComputeIterationDepthFor(ComplexNumber z)
{
ComplexNumber c = z;
for (int n = 0; n < _maxIterationDepth; n++)
{
z.MultiplyWith(z);
z.Add(c);
if (z.AbsoluteValueSquared >= _thresholdSquared)
return new IterationValue(n + 1, z.AbsoluteValue);
}
return new IterationValue(_maxIterationDepth, double.MinValue);
}