interpolationsmoothisometry.cpp

来自「本代码是《计算机常用数值计算算法与程序 C++版》一书的配套插值代码」· C++ 代码 · 共 36 行

CPP
36
字号
//InterpolationSmoothIsometry  光滑等距插值

#include <iostream.h>			//输入输出流头文件
#include "Interpolation.h"		//插值头文件

void main()
{
	int k(-1);
	double t, x(-1.0), h(0.2);

	double y[11] = 
	{
		0.0384615, 0.0588236, 0.1, 0.2, 0.5, 
		1.0,       0.5,       0.2, 0.1, 0.0588236, 0.0384615
	};

	valarray<double> yy(y,11);
	valarray<double> ss(5);

	cout << " InterpolationSmoothIsometry()" << endl << endl;
	
	t = -0.65;
	cout << " x = " << t;
	InterpolationSmoothIsometry(x, h, yy, k, t, ss);
	cout << "\tf(x) = " << ss[4] << endl;
    cout<<" s0 = "<<ss[0]<<"\ts1 = "<<ss[1]<<"\ts2 = "<<ss[2]<<"\ts3 = "<<ss[3]<<endl;

	t = 0.25;
	cout << endl << " x = " << t;
	InterpolationSmoothIsometry(x, h, yy, k, t, ss);
	cout << "\tf(x) = " << ss[4] << endl;
    cout<<" s0 = "<<ss[0]<<"\ts1 = "<<ss[1]<<"\ts2 = "<<ss[2]<<"\ts3 = "<<ss[3]<<endl;
}


⌨️ 快捷键说明

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