public Cplx Substract(Cplx b) { Cplx result = new Cplx(); result.Re = Re - b.Re; result.Im = Im - b.Im; return(result); }
public Cplx Multiply(Cplx b) { Cplx result = new Cplx(); result.Re = Re * b.Re - Im * b.Im; result.Im = Re * b.Im + Im * b.Re; return(result); }
public Cplx Sum(Cplx b) { Cplx result = new Cplx(); result.Re = Re + b.Re; result.Im = Im + b.Im; return(result); }
public Cplx Pow(int power) { Cplx result = new Cplx(); double r = System.Math.Sqrt(Re * Re + Im * Im); double teta = System.Math.Atan(Im / Re); result.Re = (int)(r * power * (System.Math.Cos(teta * power))); result.Im = (int)(r * power * (System.Math.Sin(teta * power))); return(result); }
public void AddTest() { Cplx a = new Cplx() { Re = 10, Imaginari = 20 }; Cplx b = new Cplx() { Re = 1, Imaginari = 2 }; Cplx actual = a.Add(b); Cplx shouldBe = new Cplx() { Re = 11, Imaginari = 22 }; Assert.AreEqual(shouldBe, actual); }