def sign(val):
  """
  Mimics MATLAB's sign function

  :param val: Input value
  :type val:  float
  :return:    The sign of ``val``
  :rtype:     float
  """
  if val > 0.0:
    return 1.0
  elif val == 0.0:
    return 0.0
  else:
    return -1.0