Complex.Addition 运算符

定义

将一个指定数字与另一个指定数字相加,其中至少有一个是复数,另一个可以是双精度实数。Adds a specified number to another specified number, where at least one of them is a complex number, and the other could be a double-precision real number.

重载

Addition(Complex, Complex)

将两个复数相加。Adds two complex numbers.

Addition(Double, Complex)

将一个双精度实数与一个复数相加。Adds a double-precision real number to a complex number.

Addition(Complex, Double)

将一个复数与一个双精度实数相加。Adds a complex number to a double-precision real number.

示例

下面的示例阐释了包含复数的加法:The following example illustrates addition with complex numbers:

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex[] values= { new Complex(12.3, -1.4), 
                          new Complex(-6.2, 3.1), 
                          new Complex(8.9, 1.5) };   
      foreach (var c1 in values)
         foreach (var c2 in values)
            Console.WriteLine("{0} + {1} = {2}", c1, c2, c1 + c2);
   }
}
// The example displays the following output:
//       (12.3, -1.4) + (12.3, -1.4) = (24.6, -2.8)
//       (12.3, -1.4) + (-6.2, 3.1) = (6.1, 1.7)
//       (12.3, -1.4) + (8.9, 1.5) = (21.2, 0.1)
//       (-6.2, 3.1) + (12.3, -1.4) = (6.1, 1.7)
//       (-6.2, 3.1) + (-6.2, 3.1) = (-12.4, 6.2)
//       (-6.2, 3.1) + (8.9, 1.5) = (2.7, 4.6)
//       (8.9, 1.5) + (12.3, -1.4) = (21.2, 0.1)
//       (8.9, 1.5) + (-6.2, 3.1) = (2.7, 4.6)
//       (8.9, 1.5) + (8.9, 1.5) = (17.8, 3)
Imports System.Numerics

Module modMain
   Public Sub Main()
      Dim values() As Complex = { New Complex(12.3, -1.4), 
                                  New Complex(-6.2, 3.1), 
                                  New Complex(8.9, 1.5) }   
      For Each c1 In values
         For Each c2 In values
            Console.WriteLine("{0} + {1} = {2}", c1, c2, c1 + c2)
         Next
      Next      
   End Sub
End Module
' The example displays the following output:
'       (12.3, -1.4) + (12.3, -1.4) = (24.6, -2.8)
'       (12.3, -1.4) + (-6.2, 3.1) = (6.1, 1.7)
'       (12.3, -1.4) + (8.9, 1.5) = (21.2, 0.1)
'       (-6.2, 3.1) + (12.3, -1.4) = (6.1, 1.7)
'       (-6.2, 3.1) + (-6.2, 3.1) = (-12.4, 6.2)
'       (-6.2, 3.1) + (8.9, 1.5) = (2.7, 4.6)
'       (8.9, 1.5) + (12.3, -1.4) = (21.2, 0.1)
'       (8.9, 1.5) + (-6.2, 3.1) = (2.7, 4.6)
'       (8.9, 1.5) + (8.9, 1.5) = (17.8, 3)

注解

Addition 运算符允许执行涉及复数的加法运算。The Addition operator allows performing addition operations that involve complex numbers. 它可以实现如下所示的代码:It enables code such as the following:

Complex c1 = new Complex(1.2, 2.3);
Complex c2 = new Complex(2.1, 3.2);
Complex c3 = c1 + c2;
Dim c1 As New Complex(1.2, 2.3)
Dim c2 As New Complex(2.1, 3.2)
Dim c3 As Complex = c1 + c2

如果加法导致实部或虚部溢出,则该组件的值为 Double.PositiveInfinityDouble.NegativeInfinityIf the addition results in an overflow in either the real or imaginary component, the value of that component is either Double.PositiveInfinity or Double.NegativeInfinity.

不支持自定义运算符的语言可以改为调用 Add 等效的方法组。Languages that do not support custom operators can call the Add equivalent group of methods instead.

接收一个 double 的 Addition 运算符比接收两个复数的运算符更有效。The Addition operators that receive one double are more efficient than the operators that receive two Complex numbers.

Addition(Complex, Complex)

将两个复数相加。Adds two complex numbers.

public:
 static System::Numerics::Complex operator +(System::Numerics::Complex left, System::Numerics::Complex right);
public static System.Numerics.Complex operator + (System.Numerics.Complex left, System.Numerics.Complex right);
static member ( + ) : System.Numerics.Complex * System.Numerics.Complex -> System.Numerics.Complex
Public Shared Operator + (left As Complex, right As Complex) As Complex

参数

left
Complex

要相加的第一个复值。The first complex value to add.

right
Complex

要相加的第二个复值。The second complex value to add.

返回

leftright 的和。The sum of left and right.

注解

加法复数、+ bi 和第二复数 c + di,采用以下形式:The addition of a complex number, a + bi, and a second complex number, c + di, takes the following form:

(a + c) + (b + d) i(a + c) + (b + d)i

不支持自定义运算符的语言可以改为调用 Complex.Add(Complex, Double) 等效的方法。Languages that do not support custom operators can call the Complex.Add(Complex, Double) equivalent method instead.

另请参阅

Addition(Double, Complex)

将一个双精度实数与一个复数相加。Adds a double-precision real number to a complex number.

public:
 static System::Numerics::Complex operator +(double left, System::Numerics::Complex right);
public static System.Numerics.Complex operator + (double left, System.Numerics.Complex right);
static member ( + ) : double * System.Numerics.Complex -> System.Numerics.Complex
Public Shared Operator + (left As Double, right As Complex) As Complex

参数

left
Double

要相加的双精度实数值。The double-precision real value to add.

right
Complex

要相加的复值。The complex value to add.

返回

leftright 之和(为复数)。The sum of left and right as a complex number.

注解

添加实数(可将其视为复数 a + 0 i)和复数(c + di)采用以下形式:The addition of a real number (which can be regarded as the complex number a + 0i) and a complex number (c + di) takes the following form:

(a + c) + di(a + c) + di

不支持自定义运算符的语言可以改为调用 Complex.Add(Double, Complex) 等效的方法。Languages that do not support custom operators can call the Complex.Add(Double, Complex) equivalent method instead.

另请参阅

Addition(Complex, Double)

将一个复数与一个双精度实数相加。Adds a complex number to a double-precision real number.

public:
 static System::Numerics::Complex operator +(System::Numerics::Complex left, double right);
public static System.Numerics.Complex operator + (System.Numerics.Complex left, double right);
static member ( + ) : System.Numerics.Complex * double -> System.Numerics.Complex
Public Shared Operator + (left As Complex, right As Double) As Complex

参数

left
Complex

要相加的复值。The complex value to add.

right
Double

要相加的双精度实数值。The double-precision real value to add.

返回

leftright 之和(为复数)。The sum of left and right as a complex number.

注解

增加复数(a + bi)和实数(可视为复数 c + 0 i)将采用以下形式:The addition of a complex number (a + bi) and a real number (which can be regarded as the complex number c + 0i) takes the following form:

(a + c) + bi(a + c) + bi

不支持自定义运算符的语言可以改为调用 Complex.Add(Double, Complex) 等效的方法。Languages that do not support custom operators can call the Complex.Add(Double, Complex) equivalent method instead.

另请参阅

适用于