-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or requestrefactorcompletely change the implementation methodcompletely change the implementation method
Description
在3ntt-crt的不平衡处理策略中,参数 M 本意是一个阈值,作为处理不平衡分块的一个参考值,其尽可能接近
原因如下:(假定乘数的二进制长度分别为m,n ,且认为m >> n,假定
不分块直接ntt乘法的复杂度:
分块块数假如为 t:
当
同时分块还可以复用短乘数的变换结果,而不用重复计算。
原实现中的:lamp_ui min_sum = len2 + std::max(len2, M);实际并未起到作用,因为M为sqrt(len1/len2),导致实际上min_sum=len2+len2,分块策略并未奏效。改为:lamp_ui min_sum = len2 + std::max(1ull, M) * len2;即可。
可以发现在大部分数据上,蓝色(原错误实现)耗时更长,
且原实现存在明显漏洞:即某些更长的数据计算反而更快,这都是不正确分块策略导致的结果。尽管此错误并不影响计算的正确性。

Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestrefactorcompletely change the implementation methodcompletely change the implementation method