Sitelet https://github.com/correaa/boost-multi
Skip to content

Latest commit

 

History

16,577 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Boost.Multi

Boost.Multi provides owning multidimensional arrays containers and non-owning multidimensional views for C++17. It supports slicing, layout transformations, and CPU/GPU memory.

Project status: Boost.Multi is not an official or accepted Boost library. It is being proposed for inclusion in Boost and has no Boost-library dependencies.

© Alfredo A. Correa, 2018–2026

Why Boost.Multi?

  • Generic element type and dimensionality
  • Natural multidimensional access: write A[i][j]... or iterate recursively over rows, subarrays or elements.
  • Composable subarray views: slice, transpo se, rotate indices, and broadcast arrays without copying their elements.
  • Interoperability: use standard algorithms (iterators and ranges), allocators, and legacy libraries for strided arrays (BLAS, FFTW, CUDA, HIP, MPI, etc.)

Quick start

git clone https://github.com/correaa/boost-multi.git  # or gitlab.com/correaa/boost-multi.git
cd boost-multi
cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure

Read the documentation or explore test/.

First array and view

#include <cassert>
#include <multi/array.hpp>

namespace multi = boost::multi;

int main() {
    multi::array<int, 2> A = {
        {1, 2, 3},
        {4, 5, 6}
    };

    assert(A[1][1] == 5);  // ordinary multidimensional indexing

    using multi::_;
    auto&& second_column = A(_, 1);  // a non-owning view
    second_column[0] = 20;           // changes A[0][1]
    assert(A[0][1] == 20);
}

Learn about Multi

Use Boost.Multi

Try the library online with Godbolt's Compiler Explorer.

Header-only

Add the repository's include/ directory to your compiler's include path and include the headers you need:

#include <multi/array.hpp>

Alternatively, download the single amalgamated header and include it as #include <boost-multi.hpp>.

CMake: in-tree source

Add Multi from an in-tree source directory and link its interface target:

add_subdirectory(path/to/boost-multi)
target_link_libraries(my_target PRIVATE multi)

CMake: FetchContent

Fetch Multi on demand:

include(FetchContent)
FetchContent_Declare(multi GIT_REPOSITORY https://gitlab.com/correaa/boost-multi.git)
FetchContent_MakeAvailable(multi)
target_link_libraries(my_target PRIVATE multi)

Testing

Testing requires Boost.Test. For example, install libboost-test-dev on Debian/Ubuntu or boost-devel on Fedora.

cmake -S . -B build
cmake --build build
ctest --test-dir build --output-on-failure

Support

About

Multidimensional arrays for C++. (Not an official Boost library) \\ This is a mirror of gitlab.com/correaa/boost-multi

Topics

Resources

Stars

24 stars

Watchers

4 watching

Forks

Releases

Packages

Used by

Contributors

Languages