C#,数值计算——插值和外推,Powvargram的计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer

{

/// <summary>

/// Functor for variogram v(r)=ar^b,

/// where b is specified, a is fitted from the data.

/// </summary>

public class Powvargram

{

private double alph { get; set; }

private double bet { get; set; }

private double nugsq { get; set; }

public Powvargram(double, x, double\[\] y, double beta = 1.5, double nug = 0.0)

{

this.bet = beta;

this.nugsq = nug * nug;

int npt = x.GetLength(0);

int ndim = x.GetLength(1);

double num = 0.0;

double denom = 0.0;

for (int i = 0; i < npt; i++)

{

for (int j = i + 1; j < npt; j++)

{

double rb = 0.0;

for (int k = 0; k < ndim; k++)

{

rb += Globals.SQR(xi, k - xj, k);

}

rb = Math.Pow(rb, 0.5 * beta);

num += rb * (0.5 * Globals.SQR(yi - yj) - nugsq);

denom += Globals.SQR(rb);

}

}

alph = num / denom;

}

public double functorMethod(double r)

{

return nugsq + alph * Math.Pow(r, bet);

}

}

}

2 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// Functor for variogram v(r)=ar^b, 
    /// where b is specified, a is fitted from the data.
    /// </summary>
    public class Powvargram
    {
        private double alph { get; set; }
        private double bet { get; set; }
        private double nugsq { get; set; }

        public Powvargram(double[,] x, double[] y, double beta = 1.5, double nug = 0.0)
        {
            this.bet = beta;
            this.nugsq = nug * nug;

            int npt = x.GetLength(0);
            int ndim = x.GetLength(1);
            double num = 0.0;
            double denom = 0.0;
            for (int i = 0; i < npt; i++)
            {
                for (int j = i + 1; j < npt; j++)
                {
                    double rb = 0.0;
                    for (int k = 0; k < ndim; k++)
                    {
                        rb += Globals.SQR(x[i, k] - x[j, k]);
                    }
                    rb = Math.Pow(rb, 0.5 * beta);
                    num += rb * (0.5 * Globals.SQR(y[i] - y[j]) - nugsq);
                    denom += Globals.SQR(rb);
                }
            }
            alph = num / denom;
        }

        public double functorMethod(double r)
        {
            return nugsq + alph * Math.Pow(r, bet);
        }
    }
}
相关推荐
点心的游戏开发世界23 分钟前
GDScript 入门笔记:目录
开发语言·笔记·游戏引擎·godot
xintaiideas29 分钟前
.NET 项目的多方式启动指南 [特殊字符]
c#
洋不写bug31 分钟前
二叉树(二) 常见基础操作解析|结点数、树高、查找结点、判断完全二叉树
java·开发语言·数据结构·完全二叉树·二叉树结点数·树高·查找结点
果果燕33 分钟前
实习笔记(六)主机按钮状态上报完整流程
开发语言·c++·php
平头哥技术团队1 小时前
Day 16 | 用 ul、ol、li 一个标签,把散资料收成有序的技能清单页
开发语言·前端·html·html5
统计学小王子1 小时前
数学建模国赛倒计时 2 天 ——《统计模型精讲(广义线性模型 R 语言实例 + 分析)》
开发语言·数学建模·r语言
Z5998178411 小时前
c#软件开发学习笔记--WPF(MVVM框架)
笔记·学习·c#
此冬歌咏1 小时前
自动化服务器运维监控系统(python+shell)
linux·运维·服务器·开发语言·python·自动化
wabs6662 小时前
关于二叉树【429.N叉树的层序遍历的思考】
数据结构·c++·算法·leetcode·二叉树
Cx330❀2 小时前
【Linux网络】深入TCP协议:从滑动窗口到拥塞控制与性能优化全景解析
linux·开发语言·网络·tcp/ip·ai·性能优化·ai编程