updated top-level README and version_decl for V4.5 (#1847)
[WRF.git] / var / external / wavelet / TestFilter.c
blobfe8865b7e25d2eec27d91bd849bd4a2c548e461a
1 // Author: Aime' Fournier
2 // E-mail: fournier@ucar.edu
4 #include "common.h" // Common definitions and macros.
5 #include "float.h" // Parameters of standard float types.
6 #include "qf.h" // Data structs and function prototypes.
7 #include "stdio.h"
8 #include "stdlib.h"
10 void TestFilter(int nam,int ran,int kinh,int king,pqf *h,pqf *g) {
11 int k,n,ng,nl;
12 real fg=-FLT_MAX,fl=FLT_MAX,fs=0.;
13 real *p;
15 printf("Filter-convolution %s%02d[%d]*%s%02d[%d]:\n",nam,ran,kinh,nam,ran,king);
16 nl=ICH(g->alpha-h->omega); // least n
17 ng=IFH(g->omega-h->alpha); // greatest n
18 p=(real *)calloc(ng-nl+1,sizeof(real));
19 printf("\t%36sn:"," ");
20 for( n=nl; n<=ng; n++ ) printf("%7d",n);
21 printf("\n");
22 for( n=nl; n<=ng; n++ ) {
23 for( k=max(h->alpha,g->alpha-2*n); k<=min(h->omega,g->omega-2*n); k++ )
24 p[n-nl]+=h->f[k]*g->f[k+2*n];
25 if( n==0 && kinh==king ) p[n-nl]--;
26 fl=min(fl,p[n-nl]);
27 fg=max(fg,p[n-nl]);
29 printf("\t%8.1e<orthogonality error<%8.1e:",fl,fg);
30 for( n=nl; n<=ng; n++ ) printf(" %6.1f",p[n-nl]);
31 printf("\n");
32 free(p);