⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 complex.c

📁 DSP算法C语言源代码—— TI公司的TMS320C5000
💻 C
字号:
/* complex.c - complex arithmetic functions */#include <math.h>                         /* for MSC and TC/BC, it declares: */                                          /* \ttt{struct complex} and \ttt{cabs()} *//* struct complex {double x, y;}; */      /* uncomment if not MSC or TC/BC */                                          /* uncomment if not MS or TC/BC *//*  double cabs(z) *  complex z; *  { *      return sqrt(z.x * z.x + z.y * z.y); *  }*/typedef struct complex complex;complex cmplx(x, y)                              /* z = cmplx(x,y) = x+jy */double x, y;{       complex z;       z.x = x;  z.y = y;       return z;}complex conjg(z)                                 /* complex conjugate of z=x+jy */complex z;{       return cmplx(z.x, -z.y);                  /* returns z* = x-jy */}complex cadd(a, b)                               /* complex addition */complex a, b;{       return cmplx(a.x + b.x, a.y + b.y);}complex csub(a, b)                               /* complex subtraction */complex a, b;{       return cmplx(a.x - b.x, a.y - b.y);}complex cmul(a, b)                               /* complex multiplication */complex a, b;{       return cmplx(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);}complex rmul(a, z)                               /* multiplication by real */double a;complex z;{       return cmplx(a * z.x, a * z.y);}complex cdiv(a, b)                               /* complex division */complex a, b;{   double D = b.x * b.x + b.y * b.y;   return cmplx((a.x * b.x + a.y * b.y) / D, (a.y * b.x - a.x * b.y) / D);}complex rdiv(z, a)                               /* division by real */complex z;double a;{       return cmplx(z.x / a, z.y / a);}double real(z)                                   /* real part Re(z) */complex z;{       return z.x;}double aimag(z)                                  /* imaginary part Im(z) */complex z;{       return z.y;}complex cexp(z)                                  /* complex exponential */complex z;{       double R = exp(z.x);       return cmplx(R * cos(z.y), R * sin(z.y));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -