////////////////////////////////////////////////////////////
//功能介绍:复数类定义
//编译环境:Microsoft Visual C++
//作者:maollm
//时间:2011/11/26
//邮箱:maollm@126.com
////////////////////////////////////////////////////////////
#include "Complex.h"
complex::complex(float r,float i) //带参数的构造函数定义
{
Real = r, Image = i;
}
complex operator*(const complex &a, const complex &b) //复数乘
{
complex temp;
temp.Real = a.Real*b.Real - a.Image*b.Image;
temp.Image = a.Real*b.Image + a.Image*b.Real;
return temp;
}
complex operator+(const complex &a, const complex &b) //复数加
{
complex temp;
temp.Real = a.Real + b.Real;
temp.Image = a.Image + b.Image;
return temp;
}
complex operator-(const complex &a, const complex &b) //复数减
{
complex temp;
temp.Real = a.Real - b.Real;
temp.Image = a.Image - b.Image;
return temp;
}
complex operator/(const complex &a, const complex &b) //复数除
{
complex temp;
temp.Real = (a.Real*b.Real + a.Image*b.Image) / (b.Real*b.Real + b.Image*b.Image);
temp.Image = (a.Image*b.Real - a.Real*b.Image) / (b.Real*b.Real + b.Image*b.Image);
return temp;
}
complex operator*(const complex &a, const float &b) //复数与浮点乘
{
complex temp;
temp.Real = a.Real * b;
temp.Image = a.Image * b;
return temp;
}
complex operator+(const complex &a, const float &b) //复数与浮点加
{
complex temp;
temp.Real = a.Real + b;
temp.Image = a.Image;
return temp;
}
complex operator-(const complex &a, const float &b) //复数与浮点减
{
complex temp;
temp.Real = a.Real - b;
temp.Image = a.Image;
return temp;
}
complex operator/(const complex &a, const float &b) //复数与浮点除
{
complex temp;
temp.Real = a.Real / b;
temp.Image = a.Image / b;
return temp;
}
complex operator-(const complex &a) //复数取负运算
{
return complex(-a.Real, -a.Image);
}
void complex::change_Real_to(float val) //输入实部
{
Real = val;
}
void complex::change_Image_to(float val) //输入虚部
{
Image = val;
}
void complex::output_value() //复数输出
{
cout<<setiosflags(ios::fixed)<<setiosflags(ios::left)<<setprecision(4)
<< Real << " " << Image << "i" << "\n";
}
FFT/IFFT 变换 C++源代码
5星 · 超过95%的资源 60 浏览量
2011-11-29
15:15:46
上传
评论 1
收藏 1.24MB RAR 举报
maolml
- 粉丝: 2
- 资源: 4
最新资源
- 细胞的奇迹:吃出来的免疫力(美亚畅销书!作者的TED演讲播放量超300万次!《谷物大脑》作者、《三联生活周刊》推荐!吃下对的食物,改善你的... (Z-Library).azw3
- 智能手机产品拆解,使用mindmaster打开
- 11111111111111
- 统信系统ARM64依赖openssl-1.0.2版本的libssl.so.10和libcrypto.so.10文件
- 奥比中光python sdk
- 冯超楠17.py
- OCR识别-基于视觉注意力机制Attention实现的OCR识别算法-附项目源码-优质项目实战.zip
- Java 使用蒙特卡洛方法估算PI的近似值(源代码)
- main.cpp
- 电子木鱼小程序源码电子木鱼小程序源码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
前往页