Skip to content

Instantly share code, notes, and snippets.

@vlavorini
Created August 17, 2017 15:50
Show Gist options
  • Save vlavorini/1d7baaccc67c71936d10eb3d314cf91e to your computer and use it in GitHub Desktop.
Save vlavorini/1d7baaccc67c71936d10eb3d314cf91e to your computer and use it in GitHub Desktop.
def den(points):
sq_norm=1-np.sum(np.square(points),1) #subtracting from 1 the squared norm of the vectors
expd=np.expand_dims(sq_norm,1) #this operation is needed to obtain a correctly transposed version of the vector
den_all=expd * expd.T #multiply the object by his transpose
return den_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment