def laplacian(ndim, shape, is_real=True):
 impr = np.zeros(([3] * ndim))
 for dim in range(ndim):
  idx = tuple(((([slice(1, 2)] * dim) + [slice(None)]) + ([slice(1, 2)] * ((ndim - dim) - 1))))
  impr[idx] = np.array([(-1.0), 0.0, (-1.0)]).reshape([((-1) if (i == dim) else 1) for i in range(ndim)])
 impr[([slice(1, 2)] * ndim)] = (2.0 * ndim)
 return (ir2tf(impr, shape, is_real=is_real), impr)

def laplacian ( ndim , shape , is_real = True ) : impr = np . zeros ( ( [ 3 ] * ndim ) ) for dim in range ( ndim ) : idx = tuple ( ( ( ( [ slice ( 1 , 2 ) ] * dim ) + [ slice ( None ) ] ) + ( [ slice ( 1 , 2 ) ] * ( ( ndim - dim ) - 1 ) ) ) ) impr [ idx ] = np . array ( [ ( - 1.0 ) , 0.0 , ( - 1.0 ) ] ) . reshape ( [ ( ( - 1 ) if ( i == dim ) else 1 ) for i in range ( ndim ) ] ) impr [ ( [ slice ( 1 , 2 ) ] * ndim ) ] = ( 2.0 * ndim ) return ( ir2tf ( impr , shape , is_real = is_real ) , impr )
return the transfer function of the laplacian .