/************************************************ * Test elementary operations on complex numbers * * --------------------------------------------- * * Use: to link with complex2.cpp. * * * * SAMPLE RUN: * * * * Z1=(1.000000,-2.000000) * * Z2=(2.500000,5.750000) * * Z1+Z2=(3.500000,3.750000) * * Z1+Z2 with modulus and phase: * * (5.129571,0.819867) * * Z1 with modulus and phase: * * (2.236068,-1.107149) * * Z2 with modulus and phase: * * (6.269968,1.160669) * * Z1*Z2=(14.000000,0.750000) * * Z1*Z2 with modulus and phase: * * (14.020075,0.053520) * * Z1/Z2 with modulus and phase: * * (0.356631,-2.267818) * * Exp(Z1)=(-1.131204,-2.471727) * * Exp(Z1) with modulus and phase: * * (2.718282,-2.000000) * * ArgSh(Z2)=(2.524586,1.155957) * * * * C++ version by J-P Moreau, Paris. * * (www.jpmoreau.fr) * ************************************************/ #include "complex2.h" void main() { COMPLEX Z1,Z2,Z3; double x,y; x=1; y=-2; AssignXY(&Z1,x,y); x=2.5; y=5.75; AssignXY(&Z2,x,y); AddComplex(&Z3,Z1,Z2); printf("\n Z1="); DisplayComplex(Z1); printf("\n Z2="); DisplayComplex(Z2); printf("\n Z1+Z2="); DisplayComplex(Z3); printf("\n Z1+Z2 with modulus and phase:\n"); printf(" "); DisplayComplexR(Z3); printf("\n Z1 with modulus and phase:\n"); printf(" "); DisplayComplexR(Z1); printf("\n Z2 with modulus and phase:\n"); printf(" "); DisplayComplexR(Z2); MulComplex(&Z3,Z1,Z2); printf("\n Z1*Z2="); DisplayComplex(Z3); printf("\n Z1*Z2 with modulus and phase:\n"); printf(" "); DisplayComplexR(Z3); DivComplex(&Z3,Z1,Z2); printf("\n Z1/Z2 with modulus and Phase:\n"); printf(" "); DisplayComplexR(Z3); ExpComplex(&Z3,Z1); printf("\n Exp(Z1)="); DisplayComplex(Z3); printf("\n Exp(Z1) with modulus and Phase:\n"); printf(" "); DisplayComplexR(Z3); ArgShComplex(&Z3,Z2); printf("\n ArgSh(Z2)="); DisplayComplex(Z3); printf("\n\n"); } //end of file tcomplex.cpp