Template Concepts#

Many of the lower-level classes in MParT are templated to allow for generic implementations. Using templates instead of other programming techniques, like virtual inheritance, makes it simpler to copy these classes to/from a GPU and can sometimes even result in more efficient CPU code. For example, the MonotoneComponent` class, which uses a generic function \(f(x)\) to define a monotone function \(T_d(x)\), is templated on the type of the \(f\) function. It is therefore possible to construct a monotone function from any class defining \(f(x)\), as long as the class contains the functions (i.e., the interface) expected by MonotoneComponent. In the language of generic programming, the necessary interface is a specific concept.

Specific concepts used throughout MParT can be found on the following pages.