Sundials/ML:将OCaml连接到Sundials数值解算器
Sundials/ML: Connecting OCaml to the Sundials Numeric Solvers
摘要:
本文介绍了一个全面的OCaml接口的设计和实施的Sundials库的数值求解器常微分方程,微分代数方程和非线性方程。该接口提供了一个方便和内存安全的替代方案,可以直接从C语言使用日晷,并通过与高级语言功能(如垃圾收集存储管理、代数数据类型和异常)集成来促进应用程序开发。我们的基准测试结果表明,接口开销是可以接受的:OCaml中的标准示例很少比C慢两倍,通常慢50%以下。与Sundials接口的挑战是在OCaml和C之间有效和安全地共享数据结构,通过公共接口支持向量运算和线性求解器的多种实现,以及管理OCaml的调用和错误信号。我们解释了我们如何克服这些困难,使用标准技术的组合,如幻影类型和多态变体,并精心制作的数据表示。
英文摘要:
This paper describes the design and implementation of a comprehensive OCaml interface to the Sundials library of numeric solvers for ordinary differential equations, differential algebraic equations, and non-linear equations. The interface provides a convenient and memory-safe alternative to using Sundials directly from C and facilitates application development by integrating with higher-level language features, like garbage-collected memory management, algebraic data types, and exceptions. Our benchmark results suggest that the interface overhead is acceptable: the standard examples are rarely twice as slow in OCaml than in C, and often less than 50% slower. The challenges in interfacing with Sundials are to efficiently and safely share data structures between OCaml and C, to support multiple implementations of vector operations and linear solvers through a common interface, and to manage calls and error signalling to and from OCaml. We explain how we overcame these difficulties using a combination of standard techniques such as phantom types and polymorphic variants, and carefully crafted data representations.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。