Complex.Abs(Complex) Complex.Abs(Complex) Complex.Abs(Complex) Complex.Abs(Complex) Method

定義

複素数の絶対値 (または大きさ) を取得します。Gets the absolute value (or magnitude) of a complex number.

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

パラメーター

value
Complex Complex Complex Complex

複素数。A complex number.

戻り値

value の絶対値。The absolute value of value.

次の例は、複素数の絶対値を計算しの値に相当することを示します、Magnitudeプロパティ。The following example calculates the absolute value of a complex number and demonstrates that it is equivalent to the value of the Magnitude property.

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex complex1 = new Complex(2.0, 3.0);
      Console.WriteLine("|{0}| = {1:N2}", complex1, Complex.Abs(complex1));
      Console.WriteLine("Equal to Magnitude: {0}", 
                        Complex.Abs(complex1).Equals(complex1.Magnitude)); 
   }
}
// The example displays the following output:
//       |(2, 3)| = 3.60555127546399
//       Equal to Magnitude: True
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim complex1 As New Complex(2.0, 3.0)
      Console.WriteLine("|{0}| = {1:N2}", complex1, Complex.Abs(complex1))
      Console.WriteLine("Equal to Magnitude: {0}", 
                        Complex.Abs(complex1).Equals(complex1.Magnitude)) 
   End Sub
End Module
' The example displays the following output:
'       |(2, 3)| = 3.61
'       Equal to Magnitude: True

注釈

複素数の絶対値はそのMagnitudeプロパティ。The absolute value of a complex number is equivalent to its Magnitude property. 実数値の絶対値を + bi は次のように計算されます。The absolute value of a real number a + bi is calculated as follows:

  • 場合 b = 0 の場合、結果は 0。If b = 0, the result is 0.

  • 場合、>、b、結果は、*Math.Sqrt(1 + b2/a2)。If a > b, the result is a *Math.Sqrt(1 + b2/a2).

  • 場合 b > の結果は b * Math.Sqrt(1 + a2/b2)。If b > a, the result is b * Math.Sqrt(1 + a2/b2).

絶対値を計算の結果、オーバーフローになる場合、メソッドは上記いずれかを返しますDouble.PositiveInfinityまたはDouble.NegativeInfinityします。If the calculation of the absolute value results in an overflow, the method returns either Double.PositiveInfinity or Double.NegativeInfinity. どちらの場合、RealまたはImaginaryプロパティはDouble.NaNし、その他のプロパティがどちらもDouble.PositiveInfinityDouble.NegativeInfinity、メソッドを返しますDouble.NaNIf either the Real or Imaginary property is Double.NaN and the other property is neither Double.PositiveInfinity nor Double.NegativeInfinity, the method returns Double.NaN.

適用対象

こちらもご覧ください