sample6_8.cs

来自「C#的数值计算的几乎所有算法」· CS 代码 · 共 35 行

CS
35
字号
/*
 * 示例程序Sample6_8: Interpolation类的埃尔米特等距插值
 */

using System;
using CSharpAlgorithm.Algorithm;

namespace CSharpAlgorithm.Sample
{
	class Class1
	{
		[STAThread]
		static void Main(string[] args)
		{
            // 数据
            int n = 10;
            double x0 = 0.10;
            double xstep = 0.10;
            double[] y = {0.904837,0.818731,0.740818,0.670320,0.606531,0.548812,0.496585,0.449329,0.406570,0.367879};
            double[] t = {0.752};

            double[] dy = new double[y.Length];
            for (int i=0; i<y.Length; ++i)
                dy[i]=-y[i];

            // 插值运算
            for (int i=0; i<t.Length; ++i)
            {
                double yt = Interpolation.GetValueHermite(n, x0, xstep, y, dy, t[i]);
                Console.WriteLine("f(" + t[i] + ") = " + yt);
            }		
        }
	}
}

⌨️ 快捷键说明

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