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]);
            }
        }
    }
}
相关推荐
shehuiyuelaiyuehao31 分钟前
算法50,分治归并,数组中的逆序对
java·算法
阳明山水1 小时前
校准分位数驱动智能库存决策
人工智能·深度学习·算法·机器学习·架构
Lost of 程序猿1 小时前
用 YARP 为 .NET 微服务搭一座“立交桥“:路由转发与生产配置实践
c#·asp.net
码行山野赴时序归途2 小时前
链表家族收官篇:循环链表
c语言·开发语言·数据结构·链表
景熙55232 小时前
单体项目编写思路和落地形式
java·开发语言
别动我齐刘海2 小时前
ROS2 Jazzy + C++ 实战路线——进阶学习3
c++·人工智能·vscode·python·算法·机器学习·机器人
zhangfeng11332 小时前
《从“人工适配“到“智能生成“:KernelSwift 跨国产芯片算子迁移全栈方案解读》 —— 强调范式跃迁和跨硬件属性,适合偏架构分析的写法
人工智能·算法·华为·ai编程·npu
0+1113 小时前
算法 --滑动窗口
c++·算法·leetcode
计算机毕设定制辅导-无忧学长3 小时前
《基于SpringBoot的未成年人健康知识科普平台的设计与实现》
java·开发语言·vue.js·spring boot·未成年人健康知识科普平台
Ivanqhz3 小时前
Ping-Pong 双缓冲
开发语言·人工智能·python·深度学习·mlir