def unimod_matrices_to_infty(r, s): r""" Return a list of matrices whose associated unimodular paths connect `0` to ``r/s``. INPUT: - ``r``, ``s`` -- rational numbers OUTPUT: - a list of matrices in `SL_2(\ZZ)` EXAMPLES:: sage: v = sage.modular.pollack_stevens.manin_map.unimod_matrices_to_infty(19,23); v [ [1 0] [ 0 1] [1 4] [-4 5] [ 5 19] [0 1], [-1 1], [1 5], [-5 6], [ 6 23] ] sage: [a.det() for a in v] [1, 1, 1, 1, 1] sage: sage.modular.pollack_stevens.manin_map.unimod_matrices_to_infty(11,25) [ [1 0] [ 0 1] [1 3] [-3 4] [ 4 11] [0 1], [-1 2], [2 7], [-7 9], [ 9 25] ] ALGORITHM: This is Manin's continued fraction trick, which gives an expression `\{0,r/s\} = \{0,\infty\} + ... + \{a,b\} + ... + \{*,r/s\}`, where each `\{a,b\}` is the image of `\{0,\infty\}` under a matrix in `SL_2(\ZZ)`. """ if s == 0: return [] # the function contfrac_q in # https://github.com/williamstein/psage/blob/master/psage/modform/rational/modular_symbol_map.pyx # is very, very relevant to massively optimizing this. L = convergents(r / s) # Computes the continued fraction convergents of r/s v = [M2Z([1, L[0].numerator(), 0, L[0].denominator()])] # Initializes the list of matrices for j in range(len(L) - 1): a = L[j].numerator() c = L[j].denominator() b = L[j + 1].numerator() d = L[j + 1].denominator() v.append(M2Z([(-1) ** (j + 1) * a, b, (-1) ** (j + 1) * c, d])) # The matrix connecting two consecutive convergents is added on return v
def unimod_matrices_to_infty(r, s): r""" Return a list of matrices whose associated unimodular paths connect `0` to ``r/s``. INPUT: - ``r``, ``s`` -- rational numbers OUTPUT: - a list of matrices in `SL_2(\ZZ)` EXAMPLES:: sage: v = sage.modular.pollack_stevens.manin_map.unimod_matrices_to_infty(19,23); v [ [1 0] [ 0 1] [1 4] [-4 5] [ 5 19] [0 1], [-1 1], [1 5], [-5 6], [ 6 23] ] sage: [a.det() for a in v] [1, 1, 1, 1, 1] sage: sage.modular.pollack_stevens.manin_map.unimod_matrices_to_infty(11,25) [ [1 0] [ 0 1] [1 3] [-3 4] [ 4 11] [0 1], [-1 2], [2 7], [-7 9], [ 9 25] ] ALGORITHM: This is Manin's continued fraction trick, which gives an expression `\{0,r/s\} = \{0,\infty\} + ... + \{a,b\} + ... + \{*,r/s\}`, where each `\{a,b\}` is the image of `\{0,\infty\}` under a matrix in `SL_2(\ZZ)`. """ if s == 0: return [] # the function contfrac_q in # https://github.com/williamstein/psage/blob/master/psage/modform/rational/modular_symbol_map.pyx # is very, very relevant to massively optimizing this. L = convergents(r / s) # Computes the continued fraction convergents of r/s v = [M2Z([1, L[0].numerator(), 0, L[0].denominator()])] # Initializes the list of matrices for j in range(len(L) - 1): a = L[j].numerator() c = L[j].denominator() b = L[j + 1].numerator() d = L[j + 1].denominator() v.append(M2Z([(-1)**(j + 1) * a, b, (-1)**(j + 1) * c, d])) # The matrix connecting two consecutive convergents is added on return v
def unimod_matrices_from_infty(r, s): r""" Return a list of matrices whose associated unimodular paths connect `\infty` to ``r/s``. INPUT: - ``r``, ``s`` -- rational numbers OUTPUT: - a list of `SL_2(\ZZ)` matrices EXAMPLES:: sage: v = sage.modular.pollack_stevens.manin_map.unimod_matrices_from_infty(19,23); v [ [ 0 1] [-1 0] [-4 1] [-5 -4] [-19 5] [-1 0], [-1 -1], [-5 1], [-6 -5], [-23 6] ] sage: [a.det() for a in v] [1, 1, 1, 1, 1] sage: sage.modular.pollack_stevens.manin_map.unimod_matrices_from_infty(11,25) [ [ 0 1] [-1 0] [-3 1] [-4 -3] [-11 4] [-1 0], [-2 -1], [-7 2], [-9 -7], [-25 9] ] ALGORITHM: This is Manin's continued fraction trick, which gives an expression `\{\infty,r/s\} = \{\infty,0\} + ... + \{a,b\} + ... + \{*,r/s\}`, where each `\{a,b\}` is the image of `\{0,\infty\}` under a matrix in `SL_2(\ZZ)`. """ if s != 0: L = convergents(r / s) # Computes the continued fraction convergents of r/s v = [M2Z([-L[0].numerator(), 1, -L[0].denominator(), 0])] # Initializes the list of matrices # the function contfrac_q in https://github.com/williamstein/psage/blob/master/psage/modform/rational/modular_symbol_map.pyx # is very, very relevant to massively optimizing this. for j in range(len(L) - 1): a = L[j].numerator() c = L[j].denominator() b = L[j + 1].numerator() d = L[j + 1].denominator() v.append(M2Z([-b, (-1) ** (j + 1) * a, -d, (-1) ** (j + 1) * c])) # The matrix connecting two consecutive convergents is added on return v else: return []
def unimod_matrices_from_infty(r, s): r""" Return a list of matrices whose associated unimodular paths connect `\infty` to ``r/s``. INPUT: - ``r``, ``s`` -- rational numbers OUTPUT: - a list of `SL_2(\ZZ)` matrices EXAMPLES:: sage: v = sage.modular.pollack_stevens.manin_map.unimod_matrices_from_infty(19,23); v [ [ 0 1] [-1 0] [-4 1] [-5 -4] [-19 5] [-1 0], [-1 -1], [-5 1], [-6 -5], [-23 6] ] sage: [a.det() for a in v] [1, 1, 1, 1, 1] sage: sage.modular.pollack_stevens.manin_map.unimod_matrices_from_infty(11,25) [ [ 0 1] [-1 0] [-3 1] [-4 -3] [-11 4] [-1 0], [-2 -1], [-7 2], [-9 -7], [-25 9] ] ALGORITHM: This is Manin's continued fraction trick, which gives an expression `\{\infty,r/s\} = \{\infty,0\} + ... + \{a,b\} + ... + \{*,r/s\}`, where each `\{a,b\}` is the image of `\{0,\infty\}` under a matrix in `SL_2(\ZZ)`. """ if s != 0: L = convergents(r / s) # Computes the continued fraction convergents of r/s v = [M2Z([-L[0].numerator(), 1, -L[0].denominator(), 0])] # Initializes the list of matrices # the function contfrac_q in https://github.com/williamstein/psage/blob/master/psage/modform/rational/modular_symbol_map.pyx # is very, very relevant to massively optimizing this. for j in range(len(L) - 1): a = L[j].numerator() c = L[j].denominator() b = L[j + 1].numerator() d = L[j + 1].denominator() v.append(M2Z([-b, (-1)**(j + 1) * a, -d, (-1)**(j + 1) * c])) # The matrix connecting two consecutive convergents is added on return v else: return []