Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Rebase off of 9.7.beta6 and fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorkarn committed Jul 26, 2022
1 parent 2362a63 commit 6480faa
Showing 1 changed file with 1 addition and 291 deletions.
292 changes: 1 addition & 291 deletions src/sage/algebras/clifford_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,11 +1628,7 @@ def coproduct_on_basis(self, a):
one = self.base_ring().one()
L = unshuffle_iterator(tuple(a), one)
return self.tensor_square()._from_dict(
<<<<<<< HEAD
{tuple(FrozenBitset(e) if e else FrozenBitset('0') for e in t): c for t, c in L if c},
=======
{tuple(FrozenBitset(e) if e else FrozenBitset() for e in t): c for t,c in L if c},
>>>>>>> b0f66e328e (Cythonizing the element classes.)
coerce=False,
remove_zeros=False)

Expand Down Expand Up @@ -1863,294 +1859,8 @@ def _ideal_class_(self, n=0):
"""
return ExteriorAlgebraIdeal

<<<<<<< HEAD
class Element(CliffordAlgebraElement):
"""
An element of an exterior algebra.
"""
def _mul_(self, other):
"""
Return ``self`` multiplied by ``other``.
INPUT:
- ``other`` -- element of the same exterior algebra as ``self``
EXAMPLES::
sage: E.<x,y,z> = ExteriorAlgebra(QQ)
sage: x*y
x*y
sage: y*x
-x*y
sage: z*y*x
-x*y*z
sage: (x*z)*y
-x*y*z
sage: (3*x + y)^2
0
sage: (x - 3*y + z/3)^2
0
sage: (x+y) * (y+z)
x*y + x*z + y*z
sage: E.<x,y,z,w> = ExteriorAlgebra(QQ)
sage: (x * y) * (w * z)
-x*y*z*w
sage: x * y * w * z
-x*y*z*w
sage: (z * w) * (x * y)
x*y*z*w
"""
P = self.parent()
zero = P.base_ring().zero()
d = {}
n = P.ngens()

for ml, cl in self: # ml for "monomial on the left"
for mr, cr in other: # mr for "monomial on the right"
if ml.intersection(mr):
# if they intersect nontrivially, move along.
continue

if not mr:
t = ml
else:
t = ml.union(mr)
it = iter(mr)
j = next(it)

num_cross = 0 # keep track of the number of signs
tot_cross = 0
for i in ml:
num_cross_new = 0
while i > j:
num_cross_new += 1
try:
j = next(it)
except StopIteration:
j = n + 1
tot_cross += num_cross
if tot_cross % 2:
cr = -cr

d[t] = d.get(t, zero) + cl * cr
if d[t] == zero:
del d[t]

return self.__class__(P, d)

def reduce(self, I, left=True):
r"""
Reduce ``self`` with respect to the elements in ``I``.
INPUT:
- ``I`` -- a list of exterior algebra elements or an ideal
- ``side`` -- the side, ignored if ``I`` is an ideal
"""
if isinstance(I, ExteriorAlgebraIdeal):
left = (I.side() == "left")
I = I.groebner_basis()

E = self.parent()
f = self
from sage.algebras.exterior_algebra_cython import leading_support
for g in I:
lm = leading_support(g)
reduction = True
while reduction:
supp = f.support()
reduction = False
for s in supp:
if lm <= s:
reduction = True
mon = E.monomial(s - lm)
if left:
gp = mon * g
f = f - f[s] / gp[s] * gp
else:
gp = g * mon
f = f - f[s] / gp[s] * gp
break
return f

def interior_product(self, x):
r"""
Return the interior product (also known as antiderivation) of
``self`` with respect to ``x`` (that is, the element
`\iota_{x}(\text{self})` of the exterior algebra).
If `V` is an `R`-module, and if `\alpha` is a fixed element of
`V^*`, then the *interior product* with respect to `\alpha` is
an `R`-linear map
`i_{\alpha} \colon \Lambda(V) \to \Lambda(V)`, determined by
the following requirements:
- `i_{\alpha}(v) = \alpha(v)` for all `v \in V = \Lambda^1(V)`,
- it is a graded derivation of degree `-1`: all `x` and `y`
in `\Lambda(V)` satisfy
.. MATH::
i_{\alpha}(x \wedge y) = (i_{\alpha} x) \wedge y
+ (-1)^{\deg x} x \wedge (i_{\alpha} y).
It can be shown that this map `i_{\alpha}` is graded of
degree `-1` (that is, sends `\Lambda^k(V)` into
`\Lambda^{k-1}(V)` for every `k`).
When `V` is a finite free `R`-module, the interior product can
also be defined by
.. MATH::
(i_{\alpha} \omega)(u_1, \ldots, u_k)
= \omega(\alpha, u_1, \ldots, u_k),
where `\omega \in \Lambda^k(V)` is thought of as an
alternating multilinear mapping from
`V^* \times \cdots \times V^*` to `R`.
Since Sage is only dealing with exterior powers of modules
of the form `R^d` for some nonnegative integer `d`, the
element `\alpha \in V^*` can be thought of as an element of
`V` (by identifying the standard basis of `V = R^d` with its
dual basis). This is how `\alpha` should be passed to this
method.
We then extend the interior product to all
`\alpha \in \Lambda (V^*)` by
.. MATH::
i_{\beta \wedge \gamma} = i_{\gamma} \circ i_{\beta}.
INPUT:
- ``x`` -- element of (or coercing into) `\Lambda^1(V)`
(for example, an element of `V`); this plays the role of
`\alpha` in the above definition
EXAMPLES::
sage: E.<x,y,z> = ExteriorAlgebra(QQ)
sage: x.interior_product(x)
1
sage: (x + x*y).interior_product(2*y)
-2*x
sage: (x*z + x*y*z).interior_product(2*y - x)
-2*x*z - y*z - z
sage: x.interior_product(E.one())
x
sage: E.one().interior_product(x)
0
sage: x.interior_product(E.zero())
0
sage: E.zero().interior_product(x)
0
REFERENCES:
- :wikipedia:`Exterior_algebra#Interior_product`
"""
P = self.parent()
return P.sum([c * cx * P.interior_product_on_basis(m, mx)
for m, c in self for mx, cx in x])

antiderivation = interior_product

def hodge_dual(self):
r"""
Return the Hodge dual of ``self``.
The Hodge dual of an element `\alpha` of the exterior algebra is
defined as `i_{\alpha} \sigma`, where `\sigma` is the volume
form
(:meth:`~sage.algebras.clifford_algebra.ExteriorAlgebra.volume_form`)
and `i_{\alpha}` denotes the antiderivation function with
respect to `\alpha` (see :meth:`interior_product` for the
definition of this).
.. NOTE::
The Hodge dual of the Hodge dual of a homogeneous element
`p` of `\Lambda(V)` equals `(-1)^{k(n-k)} p`, where
`n = \dim V` and `k = \deg(p) = |p|`.
EXAMPLES::
sage: E.<x,y,z> = ExteriorAlgebra(QQ)
sage: x.hodge_dual()
y*z
sage: (x*z).hodge_dual()
-y
sage: (x*y*z).hodge_dual()
1
sage: [a.hodge_dual().hodge_dual() for a in E.basis()]
[1, x, y, z, x*y, x*z, y*z, x*y*z]
sage: (x + x*y).hodge_dual()
y*z + z
sage: (x*z + x*y*z).hodge_dual()
-y + 1
sage: E = ExteriorAlgebra(QQ, 'wxyz')
sage: [a.hodge_dual().hodge_dual() for a in E.basis()]
[1, -w, -x, -y, -z, w*x, w*y, w*z, x*y, x*z, y*z,
-w*x*y, -w*x*z, -w*y*z, -x*y*z, w*x*y*z]
"""
volume_form = self.parent().volume_form()
return volume_form.interior_product(self)

def constant_coefficient(self):
"""
Return the constant coefficient of ``self``.
.. TODO::
Define a similar method for general Clifford algebras once
the morphism to exterior algebras is implemented.
EXAMPLES::
sage: E.<x,y,z> = ExteriorAlgebra(QQ)
sage: elt = 5*x + y + x*z + 10
sage: elt.constant_coefficient()
10
sage: x.constant_coefficient()
0
"""
return self._monomial_coefficients.get(self.parent().one_basis(),
self.base_ring().zero())

def scalar(self, other):
r"""
Return the standard scalar product of ``self`` with ``other``.
The standard scalar product of `x, y \in \Lambda(V)` is
defined by `\langle x, y \rangle = \langle x^t y \rangle`, where
`\langle a \rangle` denotes the degree-0 term of `a`, and where
`x^t` denotes the transpose
(:meth:`~sage.algebras.clifford_algebra.CliffordAlgebraElement.transpose`)
of `x`.
.. TODO::
Define a similar method for general Clifford algebras once
the morphism to exterior algebras is implemented.
EXAMPLES::
sage: E.<x,y,z> = ExteriorAlgebra(QQ)
sage: elt = 5*x + y + x*z
sage: elt.scalar(z + 2*x)
0
sage: elt.transpose() * (z + 2*x)
-2*x*y + 5*x*z + y*z
"""
return (self.transpose() * other).constant_coefficient()
=======
Element = ExteriorAlgebraElement
>>>>>>> b0f66e328e (Cythonizing the element classes.)


#####################################################################
# Differentials
Expand Down

0 comments on commit 6480faa

Please sign in to comment.