def slepian(M, width, sym=True):
 if _len_guards(M):
  return np.ones(M)
 (M, needs_trunc) = _extend(M, sym)
 width = (width / 2)
 width = (width / 2)
 m = np.arange(M, dtype='d')
 H = np.zeros((2, M))
 H[0, 1:] = ((m[1:] * (M - m[1:])) / 2)
 H[1, :] = (((((M - 1) - (2 * m)) / 2) ** 2) * np.cos(((2 * np.pi) * width)))
 (_, win) = linalg.eig_banded(H, select='i', select_range=((M - 1), (M - 1)))
 win = (win.ravel() / win.max())
 return _truncate(win, needs_trunc)

def slepian ( M , width , sym = True ) : if _len_guards ( M ) : return np . ones ( M ) ( M , needs_trunc ) = _extend ( M , sym ) width = ( width / 2 ) width = ( width / 2 ) m = np . arange ( M , dtype = 'd' ) H = np . zeros ( ( 2 , M ) ) H [ 0 , 1 : ] = ( ( m [ 1 : ] * ( M - m [ 1 : ] ) ) / 2 ) H [ 1 , : ] = ( ( ( ( ( M - 1 ) - ( 2 * m ) ) / 2 ) ** 2 ) * np . cos ( ( ( 2 * np . pi ) * width ) ) ) ( _ , win ) = linalg . eig_banded ( H , select = 'i' , select_range = ( ( M - 1 ) , ( M - 1 ) ) ) win = ( win . ravel ( ) / win . max ( ) ) return _truncate ( win , needs_trunc )
return a digital slepian window .