update documentation
fix pernicious case where <x> is all zeros and <wantgain> is 1 or 2.
in the cases of empty <X>, we now return 1 instead of [].