Skip to content
/ nda Public
forked from TRIQS/nda

C++ library for multi-dimensional arrays

License

Notifications You must be signed in to change notification settings

mmorale3/nda

This branch is 13 commits behind TRIQS/nda:1.1.x.

Folders and files

NameName
Last commit message
Last commit date
Jan 25, 2022
Dec 1, 2021
Feb 18, 2022
Mar 2, 2022
Feb 7, 2022
Jan 13, 2022
Sep 30, 2021
Jan 25, 2022
Feb 7, 2022
Aug 31, 2019
Oct 2, 2019
Oct 30, 2020
Feb 7, 2022
Feb 7, 2022
Sep 21, 2019
Jan 25, 2022
Dec 14, 2021
Jul 31, 2020
Feb 7, 2022
Feb 5, 2021

Repository files navigation

build

nda

nda is a C++ library providing an efficient and flexible multi-dimensional array class. It is an essential building-block of the TRIQS project. Some features include

  • coded in C++17/20 using concepts
  • expressions are implemented lazily for maximum performance
  • flexible and lightweight view-types
  • matrix and vector class with BLAS / LAPACK backend
  • easily store and retrieve arrays to and from hdf5 files using h5
  • common mpi functionality using mpi

A prelimenary reference documentation based on Doxygen is provided at triqs.github.io/nda.

Simple Example

#include <nda/nda.hpp>
#include <nda/h5.hpp>

using namespace nda;

int main() {

  // Create array of shape (4,4,4)
  array<long, 3> A(4, 4, 4);

  // Create an array given its data
  array<long, 2> B{{1, 2}, {3, 4}, {5, 6}};

  // Assign
  A() = 0;
  A(0, 1, 2) = 40;

  // Access
  int a = A(0, 1, 2) + B(0, 1);

  // Slicing to a view of shape (3, 2)
  auto V = A(range(0, 3), range(0, 2), 0);

  // Lazy Arithmetic operations
  auto C = V + 2 * B;

  // Algorithms
  min_element(V);
  max_element(V);
  sum(V);

  // write to file
  {
    h5::file file("dat.h5", 'w');
    h5_write(file, "A", A);
  }

  // read from file
  array<long, 3> D;
  {
    h5::file file("dat.h5", 'r');
    h5_read(file, "A", D);
  }

}

For further examples we refer the users to our tests.

About

C++ library for multi-dimensional arrays

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 93.3%
  • CMake 2.9%
  • C 2.0%
  • Python 1.5%
  • Other 0.3%