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;
        }
    }
}
相关推荐
little redcap2 小时前
第十九次CCF计算机软件能力认证-乔乔和牛牛逛超市
数据结构·c++·算法
吃饭只吃七分饱2 小时前
arm开发板通信
arm开发·c#
AI原吾2 小时前
掌握Python-uinput:打造你的输入设备控制大师
开发语言·python·apython-uinput
机器视觉知识推荐、就业指导2 小时前
Qt/C++事件过滤器与控件响应重写的使用、场景的不同
开发语言·数据库·c++·qt
毕设木哥2 小时前
25届计算机专业毕设选题推荐-基于python的二手电子设备交易平台【源码+文档+讲解】
开发语言·python·计算机·django·毕业设计·课程设计·毕设
珞瑜·2 小时前
Matlab R2024B软件安装教程
开发语言·matlab
weixin_455446172 小时前
Python学习的主要知识框架
开发语言·python·学习
muyierfly2 小时前
34.贪心算法1
算法·贪心算法
孤寂大仙v2 小时前
【C++】STL----list常见用法
开发语言·c++·list
她似晚风般温柔7893 小时前
Uniapp + Vue3 + Vite +Uview + Pinia 分商家实现购物车功能(最新附源码保姆级)
开发语言·javascript·uni-app