This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdividedpower.py
57 lines (43 loc) · 1.81 KB
/
dividedpower.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
r"""
A minimal implementation of the divided power algebra as an algebra with basis
AUTHOR: Bruce Westbury
"""
#*****************************************************************************
# Copyright (C) 2011 Bruce W. Westbury <brucewestbury@gmail.com>
#
# Distributed under the terms of the GNU General Public License (GPL)
# http://www.gnu.org/licenses/
#******************************************************************************
from sage.misc.cachefunc import cached_method
from sage.sets.family import Family
from sage.categories.all import AlgebrasWithBasis
from sage.combinat.free_module import CombinatorialFreeModule
class DividedPowerAlgebra(CombinatorialFreeModule):
r"""
An example of an algebra with basis: the divided power algebra.
This class illustrates a minimal implementation of the divided power algebra.
"""
def __init__(self, R):
assert(R in Rings())
CombinatorialFreeModule.__init__(self, R, NonNegativeIntegers(), category = AlgebrasWithBasis(R))
def _repr_(self):
return "The divided power algebra over %s"%(self.base_ring())
@cached_method
def one(self):
"""
Returns the unit of the algebra
as per :meth:`AlgebrasWithBasis.ParentMethods.one_basis`.
"""
u = NonNegativeIntegers.from_integer(0)
return self.monomial(u)
def product_on_basis(self, left, right):
r"""
Product, on basis elements, as per :meth:`AlgebrasWithBasis.ParentMethods.product_on_basis`.
"""
return binomial(left+right,left) * self.basis()[left+right]
@cached_method
def algebra_generators(self):
r"""
The generators of this algebra, as per :meth:`Algebras.ParentMethods.algebra_generators`.
"""
return Family(NonNegativeIntegers())