首页 | 博客群 | 公社 | 专栏 | 论坛 | 图片 | 资讯 | 注册 | 帮助 | 博客联播 | 随机访问
二进制文件的字节顺序问题- -| 回首页 | 2007年索引 | - -弓形虫——孕妇及胎儿的大敌,孕妇不要养狗猫

Hilbert(希尔伯特)变换的算法

关键词希尔伯特                                          

Firefox浏览器介绍
Firefox---重新探索网络
网络浏览器:有竞争才有发展


/******************************************/ 
/*   main.c 
/******************************************/ 
  
#include  
#include  
  
#define N 500 
  
#define sq(X) ((X)*(X)) 
  
int     main() 

        int             i; 
        double          x; 
        double          delta[N]; 
        double          kappa[N]; 
        double          y; 
        double          xmin = -10.; 
        double          xmax = 10.; 
        double          cd = -1.; 
        double          w = 2.; 
        double          h = (xmax - xmin) / N; 
  
        for (i = 0; i < N; i++) 
        { 
                x = 2. * (xmin + i * h - cd) / w; 
                if (x < -1.) 
                        delta[i1] = 0.; 
                else if (x < 1.) 
                        delta[i1] = sqrt(1. - sq(x)); 
                else 
                        delta[i1] = 0.; 
        } 
  
        hilbert(n, delta, kappa); 
  
        for (i = 0; i < N; i++) 
        { 
                x = 2. * (xmin + i * h - cd) / w; 
                if (x < -1.) 
                        y = x + sqrt(sq(x) - 1.); 
                else if (x < 1.) 
                        y = x; 
                else 
                        y = x - sqrt(sq(x) - 1.); 
                (void) printf("%.3f %.3f %.3f %.3f\n", xmin + i * h, delta[i], k 
ppa[i], y); 
        } 
  
        return 0; 

  
/******************************************/ 
/*   hilbert.c 
/******************************************/ 
  
void hilbert(int, double[], double[]); 
  
/******************************************/ 
/*   hilbert.c 
/******************************************/ 
#include  
  
#include "hilbert.h" 
  
#define PI 3.14159265 
  
void hilbert(int n, double delta[], double kappa[]) 

        double d1, d2, d3, d4; 
        int i1, i2; 
  
        for (i1 = 0; i1 < n; i1++) 
        { 
                kappa[i1] = 0.; 
                for (i2 = 1; i2 < n; i2++) 
                { 
                        d1 = (i1+i2< 0.;                          d2 = (i1-i2>=0)? delta[i1-i2]: 0.; 
                        d3 = (i1+i2+1< 0.;                          d4 = (i1-i2-1>=0)? delta[i1-i2-1]: 0.; 
  
                        kappa[i1] -= 0.5 * (d1-d2) / i2 + 0.5 * (d3 - d4) / (i2 
 1); 
                } 
                kappa[i1] /= PI; 
        } 

/*********************************************** 
/*   说明 
/*********************************************** 
  
The Hilbert transform 
This package performs a numerical Hilbert transform. 
Download Compressed tar-file 
or 
hilbert.c and hilbert.h 
  
  
Header file 
The program must include the header file 
#include "hilbert.h" 
/*********************************************** 
/*   说明 
                        kappa[i1] -= 0.5 * (d1-d2) / i2 + 0.5 * (d3 - d4) / (i2 
 1); 
                } 
                kappa[i1] /= PI; 
        } 

/*********************************************** 
/*   说明 
/*********************************************** 
  
The Hilbert transform 
This package performs a numerical Hilbert transform. 
Download Compressed tar-file 
or 
hilbert.c and hilbert.h 
  
  
Header file 
The program must include the header file 
#include "hilbert.h" 
  
and then call hilbert() to perform the transform. 
  
Usage 
If delta and kappa are arrays of n doubles, both arrays are allocated by the mai 
 program. 
The input data are in delta and the call hilbert(n, delta, kappa) will return th 
 Hilbert transform of delta in kappa. 
  
n and delta are not modified. 
  
Compilation 
Compile the package using a C-compiler. 
If you use a makefile and this makefile looks like this 
  
a.out: a.o b.o c.o 
       cc

【作者: 野牦牛】【访问统计:】【2007年06月12日 星期二 20:24】【注册】【打印

搜索

Google

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=6322576

回复

验证码:   
评论内容: