C#,数值计算——求解一组m维线性Volterra方程组的计算方法与源程序

本文主要是介绍C#,数值计算——求解一组m维线性Volterra方程组的计算方法与源程序,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1 文本格式

using System;

namespace Legalsoft.Truffer
{
    /// <summary>
    /// 求解一组m维线性Volterra方程组
    /// Solves a set of m linear Volterra equations of the second kind using the
    /// extended trapezoidal rule.On input, t0 is the starting point of the
    /// integration and h is the step size.g(k, t) is a user-supplied function or
    /// functor that returns gk(t), while ak(k, l, t, s) is another user- supplied
    /// function or functor that returns the (k, l) element of the matrix K(t, s). The
    /// solution is returned in f[0..m - 1][0..n - 1], with the corresponding abscissas
    /// in t[0..n - 1], where n-1 is the number of steps to be taken.The value of m is
    /// determined from the row-dimension of the solution matrix f.
    /// </summary>
    public abstract class Volterra
    {
        public abstract double g(int k, double t);

        public abstract double ak(int k, int l, double t1, double t2);

        public void voltra(double t0, double h, double[] t, double[,] f)
        {
            int m = f.GetLength(0);
            int n = f.GetLength(1);
            double[] b = new double[m];
            double[,] a = new double[m, m];

            t[0] = t0;
            for (int k = 0; k < m; k++)
            {
                f[k, 0] = g(k, t[0]);
            }
            for (int i = 1; i < n; i++)
            {
                t[i] = t[i - 1] + h;
                for (int k = 0; k < m; k++)
                {
                    double sum = g(k, t[i]);
                    for (int l = 0; l < m; l++)
                    {
                        sum += 0.5 * h * ak(k, l, t[i], t[0]) * f[l, 0];
                        for (int j = 1; j < i; j++)
                        {
                            sum += h * ak(k, l, t[i], t[j]) * f[l, j];
                        }
                        if (k == l)
                        {
                            a[k, l] = 1.0 - 0.5 * h * ak(k, l, t[i], t[i]);
                        }
                        else
                        {
                            a[k, l] = -0.5 * h * ak(k, l, t[i], t[i]);
                        }
                    }
                    b[k] = sum;
                }

                LUdcmp alu = new LUdcmp(a);
                alu.solve( b,  b);
                for (int k = 0; k < m; k++)
                {
                    f[k, i] = b[k];
                }
            }
        }

    }
}
 

2 代码格式

using System;namespace Legalsoft.Truffer
{/// <summary>/// 求解一组m维线性Volterra方程组/// Solves a set of m linear Volterra equations of the second kind using the/// extended trapezoidal rule.On input, t0 is the starting point of the/// integration and h is the step size.g(k, t) is a user-supplied function or/// functor that returns gk(t), while ak(k, l, t, s) is another user- supplied/// function or functor that returns the (k, l) element of the matrix K(t, s). The/// solution is returned in f[0..m - 1][0..n - 1], with the corresponding abscissas/// in t[0..n - 1], where n-1 is the number of steps to be taken.The value of m is/// determined from the row-dimension of the solution matrix f./// </summary>public abstract class Volterra{public abstract double g(int k, double t);public abstract double ak(int k, int l, double t1, double t2);public void voltra(double t0, double h, double[] t, double[,] f){int m = f.GetLength(0);int n = f.GetLength(1);double[] b = new double[m];double[,] a = new double[m, m];t[0] = t0;for (int k = 0; k < m; k++){f[k, 0] = g(k, t[0]);}for (int i = 1; i < n; i++){t[i] = t[i - 1] + h;for (int k = 0; k < m; k++){double sum = g(k, t[i]);for (int l = 0; l < m; l++){sum += 0.5 * h * ak(k, l, t[i], t[0]) * f[l, 0];for (int j = 1; j < i; j++){sum += h * ak(k, l, t[i], t[j]) * f[l, j];}if (k == l){a[k, l] = 1.0 - 0.5 * h * ak(k, l, t[i], t[i]);}else{a[k, l] = -0.5 * h * ak(k, l, t[i], t[i]);}}b[k] = sum;}LUdcmp alu = new LUdcmp(a);alu.solve( b,  b);for (int k = 0; k < m; k++){f[k, i] = b[k];}}}}
}

这篇关于C#,数值计算——求解一组m维线性Volterra方程组的计算方法与源程序的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/336937

相关文章

C#中async await异步关键字用法和异步的底层原理全解析

《C#中asyncawait异步关键字用法和异步的底层原理全解析》:本文主要介绍C#中asyncawait异步关键字用法和异步的底层原理全解析,本文给大家介绍的非常详细,对大家的学习或工作具有一... 目录C#异步编程一、异步编程基础二、异步方法的工作原理三、代码示例四、编译后的底层实现五、总结C#异步编程

C#TextBox设置提示文本方式(SetHintText)

《C#TextBox设置提示文本方式(SetHintText)》:本文主要介绍C#TextBox设置提示文本方式(SetHintText),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录C#TextBox设置提示文本效果展示核心代码总结C#TextBox设置提示文本效果展示核心代

C#中DrawCurve的用法小结

《C#中DrawCurve的用法小结》本文主要介绍了C#中DrawCurve的用法小结,通常用于绘制一条平滑的曲线通过一系列给定的点,具有一定的参考价值,感兴趣的可以了解一下... 目录1. 如何使用 DrawCurve 方法(不带弯曲程度)2. 如何使用 DrawCurve 方法(带弯曲程度)3.使用Dr

使用C#代码在PDF文档中添加、删除和替换图片

《使用C#代码在PDF文档中添加、删除和替换图片》在当今数字化文档处理场景中,动态操作PDF文档中的图像已成为企业级应用开发的核心需求之一,本文将介绍如何在.NET平台使用C#代码在PDF文档中添加、... 目录引言用C#添加图片到PDF文档用C#删除PDF文档中的图片用C#替换PDF文档中的图片引言在当

详解C#如何提取PDF文档中的图片

《详解C#如何提取PDF文档中的图片》提取图片可以将这些图像资源进行单独保存,方便后续在不同的项目中使用,下面我们就来看看如何使用C#通过代码从PDF文档中提取图片吧... 当 PDF 文件中包含有价值的图片,如艺术画作、设计素材、报告图表等,提取图片可以将这些图像资源进行单独保存,方便后续在不同的项目中使

C#使用SQLite进行大数据量高效处理的代码示例

《C#使用SQLite进行大数据量高效处理的代码示例》在软件开发中,高效处理大数据量是一个常见且具有挑战性的任务,SQLite因其零配置、嵌入式、跨平台的特性,成为许多开发者的首选数据库,本文将深入探... 目录前言准备工作数据实体核心技术批量插入:从乌龟到猎豹的蜕变分页查询:加载百万数据异步处理:拒绝界面

C#数据结构之字符串(string)详解

《C#数据结构之字符串(string)详解》:本文主要介绍C#数据结构之字符串(string),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录转义字符序列字符串的创建字符串的声明null字符串与空字符串重复单字符字符串的构造字符串的属性和常用方法属性常用方法总结摘

C#如何动态创建Label,及动态label事件

《C#如何动态创建Label,及动态label事件》:本文主要介绍C#如何动态创建Label,及动态label事件,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录C#如何动态创建Label,及动态label事件第一点:switch中的生成我们的label事件接着,

C# WinForms存储过程操作数据库的实例讲解

《C#WinForms存储过程操作数据库的实例讲解》:本文主要介绍C#WinForms存储过程操作数据库的实例,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、存储过程基础二、C# 调用流程1. 数据库连接配置2. 执行存储过程(增删改)3. 查询数据三、事务处

C#基础之委托详解(Delegate)

《C#基础之委托详解(Delegate)》:本文主要介绍C#基础之委托(Delegate),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1. 委托定义2. 委托实例化3. 多播委托(Multicast Delegates)4. 委托的用途事件处理回调函数LINQ