Complex.Subtract 方法

定义

一个指定数减另一个指定数(其中至少有一个是复数,另一个可以是双精度实数),并返回结果。Subtracts a specified number from another specified number, where at least one of them is a complex number, and the other could be a double-precision real number, and returns the result.

重载

Subtract(Double, Complex)

一个双精度实数减一个复数,并返回结果。Subtracts one complex number from a double-precision real number and returns the result.

Subtract(Complex, Double)

一个复数减一个双精度实数,并返回结果。Subtracts one double-precision real number from a complex number and returns the result.

Subtract(Complex, Complex)

从一个复数中减去另一个复数并返回结果。Subtracts one complex number from another and returns the result.

示例

下面的示例从一个复数中减去一个数组中的每个复数:The following example subtracts each complex number in an array from a complex number:

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex c1 = new Complex(4.93, 6.87);
      Complex[] values = { new Complex(12.5, 9.6), 
                           new Complex(4.3, -8.1), 
                           new Complex(-1.9, 7.4), 
                           new Complex(-5.3, -6.6) };

      foreach (var c2 in values)
         Console.WriteLine("{0} - {1} = {2}", c1, c2, 
                           Complex.Subtract(c1, c2));
   }
}
// The example displays the following output:
//       (4.93, 6.87) - (12.5, 9.6) = (-7.57, -2.73)
//       (4.93, 6.87) - (4.3, -8.1) = (0.63, 14.97)
//       (4.93, 6.87) - (-1.9, 7.4) = (6.83, -0.53)
//       (4.93, 6.87) - (-5.3, -6.6) = (10.23, 13.47)
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim c1 As New Complex(4.93, 6.87)
      Dim values() As Complex = { New Complex(12.5, 9.6), 
                                  New Complex(4.3, -8.1), 
                                  New Complex(-1.9, 7.4), 
                                  New Complex(-5.3, -6.6) }

      For Each c2 In values
         Console.WriteLine("{0} - {1} = {2}", c1, c2, 
                           Complex.Subtract(c1, c2))
      Next
   End Sub
End Module
' The example displays the following output:
'       (4.93, 6.87) - (12.5, 9.6) = (-7.57, -2.73)
'       (4.93, 6.87) - (4.3, -8.1) = (0.63, 14.97)
'       (4.93, 6.87) - (-1.9, 7.4) = (6.83, -0.53)
'       (4.93, 6.87) - (-5.3, -6.6) = (10.23, 13.47)

注解

Subtract 方法允许包含复数的减法运算。The Subtract method allows subtraction operations that involve complex numbers.

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

支持自定义运算符的语言也可以使用 Subtraction 等效的运算符组。Languages that support custom operators can use the Subtraction equivalent group of operators too.

接收一个 double 的 Subtract 方法比接收两个复数的方法更有效。The Subtract methods that receive one double are more efficient than the method that receive two Complex numbers.

Subtract(Double, Complex)

一个双精度实数减一个复数,并返回结果。Subtracts one complex number from a double-precision real number and returns the result.

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

参数

left
Double

要被减的双精度实数值(被减数)。The double-precision real value to subtract from (the minuend).

right
Complex

要减去的复值(减数)。The complex value to subtract (the subtrahend).

返回

rightleft 所得的结果(为复数)。The result of subtracting right from left, as a complex number.

注解

复数(c + di)与实数(可视为复数 a + 0 i)的减法采用以下形式:The subtraction of a complex number (c + di) from a real number (which can be regarded as the complex number a + 0i) takes the following form:

(c)-di(a - c) - di

支持自定义运算符的语言也可以使用 Complex.Subtraction(Double, Complex) 等效运算符。Languages that support custom operators can use the Complex.Subtraction(Double, Complex) equivalent operator too.

另请参阅

Subtract(Complex, Double)

一个复数减一个双精度实数,并返回结果。Subtracts one double-precision real number from a complex number and returns the result.

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

参数

left
Complex

要被减的复值(被减数)。The complex value to subtract from (the minuend).

right
Double

要减去的双精度实数值(减数)。The double-precision real value to subtract (the subtrahend).

返回

rightleft 所得的结果(为复数)。The result of subtracting right from left, as a complex number.

注解

某个实数(可以视为复数 c + 0 i)与复数(a + bi)的减法采用以下形式:The subtraction of a real number (which can be regarded as the complex number c + 0i) from a complex number (a + bi) takes the following form:

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

支持自定义运算符的语言也可以使用 Complex.Subtraction(Complex, Double) 等效运算符。Languages that support custom operators can use the Complex.Subtraction(Complex, Double) equivalent operator too.

另请参阅

Subtract(Complex, Complex)

从一个复数中减去另一个复数并返回结果。Subtracts one complex number from another and returns the result.

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

参数

left
Complex

要从中减去的值(被减数)。The value to subtract from (the minuend).

right
Complex

要减去的值(减数)。The value to subtract (the subtrahend).

返回

rightleft 所得的结果。The result of subtracting right from left.

注解

复数 c + di 与其他复数 a + bi 的减法运算采用以下形式:The subtraction of a complex number, c + di, from another complex number, a + bi, takes the following form:

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

支持自定义运算符的语言也可以使用 Complex.Subtraction(Complex, Complex) 等效运算符。Languages that support custom operators can use the Complex.Subtraction(Complex, Complex) equivalent operator too.

另请参阅

适用于