NumXX C++ Numerical Computing Library

Library Structure

This small section should act as a map, showing how the project is organised and how to navigate it.

Namespaces

NumXX is organized around a primary numxx namespace, which contains all core functionality. Additional features or specialized components are grouped into sub-namespaces under numxx.
The example below illustrates the typical namespace structure.

/* === Base namespace === */
namespace numxx {
    /* Core functions */
    zeros();
    ones();
    ...

    /* === Sub-namespaces === */
    namespace random {
        randn();
        randint();
        ...
    } // namespace random

    namespace linalg {
        det();
        eig();
        ...
    } // namespace linalg

} // namespace numxx

Please note that these are not the actual function definitions and are shown for explanation purposes only.

Project Layout

NumXX/
    Containers/
        Matrix.hpp
        NArray.hpp
        Shape.hpp
    Core/
        ArrayCreation.hpp
        Complex.hpp
        Constants.hpp
        FileHandling.hpp
        Functions.hpp
        MathOps.hpp
        Misc.hpp
        VecOps.hpp
    Utils/
        Errors.hpp
        FuncUtils.hpp
        LinalgUtils.hpp
        MathFuncUtils.hpp
        StringOps.hpp
        VecOps.hpp
    FFT.hpp
    Linalg.hpp
    NumXX.hpp
    Random.hpp

Following the namespace structure, files are grouped together by hierarchy in the namespace. Here is a brief description of each file and its contents.

Containers:

This exisits within the base numxx namespace and contains the core NumXX types: NArray, Matrix, and Shape. These are the building blocks used to build the rest of the library.

Core:

Contains all the core NumXX functions that exist within the base layer of the numxx namespace. Examples include zeros(), ones(), sin(), cos(), tan(), max(), min(), etc...

Within the Core file, there also exists an implementation of a custom complex class as well as a file containing all the constants. A custom complex type is required because std::complex does not support arithmetic between complex numbers with different underlying types. For example, an expression such as std::complex<int>(1, 1) + std::complex<float>(1, 1) is not allowed, whereas the equivalent operation using numxx::complex is fully supported.
This type flexibility is a core requirement for NumXX, making a custom complex implementation necessary.

Utils:

As the name suggests, this is a folder where all utility functions exist; any utility function used anywhere in the library exists here. These functions are all parts of the numxx::util namespace, with the exception of the custom error classes that exist within numxx::error.

NumXX.hpp:

This is simply the header file that gets included in the main program.

Other:

Each file contains a set of functions exclusive to a numxx sub-namespace. For example, the file FFT.hpp hold functions defined within numxx::fft. A similar pattern is followed with the other files.

The functions included in these files are not essential to core NumXX functionality, hence the separate namespaces.