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
评论列表
文章目录