Complex_jonah_test 1.0.4
dotnet add package Complex_jonah_test --version 1.0.4
NuGet\Install-Package Complex_jonah_test -Version 1.0.4
<PackageReference Include="Complex_jonah_test" Version="1.0.4" />
paket add Complex_jonah_test --version 1.0.4
#r "nuget: Complex_jonah_test, 1.0.4"
// Install Complex_jonah_test as a Cake Addin #addin nuget:?package=Complex_jonah_test&version=1.0.4 // Install Complex_jonah_test as a Cake Tool #tool nuget:?package=Complex_jonah_test&version=1.0.4
Complex numbers
Disclaimer: I'm a first year student, and i have no idea what i'm doing. In addition, the variables are named with a mix of French and English language.
use using Complex_jonah_test;
to import the namespace.
Update
Overrided operators == and !=, you can now check wether 2 Complex objects hold the same values. Override Equals() but not Gethashcode().
How to use
Constructors
use the "Complex()" or "Complex(double x,double y)" to define an object (Complex) variable.
Example
Complex z = new Complex(); // real_number=0 and imaginary_number = 0
or
Complex z = new Complex(5,1.5); //real_number = 5 and imaginary_number=1.5
Return the real or the imaginary number
the class stores these 2 numbers as attributes.
Complex z = new Complex(5,1.5);
Console.WriteLine($"{z.reel} , {z.imaginaire}i");
/*Output
5 , 1.5i */
Converting to string
the class overrides ToString() method, this means you can print the object or convert it into a string without special code.
Complex z = new Complex(1,1);
Complex z1 = new Complex(1,-2);
Console.WriteLine(z);
Console.WriteLine(z1);
/*Output:
1+1i
1-2i */
Algebraic operations
Basic "z+z1+..." will return the sum of 2/multiple Complex objects in a Complex type. You can add (+), subtract(-), multiply(*), divide (/), turn value negative (-z).
Complex z = new Complex(1,1);
Complex z1 = new Complex(1,-2);
Console.WriteLine(z+z1);
/*Output:
2-1i */
Check for equality
You can check if two diffrent objects hold the same or diffrent value.
Complex z = new Complex(5,5);
Complex z1= new Complex(5,5);
Console.WriteLine(z==z1);
Console.WriteLine(z!=z1);
/*Output
True
False */
Mods method (z.Mod() )
Using Pythagoras theorem, we can return the distance to the origin of the point representing the complex number in the complex plane.
Complex z = new Complex(1,0);
Console.WriteLine(z.Mod());
/*Output
1 */
Argument method (z.Arg(string x="rad") )
using Math.ArcTan() to discover the argument. the method takes 2 string inputs: "rad" to return a radiant unit (Default). "deg" to return a degree unit. typing any other string will throw an ArgumentException().
Complex z = new Complex(1,1);
Complex z1 = new Complex(2,5);
Console.WriteLine(z.Arg("deg"));
Console.WriteLine(z1.Arg());
/*Output
45
1.1902899496825317 */
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Overrided operators == and !=, you can know check wether 2 Complex objects hold the same values.
Override Equals() but not Gethashcode().