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

📄 xzroots.c

📁 Numerical Recipes in C的源代码
💻 C
字号:
/* Driver for routine zroots */

#include <stdio.h>
#define NRANSI
#include "nr.h"
#include "complex.h"

#define M 4
#define MP1 (M+1)
#define TRUE 1
#define FALSE 0

int main(void)
{
	int i,polish;
	fcomplex roots[MP1];
	static fcomplex a[MP1]={{0.0,2.0},
				{0.0,0.0},
				{-1.0,-2.0},
				{0.0,0.0},
				{1.0,0.0} };

	printf("\nRoots of the polynomial x^4-(1+2i)*x^2+2i\n");
	polish=FALSE;
	zroots(a,M,roots,polish);
	printf("\nUnpolished roots:\n");
	printf("%14s %13s %13s\n","root #","real","imag.");
	for (i=1;i<=M;i++)
		printf("%11d %18.6f %12.6f\n",i,roots[i].r,roots[i].i);
	printf("\nCorrupted roots:\n");
	for (i=1;i<=M;i++)
		roots[i]=RCmul(1+0.01*i,roots[i]);
	printf("%14s %13s %13s\n","root #","real","imag.");
	for (i=1;i<=M;i++)
		printf("%11d %18.6f %12.6f\n",i,roots[i].r,roots[i].i);
	polish=TRUE;
	zroots(a,M,roots,polish);
	printf("\nPolished roots:\n");
	printf("%14s %13s %13s\n","root #","real","imag.");
	for (i=1;i<=M;i++)
		printf("%11d %18.6f %12.6f \n",i,roots[i].r,roots[i].i);
	return 0;
}
#undef NRANSI

⌨️ 快捷键说明

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