資源簡(jiǎn)介
用C++實(shí)現(xiàn)了快速Hartley變換,這是本人參照R.N.Bracewell的論文寫得
代碼片段和文件信息
/********************************************************************************************
*
*????This?source?is?just?realize?the?Fast?Hartley?Transform?in?C++?and?all?of?algorithms?
* ?are?from?the?paper?“The?Fast?Hartley?Transform“?by?RONALD?N.?BRACEWELL?1984
*
*????Author:?dtcxy
*????Date??:?10-17-2012
*????Mail??:?wysxylq@163.com
*
********************************************************************************************/
#include?
#include?
#include?
#include?
using?namespace?std;
#define?DATA_SIZE??1024
#define?PI?3.14159265359
bool?permutation(double*?data?int?size);???//?just?like?FFT‘s?permutation
void?FHT(double*?data?double*?dataOut?int?size);?????
void?display(double*?data?int?num);
int?isPow2(int?n);
void?inputData(double*?data?int?size);
int?main()
{
cout<<“--------------CPU?FHT----------------“<
double*?data?=?new?double[DATA_SIZE];
double*?dataOut?=?new?double[DATA_SIZE];
memset(data0DATA_SIZE);
memset(dataOut0DATA_SIZE);
inputData(data?DATA_SIZE);
cout<<“source?data:“< display(dataDATA_SIZE);
FHT(data?dataOut?DATA_SIZE);
cout<<“after?FHT:“< display(dataOut?DATA_SIZE);
return?0;
}
/****************************************************************************
*??
*??Subroutine?to?do?fast?Hartley?transform?of?the?array?of?real?numbers??data.
*??size is?the?length?of?the?array.?Note?that?len?should?be?a?power?of?two.
*
*****************************************************************************/
void?FHT(double*?dataIn?double*?dataOut?int?size)
{
double*?fn?=?new?double[size];
double*?Hn?=?new?double[size];
memset(Hn?0?size*sizeof(double));
memcpy(fn?dataIn?size*sizeof(double));
if(?!permutation(?fn?size)?)
{
cout<<“error:?the?number?of?data?is?not?power?of?2“<
評(píng)論
共有 條評(píng)論