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

📄 complex.cpp

📁 Rayleigh 信道的matlab 仿真程序 及论文"A Fast and Accurate Rayleigh Fading Simulator"
💻 CPP
字号:
/* Contains the functions of the class: Complex */
#include "Complex.h"

double abs(Complex c2)
{
      /* Actually returns ABS_SQUARED ... */
  return c2.re*c2.re + c2.im*c2.im;
}


Complex Complex::operator+(Complex c2)
{
  Complex temp;

  temp.re = c2.re + re;
  temp.im = c2.im + im;

  return temp;
}

Complex Complex::operator+=(Complex c2)
{
  re += c2.re;
  im += c2.im;

  return *this;   // *this, is the object that generated the call
}

Complex Complex::operator-(Complex c2)
{
  Complex temp;
 
  temp.re = re - c2.re;
  temp.im = im - c2.im;

  return temp;
}

Complex Complex::operator-=(Complex c2)
{
  re -= c2.re;
  im -= c2.im;

  return *this;   // *this, is the object that generated the call
}

Complex Complex::operator*(Complex c2)
{
  Complex temp;
 
  temp.re = re*c2.re - im*c2.im;
  temp.im = im*c2.re + re*c2.im;

  return temp;
}

Complex Complex::operator*=(Complex c2)
{
  Complex temp;
 
  temp.re = re*c2.re - im*c2.im;
  temp.im = im*c2.re + re*c2.im;

  *this = temp;
  return *this;   // *this, is the object that generated the call
}
 
Complex Complex::operator/(Complex c2)
{
  Complex temp;

  temp.im = c2.re*c2.re + c2.im*c2.im;  // just storing the norm here
  temp.re = (re*c2.re + im*c2.im)/temp.im;
  temp.im = (im*c2.re - re*c2.im)/temp.im;

  return temp;
}

Complex Complex::operator/=(Complex c2)
{
  Complex temp;

  temp.im = c2.re*c2.re + c2.im*c2.im;  // just storing the norm here
  temp.re = (re*c2.re + im*c2.im)/temp.im;
  temp.im = (im*c2.re - re*c2.im)/temp.im;

  *this = temp;
  return *this;
}

Complex Complex::operator=(Complex c2)
{
  re = c2.re;
  im = c2.im;

  return *this;     // *this, is the object that generated the call
}


⌨️ 快捷键说明

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