Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.