-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathbuild.py
More file actions
42 lines (27 loc) · 1.16 KB
/
build.py
File metadata and controls
42 lines (27 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pandas as pd
import numpy as np
import math
class complex_number:
def __init__(self,real,imag):
self.real=real
self.imag=imag
def __str__(self):
return '{:d}{:+d}j'.format(self.real,self.imag)
def __add__(self,other):
return complex_number((self.real+other.real),(self.imag+other.imag))
def __sub__(self,other):
return complex_number((self.real-other.real),(self.imag-other.imag))
def __mul__(self,other):
real=((self.real*other.real)-(self.imag*other.imag))
imag=((self.real*other.imag)+(self.imag*other.real))
return complex_number(real,imag)
def __truediv__(self,other):
real=((self.real*other.real)+(self.imag*other.imag))/(other.real**2+other.imag**2)
imag=((self.imag*other.real)-(self.real*other.imag))/(other.real**2+other.imag**2)
return (real,imag)
def abs(self):
return math.sqrt(self.real**2+self.imag**2)
def conjugate(self):
return complex_number(self.real,-(self.imag))
def argument(self):
return math.degrees(math.atan(self.imag/self.real))