Last active
January 11, 2019 11:09
-
-
Save deque-blog/50c4d4a592654801dacba9a5464612a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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