Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Created January 10, 2019 13:45
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/1c92d05bfee556267d164156ac3d56eb to your computer and use it in GitHub Desktop.
Save deque-blog/1c92d05bfee556267d164156ac3d56eb to your computer and use it in GitHub Desktop.
def next_pythagorean_triples(previous):
matrices = np.array(
[[-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]])
next_triples = np.transpose(matrices @ np.transpose(previous))
next_triples = next_triples.reshape((3 * previous.shape[0], previous.shape[1]))
return next_triples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment