Why did you convert the algorithm from Fortran to c seems a waste of time to me, unless it was a training exercise.