gpt4 book ai didi

c# - 从 C# 调用 QuantLib 方法的最佳方法是什么

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:50:40 25 4
gpt4 key购买 nike

我打算在 C# 应用程序 (http://quantlib.org/docs.shtml) 中使用 QuantLib,但我不信任他们的 .NET 转换项目(太不成熟)。

我只需要期权估值部分。

有人在托管应用程序中使用过它吗?最好的方法是什么?

最佳答案

我在类似情况下所做的是将 C++ native dll 实现为 C# 和 C++ 项目之间的适配器。在 C# 中,您可以使用 DllImport 访问您的 dll 接口(interface)。在 dll 中,您可以获得完整的 C++ 接口(interface),但值得将其简化为您在托管站点上的确切需求。

例子:

// in the C++ dll:
extern "C" MY_API void SetInput(double* Values, int Count);

// in C#:
[DllImport("MyStuff.dll")]
public extern static void SetInput(double[] Values, int Count);

关于c# - 从 C# 调用 QuantLib 方法的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16380167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com