Commit 13505087 authored by Yuriy Polyakov's avatar Yuriy Polyakov

Optimized NTT

parent fce47424
......@@ -224,24 +224,25 @@ void NumberTheoreticTransform<VecType>::ForwardTransformToBitReverse(const VecTy
result->SetModulus(modulus);
usint i, m, j1, j2, indexOmega, indexLo, indexHi;
NativeInteger preconOmega;
IntType omega, omegaFactor, loVal, hiVal, zero(0);
for (i = 0; i < n; ++i) {
for (uint32_t i = 0; i < n; ++i) {
(*result)[i]= element[i];
}
uint32_t indexOmega, indexHi;
NativeInteger preconOmega;
IntType omega, omegaFactor, loVal, hiVal, zero(0);
usint t = (n >> 1);
usint logt1 = GetMSB64(t);
for (m = 1; m < n; m <<= 1) {
for (i = 0; i < m; ++i) {
for (uint32_t m = 1; m < n; m <<= 1, t >>= 1, --logt1) {
uint32_t j1, j2;
for (uint32_t i = 0; i < m; ++i) {
j1 = i << logt1;
j2 = j1 + t;
indexOmega = m + i;
omega = rootOfUnityTable[indexOmega];
preconOmega = preconRootOfUnityTable[indexOmega];
for (indexLo = j1; indexLo < j2; ++indexLo) {
for (uint32_t indexLo = j1; indexLo < j2; ++indexLo) {
indexHi = indexLo + t;
loVal = (*result)[indexLo];
omegaFactor = (*result)[indexHi];
......@@ -265,8 +266,6 @@ void NumberTheoreticTransform<VecType>::ForwardTransformToBitReverse(const VecTy
}
}
}
t >>= 1;
logt1--;
}
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment