mirror of
https://github.com/tuneinsight/lattigo.git
synced 2025-09-13 03:27:14 +00:00
reduce the number of masking operations in gadget product
This commit is contained in:
@@ -224,12 +224,17 @@ func (eval Evaluator) gadgetProductSinglePAndBitDecompLazy(levelQ int, cx ring.P
|
||||
|
||||
for j := 0; j < BaseTwoDecompositionVectorSize[i]; j++ {
|
||||
|
||||
if mask != 0 {
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
}
|
||||
|
||||
if i == 0 && j == 0 {
|
||||
|
||||
for u, s := range ringQ.SubRings[:levelQ+1] {
|
||||
if mask == 0 {
|
||||
s.NTTLazy(c2QP.Q.Coeffs[u], cwNTT)
|
||||
} else {
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
s.NTTLazy(cw, cwNTT)
|
||||
}
|
||||
s.MulCoeffsMontgomeryLazy(el[i][j][0].Q.Coeffs[u], cwNTT, ct.Value[0].Q.Coeffs[u])
|
||||
@@ -241,7 +246,6 @@ func (eval Evaluator) gadgetProductSinglePAndBitDecompLazy(levelQ int, cx ring.P
|
||||
if mask == 0 {
|
||||
s.NTTLazy(c2QP.P.Coeffs[u], cwNTT)
|
||||
} else {
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
s.NTTLazy(cw, cwNTT)
|
||||
}
|
||||
s.MulCoeffsMontgomeryLazy(el[i][j][0].P.Coeffs[u], cwNTT, ct.Value[0].P.Coeffs[u])
|
||||
@@ -254,7 +258,6 @@ func (eval Evaluator) gadgetProductSinglePAndBitDecompLazy(levelQ int, cx ring.P
|
||||
if mask == 0 {
|
||||
s.NTTLazy(c2QP.Q.Coeffs[u], cwNTT)
|
||||
} else {
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
s.NTTLazy(cw, cwNTT)
|
||||
}
|
||||
s.MulCoeffsMontgomeryLazyThenAddLazy(el[i][j][0].Q.Coeffs[u], cwNTT, ct.Value[0].Q.Coeffs[u])
|
||||
@@ -266,7 +269,6 @@ func (eval Evaluator) gadgetProductSinglePAndBitDecompLazy(levelQ int, cx ring.P
|
||||
if mask == 0 {
|
||||
s.NTTLazy(c2QP.P.Coeffs[u], cwNTT)
|
||||
} else {
|
||||
ring.MaskVec(cxInvNTT.Coeffs[i], j*pw2, mask, cw)
|
||||
s.NTTLazy(cw, cwNTT)
|
||||
}
|
||||
s.MulCoeffsMontgomeryLazyThenAddLazy(el[i][j][0].P.Coeffs[u], cwNTT, ct.Value[0].P.Coeffs[u])
|
||||
|
||||
@@ -32,6 +32,11 @@ type Encoder struct {
|
||||
|
||||
bufQ ring.Poly
|
||||
bufT ring.Poly
|
||||
|
||||
// bufB is allocated in the case when the degree of RingT is smaller
|
||||
// than the degree of RingQ (gap > 1), hence a more involved conversion
|
||||
// between the two structures is necessary. The size of bufB is then
|
||||
// MaxSlots() elements.
|
||||
bufB []*big.Int
|
||||
|
||||
paramsQP []ring.ModUpConstants
|
||||
|
||||
Reference in New Issue
Block a user