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

📄 zplat.cpp

📁 DSP图像处理程序源码
💻 CPP
字号:
// Zplat.cpp: implementation of the CZplat class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Zplat.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CZplat::CZplat()
{
	zero.fitForLen(0);
	top.fitForLen(0);
}

CZplat::~CZplat()
{

}

void CZplat::Empty()
{
	zero.fitForLen(0);
	top.fitForLen(0);
}

void CZplat::InsertTop(complex comp)
{
	top.fitForLenW(top.length+1);
	top.sgnw[top.length-1]=comp;
}

void CZplat::InsertZero(complex comp)
{
	zero.fitForLenW(zero.length+1);
	zero.sgnw[zero.length-1]=comp;
}

complex CZplat::GetResponse(complex comp)
{
	complex response;
	response=1.0;
	int i;
	for (i=0;i<zero.length;i++)
	{
		response=response*(comp-zero.sgnw[i]);
	}
	for (i=0;i<top.length;i++)
	{
		response=response/(comp-top.sgnw[i]);
	}
	return response;
}

double CZplat::GetResponseAbs(complex comp)
{
	complex response;
	response=GetResponse(comp);
	return response.abs();
}

double CZplat::GetResponseAngle(complex comp)
{
	complex response;
	response=GetResponse(comp);
	return arg(response);
}

Dsignal CZplat::GetAllResponseAbs(int N)
{
	Dsignal sgn;
	sgn.fitForLen(N);
	complex comp;
	complex STDi(0,1);
	int i;
	for (i=0;i<N;i++)
	{
		comp=exp(2*M_PI*i/N*STDi);
		sgn.sgnt[i]=GetResponseAbs(comp);
	}
	return sgn;
}

Dsignal CZplat::GetAllResponseAngle(int N)
{
	Dsignal sgn;
	sgn.fitForLen(N);
	complex comp;
	complex STDi(0,1);
	int i;
	for (i=0;i<N;i++)
	{
		comp=exp(2*M_PI*i/N*STDi);
		sgn.sgnt[i]=GetResponseAngle(comp);
	}
	return sgn;
}

Dsignal CZplat::GetAllResponseAbs(void)
{	
	return GetAllResponseAbs(1024);
}

Dsignal CZplat::GetAllResponseAngle(void)
{
	return GetAllResponseAngle(1024);
}

⌨️ 快捷键说明

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