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;
        }
    }
}
相关推荐
ModelBulider13 分钟前
十三、注解配置SpringMVC
java·开发语言·数据库·sql·mysql
戊子仲秋17 分钟前
【LeetCode】每日一题 2024_11_14 统计好节点的数目(图/树的 DFS)
算法·leetcode·深度优先
V搜xhliang024622 分钟前
基于深度学习的地物类型的提取
开发语言·人工智能·python·深度学习·神经网络·学习·conda
DK七七24 分钟前
多端校园圈子论坛小程序,多个学校同时代理,校园小程序分展示后台管理源码
开发语言·前端·微信小程序·小程序·php
苹果酱056728 分钟前
C语言 char 字符串 - C语言零基础入门教程
java·开发语言·spring boot·mysql·中间件
代码小鑫44 分钟前
A032-基于Spring Boot的健康医院门诊在线挂号系统
java·开发语言·spring boot·后端·spring·毕业设计
昔舍1 小时前
C#笔记(3)
笔记·c#
训山1 小时前
4000字浅谈Java网络编程
java·开发语言·网络
API快乐传递者1 小时前
除了网页标题,还能用爬虫抓取哪些信息?
开发语言·爬虫·python
TaoYuan__2 小时前
机器学习的常用算法
人工智能·算法·机器学习