C#,数值计算——插值和外推,分段线性插值(Linear_interp)的计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer

{

/// <summary>

/// 分段线性插值

/// Piecewise linear interpolation object.

/// Construct with x and y vectors, then call interp for interpolated values.

/// </summary>

public class Linear_interp : Base_interp

{

public Linear_interp(double\[\] xv, double\[\] yv) : base(xv, yv0, 2)

{

}

public override double rawinterp(int j, double x)

{

if (xxj == xxj + 1)

{

return yyj;

}

else

{

return yyj + ((x - xxj) / (xxj + 1 - xxj)) * (yyj + 1 - yyj);

}

}

}

}

2 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// 分段线性插值
    /// Piecewise linear interpolation object.
    /// Construct with x and y vectors, then call interp for interpolated values.
    /// </summary>
    public class Linear_interp : Base_interp
    {
        public Linear_interp(double[] xv, double[] yv) : base(xv, yv[0], 2)
        {
        }

        public override double rawinterp(int j, double x)
        {
            if (xx[j] == xx[j + 1])
            {
                return yy[j];
            }
            else
            {
                return yy[j] + ((x - xx[j]) / (xx[j + 1] - xx[j])) * (yy[j + 1] - yy[j]);
            }
        }
    }
}
相关推荐
名字还没想好☜8 小时前
Python f-string 进阶:数字格式化、对齐填充、调试 = 号与嵌套表达式
开发语言·数据库·python·字符串格式化·f-string
.道阻且长.8 小时前
2.LeetCode算法习题讲解--双指针--复写零
算法·leetcode·职场和发展
To_OC10 小时前
LC 438 找到所有字母异位词:暴力超时后,我靠滑动窗口一招搞定
javascript·算法·leetcode
hez201011 小时前
.NET 11 Runtime Async 详解
c#·.net·.net core
一壶浊酒..12 小时前
Scrape Webpack练习
开发语言·javascript·webpack
命运之光12 小时前
【C语言完整代码】就诊信息管理系统
java·c语言·开发语言
命运之光13 小时前
【C语言完整代码】图书管理系统:图书馆场景下的增删改查实战
c语言·开发语言
猿长大人13 小时前
C# | Serilog 新手入门
开发语言·c#·.net·log
Forever Nore13 小时前
学完C语言力扣第一题做不来正常吗
数据结构·算法