Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active January 11, 2019 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/50c4d4a592654801dacba9a5464612a6 to your computer and use it in GitHub Desktop.
Save deque-blog/50c4d4a592654801dacba9a5464612a6 to your computer and use it in GitHub Desktop.
#include <xtensor/xtensor.hpp>
#include <xtensor-blas/xlinalg.hpp>
xt::xarray<int> next_pytharogian_triples(xt::xarray<int> const& previous_stage)
{
static const xt::xarray<int> stacked_matrices = {
{ -1, 2, 2 },
{ -2, 1, 2 },
{ -2, 2, 3 },
{ 1, 2, 2 },
{ 2, 1, 2 },
{ 2, 2, 3 },
{ 1, -2, 2 },
{ 2, -1, 2 },
{ 2, -2, 3 }
};
auto shape = previous_stage.shape();
xt::xarray<int> next_three = xt::transpose(xt::linalg::dot(stacked_matrices, xt::transpose(previous_stage)));
next_three.reshape({ 3 * shape[0], shape[1] });
return next_three;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment