Complex.Negate(Complex) 方法

定义

返回指定复数的加法逆元。

public:
 static System::Numerics::Complex Negate(System::Numerics::Complex value);
public static System.Numerics.Complex Negate (System.Numerics.Complex value);
static member Negate : System.Numerics.Complex -> System.Numerics.Complex
Public Shared Function Negate (value As Complex) As Complex

参数

value
Complex

一个复数。

返回

value 参数的 RealImaginary 部分乘以 -1 的结果。

示例

以下示例获取复数数组中每个元素的加法反函数。

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex[] values= { Complex.One,
                          new Complex(-7.1, 2.5),
                          new Complex(1.3, -4.2),
                          new Complex(-3.3, -1.8) };
      foreach (Complex c1 in values)
         Console.WriteLine("{0} --> {1}", c1, Complex.Negate(c1));
   }
}
// The example displays the following output:
//       (1, 0) --> (-1, 0)
//       (-7.1, 2.5) --> (7.1, -2.5)
//       (1.3, -4.2) --> (-1.3, 4.2)
//       (-3.3, -1.8) --> (3.3, 1.8)
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim values() As Complex = { Complex.One, 
                                  New Complex(-7.1, 2.5), 
                                  New Complex(1.3, -4.2), 
                                  New Complex(-3.3, -1.8) }
      For Each c1 In values
         Console.WriteLine("{0} --> {1}", c1, Complex.Negate(c1))
      Next                                    
   End Sub
End Module
' The example displays the following output:
'       (1, 0) --> (-1, 0)
'       (-7.1, 2.5) --> (7.1, -2.5)
'       (1.3, -4.2) --> (-1.3, 4.2)
'       (-3.3, -1.8) --> (3.3, 1.8)

注解

复数的加法反数是一个复数,当将它添加到原始复数时,它会产生 值 Zero 。 此方法返回一个复数,其中原始复数的实数和虚数乘以 -1。

方法 Negate 针对不支持自定义运算符的语言实现。 其行为与使用一元求反运算符 UnaryNegation的求反相同。

适用于

另请参阅