Welcome to MOCCA’s documentation!#

MOCCA (MOnte Carlo routines for fractional Calculus and linear Algebra) is a parallel C++ template library that focus primarily on the efficient computation of matrix functions using Monte Carlo methods.

Overview#

  • Provides a novel way to calculate matrix functions using Monte Carlo methods.

  • Support for matrices and vectors in both sparse and dense format with user-friend routines to initialize and manipulate these containers.

  • Support for Expression Templates to smartly remove temporaries and enable the lazy evaluation of the matrix expressions. The expression templates also allow developers to write clean and concise code that is very similar to mathematical notation. MOCCA will analyze the expression and then convert it to a highly optimized code.

  • High-performance parallel algorithms with explicit vectorization using the AVX2/AVX512 and OpenMP.

  • Fast random number generators for producing high-quality random samples with support for many different probabilities distributions

  • Integration with highly-optimized BLAS libraries, such as Intel MKL and AMD AOCL

  • Native support for HDF5 files with a simple C++ interface to create, write and read these files.

Examples#

Sum between matrices#

mocca::Matrix<double> A = {{1, 2, 4},
                           {4, 5, 7},
                           {2, 6, 7}};

mocca::Matrix<double> B = {{10, 31,  1},
                           { 1,  0, 10},
                           { 4,  2,  1}};

mocca::Matrix<double> C = 2 * A + B;
fmt::print("{}\n", C);

Broadcast#

mocca::Matrix<int> A = {{1, 2, 4},
                        {4, 5, 7},
                        {2, 6, 7}};

mocca::RowVector<int> v = {10, 31,  1};

mocca::Matrix<int> C = A - v;
fmt::print("{}\n", C);

Sparse row-wise reduction#

mocca::CSRMatrix<int> A (5, 5, 8);
std::vector<mocca::SparseTriplet<int>> triplets = {{0, 1, 5},
                                                   {1, 1, 3},
                                                   {2, 1, 201},
                                                   {3, 3, -1092},
                                                   {4, 1, -2},
                                                   {4, 4, 10}};
A.fill_sorted(triplets.cbegin(), triplets.cend());
mocca::Vector<int> degree = sum(A, mocca::rowwise);
fmt::print("{}\n", degree);

Action of the matrix exponential#

float t = 0.1;
mocca::CSRMatrix<float> A;
mocca::Vector<float> u0;
mocca::io::read_hdf5("test.h5", "A", A, "u0", u0);
mocca::RandFunm<CSRMatrix<float>> monte_carlo(A);

// u = exp(At) v
mocca::Vector<int> u = monte_carlo.funm(mocca::expm, v, t);
fmt::print("{}\n", u);

and many others!

Inspirations#

Contents#