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);
        }
    }
}
相关推荐
波力海苔夹心脆6758 分钟前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
现任明教教主~1 小时前
Thinkphp站群蜘蛛池SaaS系统YanyvSEO含多用户/积分/六大引擎计费/易支付对接
java·开发语言·spring
Zhou1411361 小时前
SpringSecurity_02_授权与高级功能
开发语言·python
千里码aicood2 小时前
基于CART算法的图书分类系统设计与实现
数据库·算法·分类
码匠许师傅2 小时前
【C++三方组件】cpp-httplib:一个头文件起 HTTP 服务
开发语言·c++·http
做cv的小昊2 小时前
【World Model】π0.5:a Vision-Language-Action Model with Open-World Generalization
人工智能·算法·机器学习·大模型·多模态·vla·世界模型
لا معنى له3 小时前
World-In-World: World Models in a Closed-Loop World
算法
小小小小钰儿3 小时前
1.5-Python网络编程
开发语言·网络·python·web安全·计算机·网络安全