|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
Complex, structure
Espace de noms : System.Numerics
Assembly : System.Numerics (dans System.Numerics.dll)
Le type Complex expose les membres suivants.
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | Abs | |
![]() ![]() ![]() ![]() | Acos | |
![]() ![]() ![]() ![]() | Add | |
![]() ![]() ![]() ![]() | Asin | |
![]() ![]() ![]() ![]() | Atan | |
![]() ![]() ![]() ![]() | Conjugate | |
![]() ![]() ![]() ![]() | Cos | |
![]() ![]() ![]() ![]() | Cosh | |
![]() ![]() ![]() ![]() | Divide | |
![]() ![]() ![]() | Equals(Complex) | |
![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() ![]() | Exp | |
![]() ![]() ![]() ![]() | FromPolarCoordinates | |
![]() ![]() ![]() | GetHashCode | |
![]() ![]() ![]() | GetType | |
![]() ![]() ![]() ![]() | Log(Complex) | |
![]() ![]() ![]() ![]() | Log(Complex, Double) | |
![]() ![]() ![]() ![]() | Log10 | |
![]() ![]() ![]() ![]() | Multiply | |
![]() ![]() ![]() ![]() | Negate | |
![]() ![]() ![]() ![]() | Pow(Complex, Double) | |
![]() ![]() ![]() ![]() | Pow(Complex, Complex) | |
![]() ![]() ![]() ![]() | Reciprocal | |
![]() ![]() ![]() ![]() | Sin | |
![]() ![]() ![]() ![]() | Sinh | |
![]() ![]() ![]() ![]() | Sqrt | |
![]() ![]() ![]() ![]() | Subtract | |
![]() ![]() ![]() ![]() | Tan | |
![]() ![]() ![]() ![]() | Tanh | |
![]() ![]() ![]() | ToString() | |
![]() ![]() ![]() | ToString(IFormatProvider) | |
![]() ![]() ![]() | ToString(String) | |
![]() ![]() ![]() | ToString(String, IFormatProvider) |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | Addition | |
![]() ![]() ![]() ![]() | Division | |
![]() ![]() ![]() ![]() | Equality | |
![]() ![]() ![]() ![]() | Explicit(BigInteger to Complex) | |
![]() ![]() ![]() ![]() | Explicit(Decimal to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Byte to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Double to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Int16 to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Int32 to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Int64 to Complex) | |
![]() ![]() ![]() ![]() | Implicit(SByte to Complex) | |
![]() ![]() ![]() ![]() | Implicit(Single to Complex) | |
![]() ![]() ![]() ![]() | Implicit(UInt16 to Complex) | |
![]() ![]() ![]() ![]() | Implicit(UInt32 to Complex) | |
![]() ![]() ![]() ![]() | Implicit(UInt64 to Complex) | |
![]() ![]() ![]() ![]() | Inequality | |
![]() ![]() ![]() ![]() | Multiply | |
![]() ![]() ![]() ![]() | Subtraction | |
![]() ![]() ![]() ![]() | UnaryNegation |
| Nom | Description | |
|---|---|---|
![]() ![]() ![]() ![]() | ImaginaryOne | |
![]() ![]() ![]() ![]() | One | |
![]() ![]() ![]() ![]() | Zero |
Sa grandeur, qui est la distance entre le point et l'origine (autrement dit, 0,0, ou le point auquel l'axe des abscisses et les axe des ordonnées se croisent). Sa phase, qui est l'angle entre le véritable axe et la ligne tirée entre l'origine et le point.
Instanciation d'un nombre complexe
En passant deux valeurs Double à son constructeur. La première valeur représente la vraie partie du nombre complexe, et la deuxième valeur représente sa partie imaginaire. Ces valeurs représentent la position du nombre complexe dans le système de coordonnées cartésien à deux dimensions. En appelant la méthode Complex.FromPolarCoordinates statique (Shared en Visual Basic) pour créer un nombre complexe à partir de ses coordonnées polaires. En assignant une valeur Byte, SByte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single ou Double à un objet Complex. La valeur devient la vraie partie du nombre complexe, et sa partie imaginaire est égale à 0. En castant (en C#) ou convertissant (en Visual Basic) une valeur Decimal ou BigInteger en un objet Complex. La valeur devient la vraie partie du nombre complexe, et sa partie imaginaire est égale à 0. En assignant le nombre complexe retourné par une méthode ou un opérateur à un objet Complex. Par exemple, Complex.Add est une méthode statique qui retourne un nombre complexe qui est la somme de deux nombres complexes, et l'opérateur Complex.Addition ajoute deux nombres complexes et retourne le résultat.
using System; using System.Numerics; public class Example { public static void Main() { // Create a complex number by calling its class constructor. Complex c1 = new Complex(12, 6); Console.WriteLine(c1); // Assign a Double to a complex number. Complex c2 = 3.14; Console.WriteLine(c2); // Cast a Decimal to a complex number. Complex c3 = (Complex) 12.3m; Console.WriteLine(c3); // Assign the return value of a method to a Complex variable. Complex c4 = Complex.Pow(Complex.One, -1); Console.WriteLine(c4); // Assign the value returned by an operator to a Complex variable. Complex c5 = Complex.One + Complex.One; Console.WriteLine(c5); // Instantiate a complex number from its polar coordinates. Complex c6 = Complex.FromPolarCoordinates(10, .524); Console.WriteLine(c6); } } // The example displays the following output: // (12, 6) // (3.14, 0) // (12.3, 0) // (1, 0) // (2, 0) // (8.65824721882145, 5.00347430269914)
Opérations avec des nombres complexes
Méthodes pour comparer deux nombres complexes et déterminer s'ils sont égaux. Opérateurs pour exécuter des opérations arithmétiques sur les nombres complexes. Les opérateurs Complex vous permettent d'effectuer des additions, soustractions, multiplications, divisions et opérations NON unaires avec des nombres complexes. Méthodes pour exécuter d'autres opérations numériques sur les nombres complexes. En plus de quatre opérations arithmétiques fondamentales, vous pouvez élever un nombre complexe à une puissance spécifiée, rechercher la racine carrée d'un nombre complexe et obtenir la valeur absolue d'un nombre complexe. Méthodes pour exécuter des opérations trigonométriques sur les nombres complexes. Par exemple, vous pouvez calculer la tangente d'un angle représentée par un nombre complexe.
Précision et nombres complexes
Complex value = new Complex(Double.MinValue/2, Double.MinValue/2); Complex value2 = Complex.Exp(Complex.Log(value)); Console.WriteLine("{0} \n{1} \nEqual: {2}", value, value2, value == value2); // The example displays the following output: // (-8.98846567431158E+307, -8.98846567431158E+307) // (-8.98846567431161E+307, -8.98846567431161E+307) // Equal: False
Les nombres complexes, Infinity et NaN
using System; using System.Numerics; public class Example { public static void Main() { Complex c1 = new Complex(Double.MaxValue / 2, Double.MaxValue /2); Complex c2 = c1 / Complex.Zero; Console.WriteLine(c2.ToString()); c2 = c2 * new Complex(1.5, 1.5); Console.WriteLine(c2.ToString()); Console.WriteLine(); Complex c3 = c1 * new Complex(2.5, 3.5); Console.WriteLine(c3.ToString()); c3 = c3 + new Complex(Double.MinValue / 2, Double.MaxValue / 2); Console.WriteLine(c3); } } // The example displays the following output: // (NaN, NaN) // (NaN, NaN) // (NaN, Infinity) // (NaN, Infinity)
La division d'un nombre positif par zéro retourne Double.PositiveInfinity. Toute opération qui dépasse la limite supérieure du type de données Double retourne Double.PositiveInfinity. La division d'un nombre négatif par zéro retourne Double.NegativeInfinity. Toute opération qui dépasse la limite inférieure du type de données Double retourne Double.NegativeInfinity. La division d'un zéro par zéro retourne Double.NaN. Toute opération exécutée sur les opérandes dont les valeurs sont Double.PositiveInfinity, Double.NegativeInfinity ou Double.NaN retourne Double.PositiveInfinity, Double.NegativeInfinity ou Double.NaN, selon l'opération.
Mise en forme d'un nombre complexe
using System; using System.Numerics; public class ComplexFormatter :IFormatProvider, ICustomFormatter { public object GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) return this; else return null; } public string Format(string format, object arg, IFormatProvider provider) { if (arg is Complex) { Complex c1 = (Complex) arg; // Check if the format string has a precision specifier. int precision; string fmtString = String.Empty; if (format.Length > 1) { try { precision = Int32.Parse(format.Substring(1)); } catch (FormatException) { precision = 0; } fmtString = "N" + precision.ToString(); } if (format.Substring(0, 1).Equals("I", StringComparison.OrdinalIgnoreCase)) return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "i"; else if (format.Substring(0, 1).Equals("J", StringComparison.OrdinalIgnoreCase)) return c1.Real.ToString(fmtString) + " + " + c1.Imaginary.ToString(fmtString) + "j"; else return c1.ToString(format, provider); } else { if (arg is IFormattable) return ((IFormattable) arg).ToString(format, provider); else if (arg != null) return arg.ToString(); else return String.Empty; } } }
public class Example { public static void Main() { Complex c1 = new Complex(12.1, 15.4); Console.WriteLine("Formatting with ToString(): " + c1.ToString()); Console.WriteLine("Formatting with ToString(format): " + c1.ToString("N2")); Console.WriteLine("Custom formatting with I0: " + String.Format(new ComplexFormatter(), "{0:I0}", c1)); Console.WriteLine("Custom formatting with J3: " + String.Format(new ComplexFormatter(), "{0:J3}", c1)); } } // The example displays the following output: // Formatting with ToString(): (12.1, 15.4) // Formatting with ToString(format): (12.10, 15.40) // Custom formatting with I0: 12 + 15i // Custom formatting with J3: 12.100 + 15.400j
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.


