Last active
August 17, 2017 14:30
-
-
Save vlavorini/922f1e581fae69925d59f12971726fd7 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
def num(points): | |
expd=np.expand_dims(points,2) #need another dimension... | |
tiled=np.tile(expd, points.shape[0]) #...to tile up the vectors | |
trans=np.transpose(points) #Also need to transpose the points matrix to fit well with broadcasting | |
diff=trans-tiled #doing the difference, exploiting Numpy broadcasting capabilities | |
num=np.sum(np.square(diff), axis=1) #an then obtain the squared norm of the difference | |
return num |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment