def laplace(f, g_inv, g_det, X):
 r = 0
 for i in range(len(X)):
  for j in range(len(X)):
   r += (g_inv[(i, j)] * f.diff(X[i]).diff(X[j]))
 for sigma in range(len(X)):
  for alpha in range(len(X)):
   r += (((g_det.diff(X[sigma]) * g_inv[(sigma, alpha)]) * f.diff(X[alpha])) / (2 * g_det))
 return r

def laplace ( f , g_inv , g_det , X ) : r = 0 for i in range ( len ( X ) ) : for j in range ( len ( X ) ) : r += ( g_inv [ ( i , j ) ] * f . diff ( X [ i ] ) . diff ( X [ j ] ) ) for sigma in range ( len ( X ) ) : for alpha in range ( len ( X ) ) : r += ( ( ( g_det . diff ( X [ sigma ] ) * g_inv [ ( sigma , alpha ) ] ) * f . diff ( X [ alpha ] ) ) / ( 2 * g_det ) ) return r
n-dimensional laplace filter based on approximate second derivatives .