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);
        }
    }
}
相关推荐
向宇it1 小时前
【unity小技巧】unity 什么是反射?反射的作用?反射的使用场景?反射的缺点?常用的反射操作?反射常见示例
开发语言·游戏·unity·c#·游戏引擎
九鼎科技-Leo1 小时前
什么是 WPF 中的依赖属性?有什么作用?
windows·c#·.net·wpf
Heaphaestus,RC2 小时前
【Unity3D】获取 GameObject 的完整层级结构
unity·c#
Swift社区2 小时前
LeetCode - #139 单词拆分
算法·leetcode·职场和发展
baivfhpwxf20232 小时前
C# 5000 转16进制 字节(激光器串口通讯生成指定格式命令)
开发语言·c#
直裾3 小时前
Scala全文单词统计
开发语言·c#·scala
Kent_J_Truman3 小时前
greater<>() 、less<>()及运算符 < 重载在排序和堆中的使用
算法
IT 青年3 小时前
数据结构 (1)基本概念和术语
数据结构·算法
Dong雨4 小时前
力扣hot100-->栈/单调栈
算法·leetcode·职场和发展
SoraLuna4 小时前
「Mac玩转仓颉内测版24」基础篇4 - 浮点类型详解
开发语言·算法·macos·cangjie