Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 6369d2b

Browse files
author
Release Manager
committed
Trac #28579: Wedge Product with Scalar Fields
The wedge product of differential forms was not compatible with scalar fields: {{{ sage: M = Manifold(2, 'M') sage: c_cart.<x,y> = M.chart() sage: a = M.diff_form(1, [x, y], name='a') sage: f = M.scalar_field(x^2, name='f') sage: a.wedge(f) AttributeError Traceback (most recent call last) <ipython-input-1-039619b3382c> in <module>() 3 a = M.diff_form(Integer(1), [x, y], name='a') 4 f = M.scalar_field(x**Integer(2), name='f') ----> 5 a.wedge(f) ... AttributeError: 'DiffScalarFieldAlgebra_with_category.element_class' object has no attribute '_ambient_domain' }}} In this ticket, this gets fixed. This ticket is part of the metaticket #28519. URL: https://trac.sagemath.org/28579 Reported by: gh-DeRhamSource Ticket author(s): Michael Jung Reviewer(s): Eric Gourgoulhon
2 parents 28965d2 + 16d849e commit 6369d2b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/sage/manifolds/differentiable/diff_form.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,17 @@ def wedge(self, other):
505505
sage: c1.display(e_xy)
506506
c = (-x^3 - (x - 1)*y^2) dx/\dy
507507
508+
Wedging with scalar fields yields the multiplication from right::
509+
510+
sage: f = M.scalar_field(x, name='f')
511+
sage: f.add_expr_by_continuation(c_uv, W)
512+
sage: t = a.wedge(f)
513+
sage: t.display()
514+
x*y dx + x^2 dy
515+
508516
"""
517+
if other._tensor_rank == 0:
518+
return self * other
509519
from sage.tensor.modules.format_utilities import is_atomic
510520
if self._domain.is_subset(other._domain):
511521
if not self._ambient_domain.is_subset(other._ambient_domain):
@@ -1415,7 +1425,16 @@ def wedge(self, other):
14151425
sage: s[1,2,3] == a[1]*b[2,3] + a[2]*b[3,1] + a[3]*b[1,2]
14161426
True
14171427
1428+
Wedging with scalar fields yields the multiplication from right::
1429+
1430+
sage: f = M.scalar_field(x, name='f')
1431+
sage: t = a.wedge(f)
1432+
sage: t.display()
1433+
2*x dx + (x^2 + x) dy + x*y*z dz
1434+
14181435
"""
1436+
if other._tensor_rank == 0:
1437+
return self * other
14191438
if self._domain.is_subset(other._domain):
14201439
if not self._ambient_domain.is_subset(other._ambient_domain):
14211440
raise ValueError("incompatible ambient domains for exterior " +

src/sage/manifolds/differentiable/scalarfield.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ def __init__(self, parent, coord_expression=None, chart=None, name=None,
631631
ScalarField.__init__(self, parent, coord_expression=coord_expression,
632632
chart=chart, name=name, latex_name=latex_name)
633633
self._tensor_type = (0,0)
634+
self._tensor_rank = 0
634635

635636
####### Required methods for an algebra element (beside arithmetic) #######
636637

@@ -1053,7 +1054,7 @@ def degree(self):
10531054
0
10541055
10551056
"""
1056-
return 0
1057+
return self._tensor_rank
10571058

10581059
def gradient(self, metric=None):
10591060
r"""

0 commit comments

Comments
 (0)