当前位置: 首页 > news >正文

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, 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]);
            }
        }
    }
}
 

2 代码格式

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]);}}}
}

http://www.lryc.cn/news/237488.html

相关文章:

  • 详细讲解什么是单例模式
  • 在springBoot中同时使用mysql和MongoDB
  • 2023.11.19 hadoop之MapReduce
  • 力扣第841题 钥匙和房间 C++ DFS BFS 附Java代码
  • React 中 react-i18next 切换语言( 项目国际化 )
  • antd design 5 版本 文件上传
  • 【如何学习Python自动化测试】—— 浏览器操作
  • Python编程技巧 – 使用字典
  • el-tree 与table表格联动
  • Leetcode刷题详解——删除并获得点数
  • HTTP四种请求方式,状态码,请求和响应报文
  • Python - Wave2lip 环境配置与 Wave2lip x GFP-GAN 实战 [超详细!]
  • 2311rust,1.31版本更新
  • 文心一言-情感关怀之旅
  • 下厨房网站月度最佳栏目菜谱数据获取及分析PLus
  • buildadmin+tp8表格操作(5)自定义组装搜索的查询
  • 企业级固态硬盘如何稳定运行?永铭固液混合铝电解电容来帮忙
  • 【MISRA C 2012】Rule 4.2 不应该使用三连符
  • spring boot加mybatis puls实现,在新增/修改时,对某些字段进行处理,使用的@TableField()
  • 如何构建风险矩阵?3大注意事项
  • SpringSecurity5|12.实现RememberMe 及 实现原理分析
  • 持续集成交付CICD:Jenkins Sharedlibrary 共享库
  • Linux--网络编程
  • 数据结构 并查集
  • 算法通关村第十六关黄金挑战——求滑动窗口中的最大值(滑动窗口与堆方法、双端队列法和直接比较法)
  • 常见树种(贵州省):009楠木、樟木、桂木种类
  • 全志H616开发版
  • 【Spring boot】RedisTemplate中String、Hash、List设置过期时间
  • Nosql之redis概述及基本操作
  • 使ros1和ros2的bag一直互通