@@ -5,3 +5,94 @@ Complex class for different operations on complex numbers.
55- This class is essentially for mathematical operations on complex numbers.
66- It is very easy and intuitif to use, as any mathematicain would expect.
77- There is more to come on this class, like power of complex numbers.
8+
9+ ## Installation
10+
11+ Use the package manager [ pip] ( https://pypi.org/project/cmpx/ ) to install cmpx.
12+
13+ ``` bash
14+ pip install foobar
15+ ```
16+
17+ ## Usage
18+ ### Importing Complex class
19+ ``` python
20+ from cmpx.Complex import Complex
21+ ```
22+ ### Different instanciations of Complex class
23+ ``` python
24+ # Instanciation 1
25+ number = Complex() # --> Real = 0, Imaginary = 0
26+ print (number)
27+ # Instanctiation 2
28+ number = Complex(42 ) # --> Real = 42, Imaginary = 0
29+ print (number)
30+ # Instanciation 3
31+ number = Complex(12 , - 3.2 ) # --> Real = 12, Imaginary = -3.2
32+ print (number)
33+ # Instanciation 4
34+ number = Complex(im = 13.2 , re = 5 ) # --> Real = 5, Imaginary = 13.2
35+ print (number)
36+ ```
37+ ### Basic operations
38+ ``` python
39+ num1 = Complex(re = 3 , im = - 2.5 )
40+ num2 = Complex(re = 4.2 , im = 13.2 )
41+ # Summation
42+ print (' ({} ) + ({} ) = {} ' .format(num1, num2, num1 + num2))
43+ # Substraction
44+ print (' ({} ) - ({} ) = {} ' .format(num1, num2, num1 - num2))
45+ # Multiplication
46+ print (' ({} ) * ({} ) = {} ' .format(num1, num2, num1 * num2))
47+ # Division
48+ print (' ({} ) / ({} ) = {} ' .format(num1, num2, num1 / num2))
49+ # Floor division
50+ print (' ({} ) // ({} ) = {} ' .format(num1, num2, num1 // num2))
51+ # # Affecting the result directly on the number
52+ # Summation
53+ print (' ({} ) += ({} )' .format(num1, 2 ), end = ' --> ' )
54+ num1 += 2
55+ print (num1)
56+ # Substraction
57+ print (' ({} ) -= ({} )' .format(num1, num2), end = ' --> ' )
58+ num1 -= num2
59+ print (num1)
60+ # Multiplication
61+ print (' ({} ) *= ({} )' .format(num1, 2 ), end = ' --> ' )
62+ num1 *= 2
63+ print (num1)
64+ # Division
65+ print (' ({} ) /= ({} )' .format(num1, num2), end = ' --> ' )
66+ num1 /= num2
67+ print (num1)
68+ # Floor division
69+ print (' ({} ) //= ({} )' .format(num1, 2 ), end = ' --> ' )
70+ num1 /= 2
71+ print (num1)
72+ # Congugated of a complex number
73+ print (' con({} ) = {} ' .format(num2, num2.con()))
74+ # Module of a complex number
75+ print (' mod({} ) = {} ' .format(num2, num2.mod()))
76+ ```
77+ ### Comparisons of Complex numbers
78+ ``` python
79+ num1 = Complex(im = 3.1 , re = - 5 )
80+ num2 = Complex(im = - 1.5 , re = 0.6 )
81+ # Greater than
82+ if (num1 > num2): print (' ({} ) > ({} )' .format(num1, num2))
83+ # Greater or equal
84+ if (num1 >= num2): print (' ({} ) >= ({} )' .format(num1, num2))
85+ # Less than
86+ if (num1 < num2): print (' ({} ) < ({} )' .format(num1, num2))
87+ # Less or equal
88+ if (num1 <= num2): print (' ({} ) <= ({} )' .format(num1, num2))
89+ # Equal
90+ if (num1 == num2): print (' ({} ) == ({} )' .format(num1, num2))
91+ # Not equal
92+ if (num1 != num2): print (' ({} ) != ({} )' .format(num1, num2))
93+ ```
94+
95+ ## Contributing
96+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
97+
98+ Please make sure to update tests as appropriate.
0 commit comments