function XP = power_spectrum_from_fft(X)
  # Returns the power spectrum {XP} of a signal,
  # given its Fourier transform {X}.
  assert(size(X,2)==1)
  N = size(X,1); # Number of samples.
  assert(mod(N,2) == 0)
  NP = N/2+1;
  XP = zeros(NP,1);
  for ii = 1:NP
    v2 = abs(X(ii,1))^2;
    if (ii != 1) && (ii != NP)
      v2 = v2 + abs(X(N+1-ii))^2;
    end;
    XP(ii,1) = v2;
  end;
  
      
  