Last active
August 29, 2015 14:05
-
-
Save alexsavio/6ccb367f3583e65aa5b4 to your computer and use it in GitHub Desktop.
One liner for loop on upper diagonal indices of a square matrix (n_elems X n_elems) (k=0 to include the diagonal)
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
import numpy as np | |
for x_idx, y_idx in zip(*np.triu_indices(n_elems, k=1)): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment