home *** CD-ROM | disk | FTP | other *** search
- cxarth(a,b,c,n)
-
- /*this subroutine does complex arithmetic involving
- two complex numbers.
-
- n=1 for addition
- n=2 for subtraction
- n=3 for multiplication
- n=4 for division */
-
- int n;
- float a[],b[],c[];
-
- {
- double g,x,y;
-
- x = b[0];
- y = a[0];
- if(n == 1)
- {
- c[0] = x + y;
- c[1] = a[1] + b[1];
- return;
- }
- if(n == 2)
- {
- c[0] = y - x;
- c[1] = a[1] - b[1];
- return;
- }
- if(n == 3)
- {
- c[0] = y*x - a[1]*b[1];
- c[1] = a[1]*x + y*b[1];
- return;
- }
- if(n == 4)
- {
- g = x*x + b[1]*b[1];
- c[0] = (y*x + a[1]*b[1])/g;
- c[1] = (a[1]*x - y*b[1])/g;
- return;
- }
- c[0] = -99999;
- c[1] = -99999;
- }
-