Algorithms for the CELP coder with ternary excitation