Created
January 6, 2015 23:47
-
-
Save rohanp/a7d2048954377fa9e2bb to your computer and use it in GitHub Desktop.
Cython Example
This file contains 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
cdef DTYPE_t getEpsilon(int xi, DTYPE_t[:,:] RMSD, DTYPE_t[:] epsilonList, DTYPE_t[:] derivativeEpsilonList, int N): | |
cdef DTYPE_t e,k | |
cdef int i,j,x,y,neighborsLength | |
cdef DTYPE_t[:,:] eigenValues=np.zeros((len(derivativeEpsilonList),N), dtype=DTYPE) | |
cdef DTYPE_t[:,:] neighborsMatrix | |
cdef DTYPE_t[:] A | |
for i,e in enumerate(derivativeEpsilonList): | |
neighbors=[] | |
for j in range(N): | |
if(RMSD[xi,j]<=e+.01): | |
neighbors.append(j) | |
neighborsLength=len(neighbors) | |
if neighborsLength>1: | |
neighborsMatrix=np.zeros((neighborsLength,neighborsLength), dtype=DTYPE) | |
for x in range(neighborsLength): | |
for y in range(neighborsLength): | |
neighborsMatrix[x][y]=RMSD[x,neighbors[y]] | |
A=np.linalg.svd(neighborsMatrix, compute_uv=False) | |
for j,k in enumerate(A): | |
eigenValues[i][j]=k*k | |
else: | |
print "maxEpsilon too small! Try again with a larger maxEpsilon value." | |
return derivativeEpsilonList[i+3] | |
eps= getIntrinsicScaleAndDim(xi,eigenValues, epsilonList, derivativeEpsilonList) | |
return eps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment