_expr_utils.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:kdotp-symmetry 作者: greschd 项目源码 文件源码
def monomial_basis(*degrees):
    """
    Returns the product basis of (kx, ky, kz), with monomials of the given degrees.

    :param degrees: Degree of the monomials. Multiple degrees can be given, in which case the basis consists of the monomials of all given degrees.
    :type degrees: int

    Example:

        >>> import kdotp_symmetry as kp
        >>> kp.monomial_basis(*range(3))
        [1, kx, ky, kz, kx**2, kx*ky, kx*kz, ky**2, ky*kz, kz**2]
    """
    if any(deg < 0 for deg in degrees):
        raise ValueError('Degrees must be non-negative integers')
    basis = []
    for deg in sorted(degrees):
        monomial_tuples = combinations_with_replacement(K_VEC, deg)
        basis.extend(
            reduce(operator.mul, m, sp.Integer(1)) for m in monomial_tuples
        )
    return basis
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号