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

Commit b793247

Browse files
committed
#30318: Improve dot and cross product
1 parent 2f3ac09 commit b793247

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

src/sage/manifolds/differentiable/curve.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@ class DifferentiableCurve(DiffMap):
315315
316316
The Frenet-Serret frame is orthonormal::
317317
318-
sage: [[u.dot(v).expr() for v in FS] for u in FS]
319-
[[1, 0, 0], [0, 1, 0], [0, 0, 1]]
318+
sage: matrix([[u.dot(v).expr() for v in FS] for u in FS])
319+
[1 0 0]
320+
[0 1 0]
321+
[0 0 1]
320322
321323
The derivative vectors `N'` and `B'`::
322324

src/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,7 @@ def calc_normal(chart):
724724
n_comp = (n_form.contract(*args) / factorial(self._dim)).contract(
725725
self.ambient_metric().inverse().along(self._immersion))
726726
if self._ambient._dim - self._dim == 1:
727-
n_comp = n_comp / n_comp.norm(
728-
self.ambient_metric().along(self._immersion))
727+
n_comp = n_comp / n_comp.norm(self.ambient_metric())
729728

730729
norm_rst = self._normal.restrict(chart.domain())
731730
norm_rst.add_comp(max_frame.restrict(chart.domain()))[:] = n_comp[:]

src/sage/manifolds/differentiable/vectorfield.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,13 +1147,25 @@ def dot_product(self, other, metric=None):
11471147
u.v: (0, 2*pi) --> R
11481148
t |--> sin(t)^2
11491149
1150+
Scalar product between a vector field along the curve and a vector
1151+
field on the ambient Euclidean plane::
1152+
1153+
sage: e_x = M.cartesian_frame()[1]
1154+
sage: s = u.dot_product(e_x); s
1155+
Scalar field u.e_x on the Real interval (0, 2*pi)
1156+
sage: s.display()
1157+
u.e_x: (0, 2*pi) --> R
1158+
t |--> cos(t)
1159+
11501160
"""
11511161
default_metric = metric is None
11521162
if default_metric:
11531163
metric = self._ambient_domain.metric()
11541164
dest_map = self.parent().destination_map()
1155-
if dest_map is not self._domain.identity_map():
1165+
if dest_map != metric.parent().base_module().destination_map():
11561166
metric = metric.along(dest_map)
1167+
if dest_map != other.parent().destination_map():
1168+
other = other.along(dest_map)
11571169
resu = metric(self, other)
11581170
# From the above operation the name of resu is "g(u,v')" where
11591171
# g = metric._name, u = self._name, v = other._name
@@ -1248,7 +1260,7 @@ def norm(self, metric=None):
12481260
if default_metric:
12491261
metric = self._ambient_domain.metric()
12501262
dest_map = self.parent().destination_map()
1251-
if dest_map is not self._domain.identity_map():
1263+
if dest_map != metric.parent().base_module().destination_map():
12521264
metric = metric.along(dest_map)
12531265
resu = metric(self, self).sqrt()
12541266
if self._name is not None:
@@ -1357,6 +1369,16 @@ def cross_product(self, other, metric=None):
13571369
sage: w.display()
13581370
-sin(t) e_x - cos(t) e_y + (2*cos(t)^2 - 1) e_z
13591371
1372+
Cross product between a vector field along the curve and a vector field
1373+
on the ambient Euclidean space::
1374+
1375+
sage: e_x = M.cartesian_frame()[1]
1376+
sage: w = u.cross_product(e_x); w
1377+
Vector field C' x e_x along the Real interval (0, 2*pi) with values
1378+
on the Euclidean space E^3
1379+
sage: w.display()
1380+
C' x e_x = e_y - cos(t) e_z
1381+
13601382
"""
13611383
if self._ambient_domain.dim() != 3:
13621384
raise ValueError("the cross product is not defined in dimension " +
@@ -1365,10 +1387,12 @@ def cross_product(self, other, metric=None):
13651387
if default_metric:
13661388
metric = self._ambient_domain.metric()
13671389
dest_map = self.parent().destination_map()
1368-
if dest_map is self._domain.identity_map():
1390+
if dest_map == metric.parent().base_module().destination_map():
13691391
eps = metric.volume_form(1)
13701392
else:
13711393
eps = metric.volume_form(1).along(dest_map)
1394+
if dest_map != other.parent().destination_map():
1395+
other = other.along(dest_map)
13721396
resu = eps.contract(1, 2, self.wedge(other), 0, 1) / 2
13731397
# The result is named "u x v" only for a default metric:
13741398
if (default_metric and self._name is not None and

0 commit comments

Comments
 (0)