Complex.Addition 操作员
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的数字添加到另一个指定数字,其中至少有一个是复数,另一个可能是双精度实数。
重载
Addition(Complex, Complex) |
添加两个复数。 |
Addition(Complex, Double) |
向双精度实数添加复数。 |
Addition(Double, Complex) |
将双精度实数添加到复数。 |
示例
以下示例演示了复数的加法:
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)
open System.Numerics
let values = [ Complex(12.3, -1.4); Complex(-6.2, 3.1); Complex(8.9, 1.5) ]
for c1 in values do
for c2 in values do
printfn $"{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 运算符允许执行涉及复数的加法运算。 它启用以下代码:
Complex c1 = new Complex(1.2, 2.3);
Complex c2 = new Complex(2.1, 3.2);
Complex c3 = c1 + c2;
let c1 = Complex(1.2, 2.3)
let c2 = Complex(2.1, 3.2)
let 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.PositiveInfinity 或 Double.NegativeInfinity。
不支持自定义运算符的语言可以改为调用 Add 等效的方法组。
接收一双双的 Addition 运算符比接收两个复数的运算符更有效。
Addition(Complex, Complex)
- Source:
- Complex.cs
- Source:
- Complex.cs
- Source:
- Complex.cs
添加两个复数。
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) = System::Numerics::IAdditionOperators<System::Numerics::Complex, System::Numerics::Complex, System::Numerics::Complex>::op_Addition;
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
要添加的第一个复杂值。
- right
- Complex
要添加的第二个复杂值。
返回
left
和 right
的总和。
实现
注解
添加复数、a + bi
和第二个复数 c + di
采用以下形式:
$(a + c) + (b + d)i$
不支持自定义运算符的语言可以改为调用 Complex.Add(Complex, Double) 等效方法。
另请参阅
适用于
Addition(Complex, Double)
- Source:
- Complex.cs
- Source:
- Complex.cs
- Source:
- Complex.cs
向双精度实数添加复数。
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
要添加的复杂值。
- right
- Double
要添加的双精度实值。
返回
left
和 right
的总和作为复数。
注解
添加复数(a + bi
)和实数(可视为复数 c + 0i
)采用以下形式:
$(a + c) + bi$
不支持自定义运算符的语言可以改为调用 Complex.Add(Double, Complex) 等效方法。
另请参阅
适用于
Addition(Double, Complex)
- Source:
- Complex.cs
- Source:
- Complex.cs
- Source:
- Complex.cs
将双精度实数添加到复数。
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
要添加的双精度实值。
- right
- Complex
要添加的复杂值。
返回
left
和 right
的总和作为复数。
注解
添加实数(可视为复数 a + 0i
)和复数(c + di
)采用以下形式:
$(a + c) + di$
不支持自定义运算符的语言可以改为调用 Complex.Add(Double, Complex) 等效方法。