public static double[] computePhaseSpectrum_FD(final double[] fft){
  if (fft == null)   throw new NullPointerException("Received null argument");
  double[] phases=new double[fft.length / 2];
  phases[0]=Math.atan2(0,fft[0]);
  for (int i=2; i < fft.length; i+=2) {
    phases[i / 2]=Math.atan2(fft[i + 1],fft[i]);
  }
  return phases;
}

public static double [ ] computePhaseSpectrum_FD ( final double [ ] fft ) { if ( fft == null ) throw new NullPointerException ( "Received null argument" ) ; double [ ] phases = new double [ fft . length / 2 ] ; phases [ 0 ] = Math . atan2 ( 0 , fft [ 0 ] ) ; for ( int i = 2 ; i < fft . length ; i += 2 ) { phases [ i / 2 ] = Math . atan2 ( fft [ i + 1 ] , fft [ i ] ) ; } return phases ; }
from the result of the fft ( in the frequency domain ) , compute the phase spectrum for each positive frequency .
