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;
        }
    }
}
相关推荐
weixin_4461224614 分钟前
LinkedList剖析
算法
就是有点傻21 分钟前
在C#中,可以不实例化一个类而直接调用其静态字段
c#
软件黑马王子21 分钟前
C#系统学习第八章——字符串
开发语言·学习·c#
阿蒙Amon22 分钟前
C#读写文件:多种方式详解
开发语言·数据库·c#
Da_秀31 分钟前
软件工程中耦合度
开发语言·后端·架构·软件工程
Fireworkitte37 分钟前
Java 中导出包含多个 Sheet 的 Excel 文件
java·开发语言·excel
百年孤独_1 小时前
LeetCode 算法题解:链表与二叉树相关问题 打打卡
算法·leetcode·链表
就是有点傻1 小时前
C#如何实现中英文快速切换
数据库·c#
AI数据皮皮侠2 小时前
中国区域10m空间分辨率楼高数据集(全国/分省/分市/免费数据)
大数据·人工智能·机器学习·分类·业界资讯
我爱C编程2 小时前
基于拓扑结构检测的LDPC稀疏校验矩阵高阶环检测算法matlab仿真
算法·matlab·矩阵·ldpc·环检测