一个小问题,希望你能帮助我。 (为了让我的生活更简单)
最受尊敬的微分方程数值求解器之一是 LSODA,但它是用 Fortran 编写的... ( http://www.netlib.org/odepack/index.html )
似乎没有一个像样的 C# 求解器,而且在 C# 中编写自己的求解器太耗时,特别是当我有非常僵硬的方程时需要解决的问题。
net 的 NAG 库不包含 ODE 求解器(它们缺少 D02 例程)。就“大学侧”图书馆而言就是这样。
然而,NAG 支持建议调用他们的 dll,这对于简单变量来说很好,但让我对它的外部函数和虚拟参数感到相当困惑,这让我放弃了。
这使得 LSODA 仍然是 fortran,但其调用顺序要简单得多 - 所以我想知道,如何将 Odepack(包含 lsoda 例程的求解器)转换为 dll,只需很少的工作,以便可以调用它来自 C#?
(这会让我担心雅可比行列式是一个矩阵,即二维数组。)
具体来说,我想要与 Fortran NAG 库类似的情况,但为我提供对 lsoda 的访问: http://www.nag.co.uk/numeric/csharpinfo.asp
请记住,我是一名数学家 - 所以如果你的回答让我失望,请对我保持耐心。为什么我如此关注 C# - 嗯,这很简单,尤其是当一个人拥有 VisualStudio 2010 时
。非常感谢您提前做出的任何回复。
a little question in which I hope you can help me. (To make my life simpler)
One of the most respected numerical solvers for differential equations is LSODA, however it is written in Fortran... ( http://www.netlib.org/odepack/index.html )
There does not seem to be a decent solver for C#, and writing my own is too time consuming in C#, especially as I have very stiff equations that need to be solved.
The NAG libraries for net do not contain an ODE solver (they lack D02 routines). In terms of "university side" libraries that's it.
However NAG Support suggested calling their dll, which is fine for simple variables, but has me rather perplexed with its external functions and dummy parameters which made me give up.
This leaves LSODA still, which is fortran, but a lot simpler in its calling sequence - so I wonder, how can the Odepack (the solvers that include the lsoda routine) be turned into a dll with little work, so that it may be called from C#?
(Which will leave me worried about the Jacobian, being a matrix, i.e. 2D array.)
Specifically, I would like a situation similar to that with the Fortran NAG library, but instead offering me access to lsoda: http://www.nag.co.uk/numeric/csharpinfo.asp
Please keep in mind that I am a mathematician - so if your responses loose me, please be patient with me. And why am I so focused on C# - well, it is simple, especially when one has VisualStudio 2010.
Many thanks for any responses in advance.
发布评论
评论(2)
SmartMathLibrary 看起来已经死了,但它声称有 ODEPACK 绑定。您还可以查看维基百科的.NET 数值包列表。
如果您对其他语言持开放态度,Python 的 SciPy 库包含与 LSODA 的绑定: 在此处输入链接描述。它可在 Windows 上使用,易于使用,免费,并受到科学界的广泛认可。
SmartMathLibrary looks dead, but it claims to have ODEPACK bindings. You could also check out Wikipedia's List of .NET Numerical Packages.
If you're open to other languages, Python's SciPy library contains a binding to LSODA: enter link description here. It's available on Windows, easy to use, free, and widely embraced by the scientific community.
这不是一个完整的解决方案,但 f2c (Fortran-to-C 转换器)应该能够给出您正在使用 Fortran 源代码中的 C 代码。这至少可能更容易从 C# 开始工作。
免责声明:我从未使用过 f2c 来转换例程,我只使用了其他人转换的一些例程。
It's not a full solution, but f2c (Fortran-to-C converter) should be able to give you working C code from the Fortran source. That might at least be easier to get working from C#.
Disclaimer: I've never used f2c to convert a routine, I've only used some of the routines that someone else converted.