Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit c0497b20 authored by Emmanuel Thomé's avatar Emmanuel Thomé
Browse files

update inversion for prime degree

parent 9335f8ea
......@@ -67,6 +67,22 @@ compr_s12 = 12*m # BarDuq
cyclo_s12 = 18*m
cyclo_s16 = 2*cost_s(8)
def cost_prenorm(k,ell):
# returns the cost of computing
# prenorm_{j,\ell}(a)=a^(1+p^j+...+p^{j*(ell-1)})
# in F_p^k, where ell is a divisor of k-1. This is used only for k
# odd. (we have norm(a) = a * prenorm_{1,k-1}(a^p) )
# Note that the cost is independent of j.
if ell == 1:
return 0
elif is_prime(ell):
return cost_m(k) + cost_f(k) + cost_prenorm(k, ell-1)
else:
mu = factor(ell)[0][0]
return cost_prenorm(k, mu) + cost_prenorm(k, ell // mu)
# prenorm_{j,u*v}(a) = prenorm_{j*v,u}(prenorm_{j,v}(a))
# and raising to the power p^{j*v} costs exacly one frobenius.
def cost_i(k) :
# return the cost of an inversion over F_{p^k}
if k%2 == 0 :
......@@ -75,22 +91,19 @@ def cost_i(k) :
return 3*cost_s(k//3) + 9*cost_m(k//3) + cost_i(k//3)
elif k == 1:
return inv
# elif k == 5 :
# # u1 = frob(a)
# # u2 = frob(u1)
# # u3 = frob(u2)
# # v = u1 * u3 # v = a^(p+p^3)
# # w = frob(v) # v = a^(p^2+p^4)
# # b = v * w
# # n = coeff(a,0)*coeff(b,0) + alpha*sum([coeff(a,i)*coeff(b,k-i) for i in range(1,k)])
# # ni = inv(n)
# # ai = ni * a
# return 4*cost_f(k) + 2*cost_m(k) + inv + 2*k*m
elif k == 5 :
# u1 = frob(a)
# u3 = frob(frob(u1)) # costs only 1 frob
# v = u1 * u3 # v = a^(p+p^3)
# w = frob(v) # v = a^(p^2+p^4)
# b = v * w
# n = coeff(a,0)*coeff(b,0) + alpha*sum([coeff(a,i)*coeff(b,k-i) for i in range(1,k)])
# ni = inv(n)
# ai = ni * a
return 3*cost_f(k) + 2*cost_m(k) + inv + 2*k*m
# elif k == 7 :
# # u1 = frob(a)
# # u2 = frob(u1)
# # u3 = frob(u2)
# # u4 = frob(u3)
# # u4 = frob(frob(frob(u1)))
# # v = u1 * u4 # v = a^(p+p^4)
# # w = frob(v) # v = a^(p^2+p^5)
# # z = frob(w) # v = a^(p^3+p^6)
......@@ -98,12 +111,12 @@ def cost_i(k) :
# # n = coeff(a,0)*coeff(b,0) + alpha*sum([coeff(a,i)*coeff(b,k-i) for i in range(1,k)])
# # ni = inv(n)
# # ai = ni * a
# return 6*cost_f(k) + 3*cost_m(k) + inv + 2*k*m
return 4*cost_f(k) + 3*cost_m(k) + inv + 2*k*m
elif k%2 == 1:
# generalization of the above.
# Note that we can go further. If (k-1)/2 >= 4, then we may apply
# the same trick to save some more multiplications.
return ((k+1)//2)*cost_f(k) + cost_m(k) + ((k-3)//2)*(cost_f(k)+cost_m(k)) + inv + 2*k*m
return cost_f(k) + cost_prenorm(k, k-1) + inv + 2*k*m
# elif k == 5 or k == 7 :
# return (k-1)*cost_f(k) + (k-2)*cost_m(k) + inv + 2*k*m
else :
......@@ -140,9 +153,11 @@ def table_costFpk(k_list):
SC = ''.join(["&%s"%sc_dict[k](m=1)+r"\bfm" if k in sc_dict else "&" for k in k_list])
I0 = ''.join(["&%s"%cost_i(k)(m=1,inv=0)+r"\bfm" for k in k_list])
I1 = ''.join(["&%s"%cost_i(k)(m=1,inv=25)+r"\bfm" for k in k_list])
F = F.replace(r"&1\bfm",r"&\bfm")
M = M.replace(r"&1\bfm",r"&\bfm")
S = S.replace(r"&1\bfm",r"&\bfm")
I0 = I0.replace(r"&0\bfm",r"&0")
F = F.replace(r"&0\bfm",r"&0")
contents = [
r"$$\begin{array}{|c|" + "c|" * len(k_list) + "}",
r"\hline",
......
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