@_blocked_elementwise
def sign_round_up(X):
 Y = X.copy()
 Y[(Y == 0)] = 1
 Y /= np.abs(Y)
 return Y

@ _blocked_elementwise def sign_round_up ( X ) : Y = X . copy ( ) Y [ ( Y == 0 ) ] = 1 Y /= np . abs ( Y ) return Y
this should do the right thing for both real and complex matrices .