• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python all.vector函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sage.all.vector函数的典型用法代码示例。如果您正苦于以下问题:Python vector函数的具体用法?Python vector怎么用?Python vector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了vector函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: fc_of_pullback_of_diff_eisen

def fc_of_pullback_of_diff_eisen(l, k, m, A, D, u3, u4, verbose=False):
    '''Return the Fourier coefficient of exp(2pi A Z1 + 2pi D Z2)
    of pullback of vector valued Eisenstein series F_{l, (k, m)} in [DIK], pp 1313.
    '''
    dct = {"A": A, "D": D}
    res = _U_ring(0)
    es = sess(weight=l, degree=4)
    us = list(_U_ring.gens()) + [u3, u4]
    # D_up is multiplication by d_up_mlt on p(z2)e(A Z1 + R^t Z12 + D Z2)
    v_up = vector(_U_ring, us[:2])
    d_up_mlt = v_up * A * v_up
    v_down = vector(us[2:])
    d_down_mlt = v_down * D * v_down
    d_up_down_mlt = d_up_mlt * d_down_mlt
    _u1, _u2 = (_Z_U_ring(a) for a in ["u1", "u2"])
    for R, mat in r_n_m_iter(A, D):
        r_ls = R.list()
        pol = D_tilde_nu(l, k - l, QQ(1), r_ls, **dct)
        # L_operator is a differential operator whose order <= m,
        # we truncate it.
        pol = _Z_ring(
            {t: v for t, v in pol.dict().iteritems() if sum(list(t)) <= m})
        _l_op_tmp = L_operator(k, m, A, D, r_ls, pol *
                               es.fourier_coefficient(mat), us, d_up_down_mlt)
        _l_op_tmp = _U_ring({(m - a, a): _l_op_tmp[_u1 ** (m - a) * _u2 ** a]
                             for a in range(m + 1)})
        res += _l_op_tmp
    res = res * QQ(mul(k + i for i in range(m))) ** (-1)
    res = res * _zeta(1 - l) * _zeta(1 - 2 * l + 2) * _zeta(1 - 2 * l + 4)
    if verbose:
        print "Done computation of Fourier coefficient of pullback."
    return res
开发者ID:stakemori,项目名称:degree2,代码行数:32,代码来源:diff_operator_pullback_vector_valued.py


示例2: split_into_diamond_orbits

def split_into_diamond_orbits(cuspsums,level):
    """
    Input a list of cuspsums w.r.t. to the standard basis. Output a list of orbits of these cuspsums.  
    """
    csp_grp = conjectural_cuspidal_classgroup(level)
    diamonds = counts([tuple(sorted(set(csp_grp(vector(i)) for i in diamond_orbits_cuspsum(c,level)))) for c in cuspsums])
    cusp_grp_to_cusp_sum = dict((csp_grp(vector(c)),c) for c in cuspsums)
    return [[cusp_grp_to_cusp_sum[k] for k in d[0]] for d in diamonds]
开发者ID:koffie,项目名称:mdsage,代码行数:8,代码来源:modular_unit_divisors.py


示例3: upsert_embedding

def upsert_embedding(id_number, skip = False):
    rowcc = db.mf_hecke_cc.lucky({'id':id_number}, projection=['an', 'hecke_orbit_code','id','lfunction_label', 'embedding_root_imag','embedding_root_real'])
    if rowcc is None:
        return
    if skip:
        if rowcc.get("embedding_root_imag", None) is not None:
            if rowcc.get("embedding_root_real", None) is not None:
                return
    row_embeddings =  {}
    hecke_orbit_code = rowcc['hecke_orbit_code']
    newform = db.mf_newforms.lucky({'hecke_orbit_code':hecke_orbit_code})
    if newform is None:
        # No newform in db
        return
    if newform['dim'] == 1:
        row_embeddings['embedding_root_imag'] = 0
        row_embeddings['embedding_root_real'] = 0
    elif newform['weight'] == 1:
        return
    elif newform.get('field_poly', None) is None:
	    return
    else:
        # print rowcc['lfunction_label']
        HF = NumberField(ZZx(newform['field_poly']), "v")
        numerators =  newform['hecke_ring_numerators']
        denominators = newform['hecke_ring_denominators']
        betas = [HF(elt)/denominators[i] for i, elt in enumerate(numerators)]

        embeddings = HF.complex_embeddings(prec=2000)
        an_nf = list(db.mf_hecke_nf.search({'hecke_orbit_code':hecke_orbit_code}, ['n','an'], sort=['n']))
        betas_embedded = [map(elt, betas) for elt in embeddings]
        CCC = betas_embedded[0][0].parent()
        qexp = [convert_eigenvals_to_qexp(elt, an_nf) for elt in betas_embedded]
        min_len = min(len(rowcc['an']), len(qexp[0]))
        an_cc = vector(CCC, map(lambda x: CCC(x[0], x[1]), rowcc['an'][:min_len]))
        #qexp_diff = [ (vector(CCC, elt[:min_len]) - an_cc).norm() for elt in qexp ]
        # normalized, to avoid the unstability comming from large weight
        qexp_diff = [ vector([(elt- an_cc[i])/elt.abs() for i, elt in enumerate(q) if elt != 0]).norm() for j,q in enumerate(qexp)]

        qexp_diff_sorted = sorted(qexp_diff)
        min_diff = qexp_diff_sorted[0]
        #print "min_diff = %.2e \t min_diff/2nd = %.2e" % (min_diff, min_diff/qexp_diff_sorted[1])

        #assuring that is something close to zero, and that no other value is close to it
        assert min_diff < 1e-6
        assert min_diff/qexp_diff_sorted[1] < 1e-15

        for i, elt in enumerate(qexp_diff):
            if elt == min_diff:
                row_embeddings['embedding_root_real'] = float(embeddings[i](HF.gen()).real())
                row_embeddings['embedding_root_imag'] = float(embeddings[i](HF.gen()).imag())
                break
    assert len(row_embeddings) == 2
    db.mf_hecke_cc.upsert({'id': rowcc['id']}, row_embeddings)
开发者ID:koffie,项目名称:lmfdb,代码行数:54,代码来源:populate_embeddings_mf_hecke_cc.py


示例4: optimal_remove_points

def optimal_remove_points(Delta, Fundam):
    l = ZZ(5)

    candidates = [(vector(pt),) for pt in Delta.integral_points()]

    V = Delta.vertices()
    if len(V) == 3:
        candidates.append(tuple(vector(pt) for pt in V))
    elif len(V) == 4:
        VV = list(V)
        WW = []
        V0 = VV[0]
        for edge in Delta.faces(1):
            edge = edge.vertices()
            if edge[0] == V0:
                e = edge[1]
                VV.remove(e); WW.append(e)
            elif edge[1] == V0:
                e = edge[0]
                VV.remove(e); WW.append(e)
        # We should be left with 2 pairs
        assert len(VV) == 2
        assert len(WW) == 2

        candidates.append(tuple(vector(pt) for pt in VV))
        candidates.append(tuple(vector(pt) for pt in WW))

    Delta_pts = Delta.integral_points()
    Delta_int_pts = interior_points(Delta)
    Delta2_int_pts = interior_points(ZZ(2) * Delta)

    # Check monomials in the fundamental domain
    X, Y = ZZ_X_Y.gens()
    AUT = polygon_symmetries(l * Delta)
    lFundam = fundamental_points(l * Fundam, AUT)
    monomials = [X**pt[0] * Y**pt[1] for pt in lFundam]

    def difficulty(remove_points):
        all_pts = list(Delta_pts)
        int_pts = list(Delta_int_pts)
        int_pts2 = list(Delta2_int_pts)
        for pt in remove_points:
            all_pts.remove(pt)
            for z in int_pts:
                int_pts2.remove(pt + z)

        fd_coeff = genf_koszul_points(all_pts, int_pts, l-1).monomial_coefficient
        fc_coeff = genf_koszul_points(all_pts, int_pts2, l-2).monomial_coefficient

        return max(fd_coeff(monom) * fc_coeff(monom) for monom in monomials)

    return min(candidates, key=difficulty)
开发者ID:jdemeyer,项目名称:toricbetti,代码行数:52,代码来源:table.py


示例5: NonCubicSet

def NonCubicSet(K,S, verbose=False):
    u = -1 if K==QQ else  K(K.unit_group().torsion_generator())
    from KSp import IdealGenerator
    Sx = [u] + [IdealGenerator(P) for P in S]
    r = len(Sx)
    d123 = r + binomial(r,2) + binomial(r,3)
    vecP = vec123(K,Sx)
    A = Matrix(GF(2),0,d123)
    N = prod(S,1)

    primes = primes_iter(K,None)
    T = []
    while A.rank() < d123:
        p = primes.next()
        while p.divides(N):
            p = primes.next()
        v = vecP(p)
        if verbose:
            print("v={}".format(v))
        A1 = A.stack(vector(v))
        if A1.rank() > A.rank():
            A = A1
            T.append(p)
            if verbose:
                print("new A={} with {} rows and {} cols".format(A,A.nrows(),A.ncols()))
                print("T increases to {}".format(T))
    return T
开发者ID:JohnCremona,项目名称:CremonaPacetti,代码行数:27,代码来源:SerreFaltings.py


示例6: in_kernel

    def in_kernel(self):
        """
        Determine whether this :class:`StrataAlgebraElement` is in the span of the FZ relations, and hence in the kernel of the map to the tautological ring. ::
        
            sage: from strataalgebra import *
            sage: s = StrataAlgebra(QQ,0,(1,2,3,4,5))
            sage: b = s.boundary(0,(1,2,5)) + s.boundary(0,(1,2)) - s.boundary(0,(1,3,5)) - s.boundary(0,(1,3))
            sage: b
            Dg0m1_2_5 + Dg0m1_2 - Dg0m1_3_5 - Dg0m1_3
            sage: b.in_kernel()
            True
            sage: (s.psi(1) - s.psi(2)).in_kernel()
            False

            
        It should work fine for non-homogeneous things as well. ::
            
            sage: (b + s.psi(1)).in_kernel()
            False
            sage: (b + s.psi(1)**2 - s.psi(2)**2).in_kernel()
            True
        """
        for codim in range(self.codim()+1):
            v = vector([0]*self.parent().hilbert(codim))
            for (cd, index), coef in self.coef_dict.items():
                if cd == codim:
                    v[index] = coef
            if v not in self.parent().FZ_matrix(codim).row_space():
                return False
        return True
开发者ID:uberparagon,项目名称:mgn,代码行数:30,代码来源:strataalgebra.py


示例7: small_lgs2

def small_lgs2(A, c, mod, sol=None):
    '''
    Find short x with Ax = c (mod m).

    This is more generic because it also works for composite m, but it does
    not work for c = 0. The difference is that we don't have to compute the
    orthogonal lattice of A.

    TODO: For c = 0, we can brute force a k with small ||k|| and solve for
    c = k*mod instead.

    See [2] (p. 264-268) and https://crypto.stackexchange.com/questions/37836/
    '''
    m, n = A.dimensions()
    A = list(A)
    for i in range(n):
        A.append([0]*i + [mod] + [0]*(n-i-1))
    A = matrix(ZZ, A)
    L = A.LLL()

    for i in range(m):
        assert L[i] == 0
    L = L[m:]
    if c == 0 or c == None:
        # Brutal heuristic here, see TODO above. We are only trying one single k
        # here, namely (0, ..., 0, 1)
        x = normalize(integer_lgs(L, vector([0]*(n-1) + [mod])))
        for t in x:
            assert 0 <= x < mod
        return x

    # compute Y such that Y*A == L
    Y = []
    smith = A.transpose().smith_form()
    for i in range(L.nrows()):
        y = integer_lgs(None, L[i], smith)
        # assert At*y == L[i]
        Y.append(y)
    Y = matrix(ZZ, Y)
    # assert Y*A == L

    c = Y*vector(list(c)+[0]*n)%mod
    for i in range(len(c)):
        if c[i] * 2 >= mod:
            c[i] -= mod
        assert abs(c[i]) * 2 < mod
    return integer_lgs(Y*A, c)
开发者ID:niklasb,项目名称:ctf-tools,代码行数:47,代码来源:lll.py


示例8: __getitem__

 def __getitem__(self, t):
     if (isinstance(t, tuple) and isinstance(t[0], tuple) and
             is_number(t[1])):
         tpl, i = t
         return self.forms[i][tpl]
     else:
         vec = vector([f[t] for f in self.forms])
         return vec
开发者ID:stakemori,项目名称:degree2,代码行数:8,代码来源:elements.py


示例9: class_mats_m1

def class_mats_m1(lst):
    d = {0:[],1:[],2:[]}

    for M in lst:
        x = sum(min(1, M.columns().count(vector(c))) for c in SYS_COL)
        d[x].append(M)

    return d
开发者ID:terhorst,项目名称:kalmanson,代码行数:8,代码来源:tucker.py


示例10: normal_vertices

def normal_vertices(Delta):
    vertices = []
    for ineq in Delta.inequalities_list():
        c = ineq[0]
        ineq = ineq[1:]
        assert gcd(ineq) == 1
        vertices.append(vector(ZZ, ineq))
    return vertices
开发者ID:jdemeyer,项目名称:toricbetti,代码行数:8,代码来源:polygon.py


示例11: kernel_lattice

def kernel_lattice(A, mod=None):
    ''' Lattice of vectors x with Ax = 0 (potentially mod m) '''
    A = matrix(ZZ if mod is None else Integers(mod), A)
    L = [vector(ZZ, row) for row in A.right_kernel().basis()]
    if mod is not None:
        cols = len(L[0])
        for i in range(cols):
            L.append([0]*i + [mod] + [0]*(cols-i-1))
    return matrix(L)
开发者ID:niklasb,项目名称:ctf-tools,代码行数:9,代码来源:lll.py


示例12: as_polynomial_in_E4_and_E6

 def as_polynomial_in_E4_and_E6(self,insert_in_db=True):
     r"""
     If self is on the full modular group writes self as a polynomial in E_4 and E_6.
     OUTPUT:
     -''X'' -- vector (x_1,...,x_n)
     with f = Sum_{i=0}^{k/6} x_(n-i) E_6^i * E_4^{k/4-i}
     i.e. x_i is the coefficient of E_6^(k/6-i)*
     """
     if(self.level() != 1):
         raise NotImplementedError("Only implemented for SL(2,Z). Need more generators in general.")
     if(self._as_polynomial_in_E4_and_E6 is not None and self._as_polynomial_in_E4_and_E6 != ''):
         return self._as_polynomial_in_E4_and_E6
     d = self._parent.dimension_modular_forms()  # dimension of space of modular forms
     k = self.weight()
     K = self.base_ring()
     l = list()
     # for n in range(d+1):
     #    l.append(self._f.q_expansion(d+2)[n])
     # v=vector(l) # (self._f.coefficients(d+1))
     v = vector(self.coefficients(range(d),insert_in_db=insert_in_db))
     d = dimension_modular_forms(1, k)
     lv = len(v)
     if(lv < d):
         raise ArithmeticError("not enough Fourier coeffs")
     e4 = EisensteinForms(1, 4).basis()[0].q_expansion(lv + 2)
     e6 = EisensteinForms(1, 6).basis()[0].q_expansion(lv + 2)
     m = Matrix(K, lv, d)
     lima = floor(k / 6)  # lima=k\6;
     if((lima - (k / 2)) % 2 == 1):
         lima = lima - 1
     poldeg = lima
     col = 0
     monomials = dict()
     while(lima >= 0):
         deg6 = ZZ(lima)
         deg4 = (ZZ((ZZ(k / 2) - 3 * lima) / 2))
         e6p = (e6 ** deg6)
         e4p = (e4 ** deg4)
         monomials[col] = [deg4, deg6]
         eis = e6p * e4p
         for i in range(1, lv + 1):
             m[i - 1, col] = eis.coefficients()[i - 1]
         lima = lima - 2
         col = col + 1
     if (col != d):
         raise ArithmeticError("bug dimension")
     # return [m,v]
     if self._verbose > 0:
         wmf_logger.debug("m={0}".format(m, type(m)))
         wmf_logger.debug("v={0}".format(v, type(v)))
     try:
         X = m.solve_right(v)
     except:
         return ""
     self._as_polynomial_in_E4_and_E6 = [poldeg, monomials, X]
     return [poldeg, monomials, X]
开发者ID:sehlen,项目名称:modforms-db,代码行数:56,代码来源:web_modforms_computing.py


示例13: multiply_mat_vec

def multiply_mat_vec(E,v):
    KE = E.base_ring()
    if isinstance(v,list):
        v = vector(v)
    Kv = v.base_ring()
    if KE != QQ and KE != Kv:
        EE = convert_matrix_to_extension_fld(E,Kv)
        return EE*v
    else:
        return E*v
开发者ID:kedlaya,项目名称:lmfdb,代码行数:10,代码来源:emf_utils.py


示例14: _to_vector

 def _to_vector(self, fm, tpls=None):
     '''
     Returns a vector corresponding to fm.
     By this method, self.basis() becomes the standard basis.
     '''
     if tpls is None:
         tpls = self.linearly_indep_tuples()
     m1 = matrix([[f[t] for t in tpls] for f in self.basis()])
     v = vector([fm[t] for t in tpls])
     return v * m1 ** (-1)
开发者ID:stakemori,项目名称:degree2,代码行数:10,代码来源:modular_form_module.py


示例15: apply

    def apply(self, c, G, h, evaluation):
        "LinearProgramming[c_, G_, h_]"

        (c, G, h), subs = to_sage((c, G, h), evaluation)
        n = len(c)
        c = vector(c)
        G = matrix([[-item for item in row] for row in G] + [unit_vector(k, n, -1) for k in range(n)])
        h = vector([-item for item in h] + [0] * n)
        result = linear_program(c, G, h)
        status = result["status"]
        if status == "dual infeasible":
            evaluation.message("LinearProgramming", "lpsub")
            return Expression("List", *([Symbol("Indeterminate")] * n))
        elif status == "primal infeasible":
            return evaluation.message("LinearProgramming", "lpsnf")
        # print result
        x = result["x"]
        x = [round(value, mpf("0.000001")) for value in x]  # round result to 6 digits after comma
        return from_sage(x, subs)
开发者ID:mikexstudios,项目名称:Mathics,代码行数:19,代码来源:numerical_optimization.py


示例16: _assert

 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])
开发者ID:stakemori,项目名称:degree2,代码行数:11,代码来源:test_pullback_se_scalar_valued.py


示例17: test_permutation

def test_permutation(g,R):
    Rp = permute_matrix(g,R)
    pat = map(ray_sign_pattern, [R,Rp])
    vec = np.array(permutation_action(g, ray_sign_vector(R)))
    if vec[0]==-1:
        vec *= -1
    pred = vector(list(vec))
    d = {-1:"-", 1:"+"}
    pred = "".join(map(d.get, pred))
    #print R,"\n\n",Rp
    #print "p0: %s\tp': %s\tp_pred: %s" % (pat[0], pat[1], pred)
    assert pred==pat[1]
开发者ID:terhorst,项目名称:kalmanson,代码行数:12,代码来源:kalmanson.py


示例18: truncated_lgs

def truncated_lgs(A, y, mod):
    '''
    Find short x with A(y + x) = 0 (mod m).

    This is essentially a special case of small_lgs2, might be faster?

    See [2] (p. 264-268) and https://crypto.stackexchange.com/questions/37836/
    '''

    ## This will also work usually, but might be slower
    # c = -A*y%mod
    # return y + small_lgs2(A, c, mod)

    n = A.ncols()
    A = list(matrix(ZZ, A))
    for i in range(n):
        A.append([0]*i + [mod] + [0]*(n-i-1))

    L = matrix(ZZ, A).LLL()
    W1 = L*vector(ZZ, y)
    W2 = vector([int(round(RR(w)/mod))*mod - w for w in W1])
    return L.solve_right(W2) + y
开发者ID:niklasb,项目名称:ctf-tools,代码行数:22,代码来源:lll.py


示例19: orbits

def orbits(L, G):
    """
    Given a collection `L` of points, group them in orbits under the
    action of `G` (a collection of matrices representing elements of
    AGL.).
    """
    from collections import defaultdict
    orbits = defaultdict(list)
    for pt in L:
        v = vector(ZZ, tuple(pt) + (1,))
        orbit = frozenset(tuple(g*v)[:-1] for g in G)
        orbits[orbit] = orbits[orbit] + [pt]
    return orbits.values()
开发者ID:jdemeyer,项目名称:toricbetti,代码行数:13,代码来源:polygon.py


示例20: cvp_embed

def cvp_embed(L, v, b=None):
    if not b:
        b = max(max(row) for row in L.rows())

    L2 = matrix([list(row) + [0] for row in L] + [list(v) + [b]])
    res = None
    for x in lll(matrix(L2)):
        if x[-1] > 0: x = -x
        if x[-1] == -b:
            u = vector(x[:-1]) + v
            assert in_lattice(L, u)
            if res is None or (v - u).norm() < (v - res).norm():
                res = u
    return res
开发者ID:niklasb,项目名称:ctf-tools,代码行数:14,代码来源:lll.py



注:本文中的sage.all.vector函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python all.EllipticCurve类代码示例发布时间:2022-05-27
下一篇:
Python all.var函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap