# Sundials/ML: Connecting OCaml to the Sundials Numeric Solvers

**Authors:** Timothy Bourke (Inria Paris & \'Ecole normale sup\'erieure, PSL, University), Jun Inoue (National Institute of Advanced Industrial Science and, Technology), Marc Pouzet (Sorbonne Universit\'es, UPMC Univ Paris 06 &, \'Ecole normale sup\'erieure, PSL University & Inria Paris)

arXiv: 1812.11668 · 2019-01-07

## TL;DR

This paper presents a safe and efficient OCaml interface to the Sundials numeric solvers, enabling easier application development with minimal performance overhead.

## Contribution

It introduces a comprehensive OCaml binding to Sundials, addressing data sharing, multiple solver implementations, and error handling with novel techniques.

## Key findings

- OCaml interface incurs less than 50% slowdown compared to C
- The interface supports multiple solver implementations seamlessly
- Memory safety and data sharing are effectively managed

## Abstract

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.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1812.11668/full.md

## Figures

59 figures with captions in the complete paper: https://tomesphere.com/paper/1812.11668/full.md

## References

17 references — full list in the complete paper: https://tomesphere.com/paper/1812.11668/full.md

---
Source: https://tomesphere.com/paper/1812.11668