Discrete channel capacity iterative algorithm (C language)