private void Reduce(MutableInteger z) { // var qhat = (z >> (bLength * (k - 1))) * mu >> (bLength * (k + 1)); var reg1 = store.Allocate().Set(z); reg1.RightShift(bToTheKMinusOneLength); #if false var reg2.store.Allocate().SetProductShifted(reg1, muRep, bToTheKPlusOneLength); #else var reg2 = store.Allocate().SetProduct(reg1, muRep); reg2.RightShift(bToTheKPlusOneLength); #endif // var r = z % bToTheKPlusOne - qhat * p % bToTheKPlusOne; z.Mask(bToTheKPlusOneLength); #if true reg1.SetProductMasked(reg2, pRep, bToTheKPlusOneLength); #else reg1.SetProduct(reg2, pRep); reg1.Mask(bToTheKPlusOneLength); #endif // if (r.Sign == -1) r += bToTheKPlusOne; if (z < reg1) { z.SetBit(bToTheKPlusOneLength, true); } z.Subtract(reg1); // while (r >= p) r -= p; while (z >= pRep) { z.Subtract(pRep); } store.Release(reg1); store.Release(reg2); }
private void Reduce(MutableInteger t, MutableInteger u, MutableInteger v) { t.MontgomeryCIOS(u, v, nRep, k0); if (t >= nRep) { t.Subtract(nRep); } Debug.Assert(t < nRep); }
private void Reduce(MutableInteger t) { t.MontgomerySOS(nRep, k0); if (t >= nRep) { t.Subtract(nRep); } Debug.Assert(t < nRep); }
public IResidue <BigInteger> Subtract(IResidue <BigInteger> x) { r.Subtract(((Residue)x).r); return(this); }
public void AdmitParty(int partySize) { remainingCapacity.Subtract(partySize); }