⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xwtn.c

📁 Numerical Recipes Software 提供的算法子程序集
💻 C
字号:
/* Driver for routine wtn */
#include <stdio.h>
#include <math.h>
#define NRANSI
#include "nr.h"
#include "nrutil.h"

#define EPS 1.0e-06
#define NX 8
#define NY 16

int main(void)
{
	unsigned long i,j,l,nerror=0,ntot=NX*NY;
	float *a,*aorg;
	static unsigned long ndim[]={0,NX,NY};

	aorg=vector(1,ntot);
	a=vector(1,ntot);
	pwtset(12);
	for (i=1;i<=NX;i++)
		for (j=1;j<=NY;j++) {
			l=i+(j-1)*NX;
			aorg[l]=a[l]=(i == j ? -1.0 : 1.0/sqrt(fabs((float)(i-j))));
		}
	wtn(a,ndim,2,1,pwt);
	/* here, one might set the smallest components to zero, encode and transmit
	the remaining components as a compressed form of the "image" */
	wtn(a,ndim,2,-1,pwt);
	for (l=1;l<=ntot;l++) {
		if (fabs(aorg[l]-a[l]) >= EPS) {
			printf("Compare Error at element %ld\n",l);
			nerror++;
		}
	}
	if (nerror) printf("Number of comparision errors: %ld\n",nerror);
	else printf("transform-inverse transform check OK\n");
	free_vector(a,1,ntot);
	free_vector(aorg,1,ntot);
	return nerror;
}
#undef NRANSI
/* (C) Copr. 1986-92 Numerical Recipes Software . */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -