数字信号处理算法c语言实现,C语言实现数字信号处理算法.pdf

中国科学技术大学电子工程与信息科学系 多媒体通信实验室 (Copyright 2000 )

附录A C 语言实现数字信号处理算法

附录A1 BC 下复数类型的实现

本部分内容可以在http ://3/dsp/C/ComplexUse.cpp获得。

1、利用BC 提供的复数支持

//BC 中使用复数类型使用示例(Complex Use.Cpp 文件)

#include

#include

int main(void)

{

double x = 3.1, y = 4.2;

complex z = complex(x,y);

cout << "z = "<< z << "\n";

cout << " and imaginary real part = " << imag(z) << "\n";

cout << "z has complex conjugate = " << conj(z) << " \n";

return 0;

}

2、定义复数类,填写相应成员函数

//C 中的复数类型调用时可能不是非常好用,可自己定义复数类(Complex Use.Cpp 文件)

class Complex{

public :

Complex(){}

Complex( float re, float im );

float r(){return real;};

float i(){return imag;};

float mod(){return sqrt(real*real+imag*imag);};

Complex operator+( Complex &other );

Complex operator-( Complex &other );

Complex operator*( Complex &other );

Complex operator/( Complex &other );

private:

float real, imag;

};// Op erator overloaded using a member function

Complex::Complex(float re,float im){

如果您在阅读过程中发现疏漏和错误,请您尽快和编者取得联系 network@ cxh@

中国科学技术大学电子工程与信息科学系 多媒体通信实验室 (Copyright 2000 )

real=re;

imag=im;

};

Complex Complex::operator+( Complex &other ){

return Complex( real + other.real, imag + other.imag );

};

Complex Complex::operator-( Complex &other ){

return Complex( real - other.real, imag - other.imag );

};

Complex Complex::operator*( Complex &other ){

float x,y;

x=real*other.real-imag*other.imag;

y=real*other.imag+imag*other.real;

return Complex( x,y );

};

Complex Complex::operator/( Complex &other ){

float x,y,l;

l=other.real*other.real+other.imag*other.imag;

x=real*other.real+imag*other.imag;

y=other.real*imag-real*other.imag;

x=x/l;

y=y/l;

return Complex(x

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值