视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
C语言程序设计论文
2025-09-30 20:58:09 责编:小OO
文档
C语言程序设计

快速傅立叶变换

李喜付

  (东北农业大学 工程学院)

  班级 机化0802

姓名 李喜付

   学号 A07070244

    指导教师  范永存

                  快速傅立叶变换

摘要

实现二维快速傅立叶变换,这是第一次通过读程序流程图来设计程序,同时也将借此实例学习C语言实现矩阵的基本操作、复数的基本操作,复习前面所学过的动态内存分配、文件操作、结构指针的函数调用等内容。

关键词 C语言程序设计  傅立叶变换  C语言论文

程序流程图

    

本程序将对二维数组进行正、反快速快速傅立叶变换。

#include

#include

#include

#define PI  3.1415926

Struct  COMPLEX

{

  Float  re;

  Float  im;

}  cplx  , * hfield , * s , * r , * w ;

Int  n , m ;

Int  ln , lm ;

Void  initiate ( ) ;

Void  dfft () ;

Void  rdfft () ;

Void  showresult () ;

Void  fft( int l , int k ) ;

Void reverse ( int t , int k ) ;

Void  w ( int l);

Int  loop ( int l );

Void  conjugate ( ) ;

Void add (struct complex * x , struct complex * y , struct complex * z ) ;

Void sub (struct complex * x , struct complex * y , struct complex * z ) ;

Void mul (struct complex * x , struct complex * y , struct complex * z ) ;

Struct complex *hread (int j , int j );

Void  hwrite ( int i ,int j ,struct complex x ) ;

Void  main ( ) ;

{

Initiate ( ) ;

Printf ( "\\n 原始数据:\\n") ;

Showresult ( ) ;

Getchar ( ) ;

Dfft ( ) ;

Printf ("\\n快速傅立叶变换后的结果:\\n");

Showresult ( ) ;

Getchar ( );

Rdfft ( ) ;

Printf ( "\\n快速傅立叶你变换后的结果:\\n");

Showresult ( );

Getchar ( ) ;

Free ( hfield );

}

Void  initiate ( )

File * df ;

df = fopen ("data.txt" ,"r" ) ;

Fscanf ( df , "%5d", & n ) ;

Fscanf ( df ,"%5d", & m ) ;

If ( ( ln = loop ( n ) )== -1 )

{

Printf ( " 列数不是2的整数次幂 " ) ;

Exit ( 1 ) ;

}

If ( ( lm = loop ( m ) ) == -1 )

{

Printf ( " 行数不是2的整数次幂 " ) ;

Exit ( 1 ) ;

}

Hfield = ( struct complex * ) malloc ( n * m sizeof ( cplx )) ;

If ( fread ( hfield , sizeof ( cplx ) , m * n ,df ) != ( unsigned ) ( m * n ) )

{

If ( feof ( df) ) printf (" premature end of file " ) ;

Else printf ( " file read error " ) ;

}

Fclose ( df ) ;

}

Void dfft ( )

{

Int i , j ;

Int l , k ;

l = n;

k = ln ;

w = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

r = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

s = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

W ( l ) ;

For ( i = 0 ; j < m ; j++ )

For ( j = 0 ; j < n ; j++ ) ;

}

Free ( R) ;

Free ( S) ;

Free ( W) ;

L = m ;

K = lm;

w = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

r = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

s = ( struct complex * ) calloc ( l , sizeof ( cplx ) ) ;

W ( 1 ) ;

For ( i = 0 ; i < n ; i++ )

For ( j = 0 ; j < m ; j++ )

{

S [ j ] .re = hread ( j . i ) re

 S [ j ] .re = hread ( j . i ) im

}

Fft ( l , k ) ;

For ( j = 0; j < m ; j++ ) ;

}

Free ( R ) ;

Free ( S ) ;

Free ( W ) ;

}

Void rdft ( )

{

Conjugate ( ) ;

Dfft ( ) ;

Conjugate () ;

}

Void showresult ()

{

Int  i , j ;

For ( i = 0 ; i < n ; j++ )

{

Printf ( "\\n第%d行\\n ", i )

For ( j = 0 ; j < n ; j++ )

{

If ( j % 4 == 0 ) print (" \\n") ;

Printf ( " ( %5.2f ,%5.2fi )" , hread ( i , j ) , hread ( i , j ) ;

}

}

本实例实现了矩阵、复数及复数矩阵的基本操作,并复习了前面所学过的文件操作、动态内存分配操作等知识点。

参考文献

[1]C语言精彩编程 温海 张友 中国水利水电出版社

[2]贾宇然,应建华,倪春波,等.一种低功耗时钟芯片的设计[J].华中科技大学学报:自然科学版,2003,31(7):25-27

任务要求:

1.C语言程序要求结合本专业应用

2.要有完整的设计任务过程和分析

3.必要的图标说明

4.参考文献

格式:1.题目居中三号宋体

其余五号宋体. 全文3000字左右 单倍行距下载本文

显示全文
专题