QuantumDividedPowerAlgebra: dividedpower.py

File dividedpower.py, 1.8 KB (added by bruce, 8 years ago)

This file is my attempt at a minimal implementation of the divided power algebra. This does not work. It appears to confuse integers (the basis) with using integers as coefficients.

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