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++)

{

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;

}

}

}

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;
        }
    }
}
相关推荐
写个博客11 分钟前
暑假算法日记第二天
算法
ChaITSimpleLove26 分钟前
.NET9 实现排序算法(MergeSortTest 和 QuickSortTest)性能测试
算法·排序算法·.net·benchmarkdotnet·datadog.trace
想躺平的咸鱼干27 分钟前
Volatile解决指令重排和单例模式
java·开发语言·单例模式·线程·并发编程
CVer儿38 分钟前
svd分解求旋转平移矩阵
线性代数·算法·矩阵
Owen_Q1 小时前
Denso Create Programming Contest 2025(AtCoder Beginner Contest 413)
开发语言·算法·职场和发展
·云扬·1 小时前
【Java源码阅读系列37】深度解读Java BufferedReader 源码
java·开发语言
liulilittle2 小时前
C++ i386/AMD64平台汇编指令对齐长度获取实现
c语言·开发语言·汇编·c++
Wilber的技术分享2 小时前
【机器学习实战笔记 14】集成学习:XGBoost算法(一) 原理简介与快速应用
人工智能·笔记·算法·随机森林·机器学习·集成学习·xgboost
Tanecious.2 小时前
LeetCode 876. 链表的中间结点
算法·leetcode·链表
Thomas_YXQ2 小时前
Unity URP法线贴图实现教程
开发语言·unity·性能优化·游戏引擎·unity3d·贴图·单一职责原则