Esempio n. 1
0
        NonZeroRandom(Digits mod, Digits arr, int n, Random generator)
        {
            if (Digits.Compare(mod, 1U, n) <= 0)
            {
                throw new ArgumentException();
            }
            int ntry = 0;

            do
            {
                ntry++;
                Debug.Assert(ntry <= 100, "too many iterations");
                Random(mod, arr, n, generator);
            } while (Digits.SigDigitN(arr, n) == 0);
        }
Esempio n. 2
0
        internal void _ToModular(Digits a, int aDigitN, Digits b)
        {
            Digits aR;
            int    aRDigitN;

            if (Digits.Compare(a, aDigitN, _mod, _digitN) >= 0)
            {
                aR = new Digits(_digitN);
                Digits.Div(a, aDigitN, _mod, _digitN, _leftRecip, null, aR);
                aRDigitN = _digitN;
            }
            else
            {
                aR       = a;
                aRDigitN = aDigitN;
            }
            aRDigitN = Digits.SigDigitN(aR, aRDigitN);
            Digits.Set(aR, aRDigitN, b, _digitN);
            _Shift(b, _scaleBitN, b);
        }