xtensor: N-D arrays in C++

  • NumPy-style API
  • Idiomatic STL-style C++
  • Lazily evaluated

In [ ]:
#include <iostream>

#include "xtensor/xarray.hpp"
#include "xtensor/xio.hpp"
#include "xtensor/xview.hpp"

In [ ]:
xt::xarray<int> arr
  {1, 2, 3, 4, 5, 6, 7, 8, 9};

arr.reshape({3, 3});

arr

Symengine: Symbolic Computing in C++

  • by the creators of Sympy
  • now a possible engine of sympy

In [ ]:
#include <symengine/expression.h>

using SymEngine::Expression;

Rich rendering of mathematical expressions.


In [ ]:
Expression x("x");

auto ex = pow(x + sqrt(Expression(2)), 10);
ex

In [ ]:
expand(ex)

Combining xtensor and Symengine


In [ ]:
#include <xtensor/xarray.hpp>
#include <xtensor/xbuilder.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xview.hpp>

In [ ]:
Expression y("z");

In [ ]:
xt::xarray<int> e = xt::linspace(0.0, 100.0, 6);

In [ ]:
e + y

In [ ]:
#include <xtensor/xreducer.hpp>

In [ ]:
auto s = (e + y) * xt::view(e + y, xt::all(), xt::newaxis());
s

In [ ]:
xt::sum(s)()

In [ ]: