• 大小: 4KB
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: C/C++
  • 标签: FHT  Hartley  

资源简介

用C++实现了快速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“<

评论

共有 条评论

相关资源