C#,数值计算——积分方程与逆理论Quad_matrix的计算方法与源程序

1 文本格式

using System;

namespace Legalsoft.Truffer

{

public class Quad_matrix : UniVarRealMultiValueFun

{

private int n { get; set; }

private double x { get; set; }

public Quad_matrix(double, a)

{

this.n = a.GetLength(0);

double h = Math.PI / (n - 1);

Wwghts w = new Wwghts(h, n, this);

for (int j = 0; j < n; j++)

{

x = j * h;

double\[\] wt = w.weights();

double cx = Math.Cos(x);

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

{

aj, k = wtk * cx * Math.Cos(k * h);

}

++aj, j;

}

}

public double\[\] funk(double y)

{

return kermom(y);

}

public double\[\] kermom(double y)

{

double\[\] w = new double4;

if (y >= x)

{

double d = y - x;

double df = 2.0 * Math.Sqrt(d) * d;

w0 = df / 3.0;

w1 = df * (x / 3.0 + d / 5.0);

w2 = df * ((x / 3.0 + 0.4 * d) * x + d * d / 7.0);

w3 = df * (((x / 3.0 + 0.6 * d) * x + 3.0 * d * d / 7.0) * x + d * d * d / 9.0);

}

else

{

double x2 = x * x;

double x3 = (x2) * x;

double x4 = x2 * x2;

double y2 = y * y;

double d = x - y;

double clog = Math.Log(d);

w0 = d * ((clog) - 1.0);

w1 = -0.25 * (3.0 * x + y - 2.0 * clog * (x + y)) * d;

w2 = (-11.0 * x3 + y * (6.0 * x2 + y * (3.0 * x + 2.0 * y)) + 6.0 * clog * (x3 - y * y2)) / 18.0;

w3 = (-25.0 * x4 + y * (12.0 * x3 + y * (6.0 * x2 + y * (4.0 * x + 3.0 * y))) + 12.0 * clog * (x4 - (y2 * y2))) / 48.0;

}

return w;

}

}

}

2 代码格式

cs 复制代码
using System;

namespace Legalsoft.Truffer
{
    public class Quad_matrix : UniVarRealMultiValueFun
    {
        private int n { get; set; }
        private double x { get; set; }

        public Quad_matrix(double[,] a)
        {
            this.n = a.GetLength(0);
            double h = Math.PI / (n - 1);
            Wwghts w = new Wwghts(h, n, this);
            for (int j = 0; j < n; j++)
            {
                x = j * h;
                double[] wt = w.weights();
                double cx = Math.Cos(x);
                for (int k = 0; k < n; k++)
                {
                    a[j, k] = wt[k] * cx * Math.Cos(k * h);
                }
                ++a[j, j];
            }
        }

        public double[] funk(double y)
        {
            return kermom(y);
        }

        public double[] kermom(double y)
        {
            double[] w = new double[4];
            if (y >= x)
            {
                double d = y - x;
                double df = 2.0 * Math.Sqrt(d) * d;
                w[0] = df / 3.0;
                w[1] = df * (x / 3.0 + d / 5.0);
                w[2] = df * ((x / 3.0 + 0.4 * d) * x + d * d / 7.0);
                w[3] = df * (((x / 3.0 + 0.6 * d) * x + 3.0 * d * d / 7.0) * x + d * d * d / 9.0);
            }
            else
            {
                double x2 = x * x;
                double x3 = (x2) * x;
                double x4 = x2 * x2;
                double y2 = y * y;
                double d = x - y;
                double clog = Math.Log(d);
                w[0] = d * ((clog) - 1.0);
                w[1] = -0.25 * (3.0 * x + y - 2.0 * clog * (x + y)) * d;
                w[2] = (-11.0 * x3 + y * (6.0 * x2 + y * (3.0 * x + 2.0 * y)) + 6.0 * clog * (x3 - y * y2)) / 18.0;
                w[3] = (-25.0 * x4 + y * (12.0 * x3 + y * (6.0 * x2 + y * (4.0 * x + 3.0 * y))) + 12.0 * clog * (x4 - (y2 * y2))) / 48.0;
            }
            return w;
        }
    }
}
相关推荐
君顾19 小时前
本地城市低空经济管理系统定制:城市级低空运营平台架构与落地实战
java·开发语言·飞手
多多鼠10 小时前
System Prompt 的“版本漂移”问题:从变更管理到 A/B 测试体系
开发语言·网络·人工智能·python·langchain
WiChP10 小时前
【V0.1B16】从零开始的2D游戏引擎开发之路
开发语言·算法·游戏引擎
番茄巴士11 小时前
手写一个 mini HashMap,彻底搞懂哈希表原理
算法
孙启超11 小时前
【AI开发之Rust】第 8 课:泛型、trait 与 trait 对象
开发语言·后端·rust
宣宣猪的小花园.11 小时前
【机器学习】过拟合与泛化:模型为什么会“刷题很强、实战失灵”
人工智能·算法·机器学习
INGNIGHT11 小时前
624.数组列表中的最大距离(maximum)
算法·散列表
2501_9336707911 小时前
经营财务岗技能栈拆解:Excel、SQL、BI、预算分析怎么准备
开发语言
Niuguangshuo11 小时前
论文解读:w2v-BERT,把 wav2vec 2.0 和 BERT 合成一根管子的语音 SSL
算法·音视频·语音识别
科技小E11 小时前
国标视频分析平台EasyGBS×自动化AI算法训练服务器DLTM,把通用AI炼成你的现场AI
算法·自动化·音视频