C#,数值计算——多项式插值与外推插值(Poly2D_interp)的计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer

{

/// <summary>

/// Object for two-dimensional polynomial interpolation on a matrix.Construct

/// with a vector of x1 values, a vector of x2 values, a matrix of tabulated

/// function values yij , and integers to specify the number of points to use

/// locally in each direction. Then call interp for interpolated values.

/// </summary>

public class Poly2D_interp

{

private int m { get; set; }

private int n { get; set; }

private int mm { get; set; }

private int nn { get; set; }

private double[,] y { get; set; }

private double[] yv { get; set; }

private Poly_interp x1terp { get; set; } = null;

private Poly_interp x2terp { get; set; } = null;

public Poly2D_interp(double[] x1v, double[] x2v, double[,] ym, int mp, int np)

{

this.m = x1v.Length;

this.n = x2v.Length;

this.mm = mp;

this.nn = np;

this.y = ym;

this.yv = new double[m];

this.x1terp = new Poly_interp(x1v, yv, mm);

this.x2terp = new Poly_interp(x2v, x2v, nn);

}

public double interp(double x1p, double x2p)

{

int i = x1terp.cor > 0 ? x1terp.hunt(x1p) : x1terp.locate(x1p);

int j = x2terp.cor > 0 ? x2terp.hunt(x2p) : x2terp.locate(x2p);

for (int k = i; k < i + mm; k++)

{

// x2terp.yy = (y[k, 0]);

x2terp.yy = Globals.CopyFrom(k, y);

yv[k] = x2terp.rawinterp(j, x2p);

}

return x1terp.rawinterp(i, x1p);

}

}

}

2 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// Object for two-dimensional polynomial interpolation on a matrix.Construct
    /// with a vector of x1 values, a vector of x2 values, a matrix of tabulated
    /// function values yij , and integers to specify the number of points to use
    /// locally in each direction. Then call interp for interpolated values.
    /// </summary>
    public class Poly2D_interp
    {
        private int m { get; set; }
        private int n { get; set; }
        private int mm { get; set; }
        private int nn { get; set; }
        private double[,] y { get; set; }
        private double[] yv { get; set; }
        private Poly_interp x1terp { get; set; } = null;
        private Poly_interp x2terp { get; set; } = null;

        public Poly2D_interp(double[] x1v, double[] x2v, double[,] ym, int mp, int np)
        {
            this.m = x1v.Length;
            this.n = x2v.Length;
            this.mm = mp;
            this.nn = np;
            this.y = ym;
            this.yv = new double[m];
            this.x1terp = new Poly_interp(x1v, yv, mm);
            this.x2terp = new Poly_interp(x2v, x2v, nn);
        }

        public double interp(double x1p, double x2p)
        {
            int i = x1terp.cor > 0 ? x1terp.hunt(x1p) : x1terp.locate(x1p);
            int j = x2terp.cor > 0 ? x2terp.hunt(x2p) : x2terp.locate(x2p);
            for (int k = i; k < i + mm; k++)
            {
                // x2terp.yy = (y[k, 0]);
                x2terp.yy = Globals.CopyFrom(k, y);
                yv[k] = x2terp.rawinterp(j, x2p);
            }
            return x1terp.rawinterp(i, x1p);
        }
    }
}
相关推荐
浮生如梦_1 小时前
Halcon基于laws纹理特征的SVM分类
图像处理·人工智能·算法·支持向量机·计算机视觉·分类·视觉检测
△曉風殘月〆1 小时前
WPF MVVM入门系列教程(二、依赖属性)
c#·wpf·mvvm
励志成为嵌入式工程师3 小时前
c语言简单编程练习9
c语言·开发语言·算法·vim
逐·風3 小时前
unity关于自定义渲染、内存管理、性能调优、复杂物理模拟、并行计算以及插件开发
前端·unity·c#
捕鲸叉4 小时前
创建线程时传递参数给线程
开发语言·c++·算法
A charmer4 小时前
【C++】vector 类深度解析:探索动态数组的奥秘
开发语言·c++·算法
wheeldown4 小时前
【数据结构】选择排序
数据结构·算法·排序算法
观音山保我别报错5 小时前
C语言扫雷小游戏
c语言·开发语言·算法
m0_656974746 小时前
C#中的集合类及其使用
开发语言·c#
九鼎科技-Leo6 小时前
了解 .NET 运行时与 .NET 框架:基础概念与相互关系
windows·c#·.net