def algebraic_part_of_standard_l(f, l, space_of_cuspforms, verbose=False):
    r'''f: (vector valued) cuspidal eigenform of degree 2 of weight det^k Sym(j).
    l: positive even integer such that 2 le l < k - 2.
    space_of_cuspforms: space of cusp form that f belongs to.
    Return the algebriac part of the standard L of f at l
    cf. Katsurada, Takemori Congruence primes of the Kim-Ramakrishnan-Shahidi lift. Theorem 4.1.
    '''
    k = f.wt
    j = f.sym_wt
    t0 = f._none_zero_tpl()
    D = tpl_to_half_int_mat(t0)
    if not (l % 2 == 0 and 2 <= l < k - 2):
        raise ValueError
    u3_val, u4_val, f_t0_pol_val = _u3_u4_nonzero(f, t0)
    pull_back_vec = _pullback_vector(
        l + ZZ(2), D, u3_val, u4_val, space_of_cuspforms, verbose=verbose)
    T2 = space_of_cuspforms.hecke_matrix(2)
    d = space_of_cuspforms.dimension()
    vecs = [(T2 ** i) * pull_back_vec for i in range(d)]
    ei = [sum(f[t0] * a for f, a in zip(space_of_cuspforms.basis(), v))
          for v in vecs]
    if j > 0:
        ei = [a._to_pol() for a in ei]
    chply = T2.charpoly()
    nume = first_elt_of_kern_of_vandermonde(chply, f.hecke_eigenvalue(2), ei)
    denom = f[t0] * f_t0_pol_val
    if j > 0:
        denom = denom._to_pol()
    return f.base_ring(nume / denom)
 def _assert(d):
     alphas = []
     while len(set(alphas)) < d and all(a != 0 for a in alphas):
         alphas.append(random_prime(100000))
         alphas = list(set(alphas))
     A = matrix([[alpha ** i for alpha in alphas] for i in range(d)])
     v = [random_prime(100000) for _ in range(d)]
     x = PolynomialRing(QQ, names="x").gens()[0]
     chpy = mul(x - alpha for alpha in alphas)
     self.assertEqual(first_elt_of_kern_of_vandermonde(chpy, alphas[0], v),
                      (A ** (-1) * vector(v))[0])