def symrand(dim_or_eigv):
 if isinstance(dim_or_eigv, int):
  dim = dim_or_eigv
  d = ((random(dim) * 2) - 1)
 elif (isinstance(dim_or_eigv, ndarray) and (len(dim_or_eigv.shape) == 1)):
  dim = dim_or_eigv.shape[0]
  d = dim_or_eigv
 else:
  raise TypeError('input type not supported.')
 v = random_rot(dim)
 h = dot(dot(v.T.conj(), diag(d)), v)
 h = (0.5 * (h.T + h))
 return h

def symrand ( dim_or_eigv ) : if isinstance ( dim_or_eigv , int ) : dim = dim_or_eigv d = ( ( random ( dim ) * 2 ) - 1 ) elif ( isinstance ( dim_or_eigv , ndarray ) and ( len ( dim_or_eigv . shape ) == 1 ) ) : dim = dim_or_eigv . shape [ 0 ] d = dim_or_eigv else : raise TypeError ( 'input type not supported.' ) v = random_rot ( dim ) h = dot ( dot ( v . T . conj ( ) , diag ( d ) ) , v ) h = ( 0.5 * ( h . T + h ) ) return h
return a random symmetric matrix .