From d40de259097c5e8d8fd35539560ca7c3d47523e7 Mon Sep 17 00:00:00 2001 From: Ryan Rueger Date: Sat, 1 Mar 2025 20:25:41 +0100 Subject: Initial Commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Damien Robert Co-Authored-By: Frederik Vercauteren Co-Authored-By: Jonathan Komada Eriksen Co-Authored-By: Pierrick Dartois Co-Authored-By: Riccardo Invernizzi Co-Authored-By: Ryan Rueger [0.01s] Co-Authored-By: Benjamin Wesolowski Co-Authored-By: Arthur Herlédan Le Merdy Co-Authored-By: Boris Fouotsa --- theta_lib/theta_structures/theta_helpers_dim2.py | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 theta_lib/theta_structures/theta_helpers_dim2.py (limited to 'theta_lib/theta_structures/theta_helpers_dim2.py') diff --git a/theta_lib/theta_structures/theta_helpers_dim2.py b/theta_lib/theta_structures/theta_helpers_dim2.py new file mode 100644 index 0000000..a57789d --- /dev/null +++ b/theta_lib/theta_structures/theta_helpers_dim2.py @@ -0,0 +1,32 @@ +from sage.all import * + +def batch_inversion(L): + r"""Does n inversions in 3(n-1)M+1I. + + Input: + - L: list of elements to invert. + + Output: + - [1/x for x in L] + """ + # Given L=[a0,...,an] + # Computes multiples=[a0, a0.a1, ..., a0...an] + multiples=[L[0]] + for ai in L[1:]: + multiples.append(multiples[-1]*ai) + + # Computes inverses=[1/(a0...an),...,1/a0] + inverses=[1/multiples[-1]] + for i in range(1,len(L)): + inverses.append(inverses[-1]*L[-i]) + + # Finally computes [1/a0,...,1/an] + result=[inverses[-1]] + for i in range(2,len(L)+1): + result.append(inverses[-i]*multiples[i-2]) + return result + +def product_theta_point(theta1,theta2): + a,b=theta1 + c,d=theta2 + return [a*c,b*c,a*d,b*d] -- cgit v1.2.3-70-g09d2