The nda library offers efficient and flexible multi-dimensional array classes and associated functionality.
Efficiency is achieved by
- lazy expressions to delay evaluation and to remove redundant temporaries,
- views to access only part of already existing arrays and to avoid unnecessary allocations,
- evaluating expressions as much as possible at compile-time by using type traits and concepts,
- compile-time guarantees that specify the memory layout of arrays and views,
- using optimized libraries like BLAS, LAPACK or MAGMA,
- making use of known symmetries,
- and more.
Flexibility is achieved by
- general memory layouts that allow different strides and stride orders (e.g. C-order vs. Fortran-order),
- memory handles that can manage memory on the heap, the stack and on other devices like GPUs,
- the possibility to specify sizes and shapes at compile-time, at runtime or both,
- simulating Python's
:
and ...
syntax for easy access to slices of an array/view,
- and more.
The following provides a detailed reference documentation grouped into logical units.
If you are looking for a specific function, class, etc., try using the search bar in the top left corner.
Arrays and views
Arrays and views form the backbone of the nda library. The generic array (nda::basic_array) and view (nda::basic_array_view) classes are used to store and access multi-dimensional data and they come with a wide range of operations and functions to manipulate them:
- nda::basic_array is the generic array class in nda. Regular arrays own the memory they use for storing the data. That means they are responsible for managing their memory storage.
- nda::basic_array_view is the generic view class in nda. In contrast to regular arrays, a view does not own the data. This makes it very lightweight and efficient.
- A few Algorithms, similar to the ones found in the standard library header
<algorithm>
, are implemented for arrays and views.
- Arithmetic operations provide the usual arithmetic operations for arrays and views. Note that the behavior of these operations depends on the algebra of the involved objects (see nda::get_algebra). They are all evaluated lazily (with few exceptions).
- Array/View utilities contain type traits, concepts and more functionality related to array and view types.
- Factories and transformations create new array/view objects or transform existing ones.
- HDF5 support allows us to write/read arrays and views to/from HDF5 files.
- MPI support allows us to broadcast, scatter, gather and reduce arrays and views across/over multiple processes using MPI.
- Various Mathematical functions are implemented for arrays and views. They are all evaluated lazily (with few exceptions).
- Symmetries contain tools to use and detect symmetries in nda::Array objects.
- Typedefs provide convenient aliases for the most common array and view types.
CLEF - Compile-time lazy expressions and functions
Compile-time lazy expressions and functions are called lazy because they are not evaluated right away. Instead, they usually return some proxy, i.e. lazy, object which can be used to create new lazy expressions and which can be evaluated whenever the result is actually needed.
- Automatic assignment uses lazy expressions and placeholders to simplify assigning values to multi-dimensional arrays/views and other container like objects.
- CLEF utilities contain various internally used type traits as well as overloads of the
operator<<
to output lazy objects to a std::ostream.
- Evaluation of lazy objects can be done by calling the generic nda::clef::eval function which forwards the evaluation to specialized evaluators.
- Lazy expressions, functions and operations provide the classes that represent these lazy objects and the tools to create them.
- Placeholders are lazy objects that can be used in lazy expressions. When a lazy expression is evaluated, one usually assigns a value to the placeholders which are then plugged into the expression.
Linear algebra
nda offers some Linear algebra related functionality:
- A BLAS interface to parts of the BLAS library to work with arrays and views.
- An LAPACK interface to parts of the LAPACK library to work with arrays and views.
- Some generic Linear algebra tools that wrap the BLAS and LAPACK interfaces to provide a more user-friendly approach for the most common tasks, like matrix-matrix multiplication, matrix-vector multiplication, eigen decompositions, etc.
Memory layout
Memory layout contains tools that allow us to specify how the data of a multi-dimensional array (nda::basic_array) or view (nda::basic_array_view) is laid out in memory and how we can access it in a generic, i.e. independent of the actual memory layout, way.
- Layout policies specify the various layout policies that can be used with nda::basic_array and nda::basic_array_view.
- Layout utilities provide bounds checking,
for_each
functions to loop over multi-dimensional indices, structs that mimic Python's :
and ...
syntax and more.
- Multi-dimensional indexing is used to map multi-dimensional indices to a linear/flat index for a given memory layout and to calculate the resulting memory layout when taking slices of already existing arrays/views.
Memory management
Memory management tools are classes, functions and other definitions that help with the management of different kinds of memory.
In most cases, users shouldn't use any of the memory management tools directly. They are used internally by nda::basic_array and nda::basic_array_view to take care of their memory needs.
However, some advanced users might be interested in the different Memory policies.
Testing tools
Testing tools for checking nda::basic_array and nda::basic_array_view objects with googletest.
Utilities
Utilities contain general Type traits and Concepts as well as Extensions to the standard library and tools to work with Permutations.