Skip to content

Commit 0e91599

Browse files
optimized set structure usage and removed commented out code
1 parent 12a8014 commit 0e91599

File tree

1 file changed

+4
-169
lines changed

1 file changed

+4
-169
lines changed

src/sage/dynamics/arithmetic_dynamics/dynamical_semigroup.py

Lines changed: 4 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ def nth_iterate(self, p, n):
544544
raise TypeError(str(n) + " must be an integer")
545545
if n < 0:
546546
raise ValueError(str(n) + " must be a nonnegative integer")
547-
result = (self.domain()(p),)
547+
result = {self.domain()(p)}
548548
for i in range(1, n + 1):
549-
next_iteration = []
549+
next_iteration = set()
550550
for point in result:
551-
next_iteration.extend(self(point))
551+
next_iteration.update(self(point))
552552
result = next_iteration
553-
return set(result)
553+
return result
554554

555555
def _mul_(self, other_dynamical_semigroup):
556556
r"""
@@ -1140,171 +1140,6 @@ def homogenize(self, n):
11401140
new_systems.append(new_system)
11411141
return DynamicalSemigroup_projective(new_systems)
11421142

1143-
# def _mul_(self, other_dynamical_semigroup):
1144-
# r"""
1145-
# Return a new :class:`DynamicalSemigroup_affine` that is the result of multiplying
1146-
# this dynamical semigroup with another dynamical semigroup using the * operator.
1147-
1148-
# Let `f` be a dynamical semigroup with generators `\{ f_1, f_2, \dots, f_m \}`
1149-
# and `g` be a dynamical semigroup with generators `\{ g_1, g_2, \dots, g_n \}`.
1150-
# The product `f * g` has generators
1151-
# `\{ f_i(g_j) : 1 \leq i \leq m, 1 \leq j \leq n \} \cup \{ g_j(f_i) : 1 \leq i \leq m, 1 \leq j \leq n \}`.
1152-
1153-
# INPUT:
1154-
1155-
# - ``other_dynamical_semigroup`` -- a dynamical semigroup over affine space
1156-
1157-
# OUTPUT: :class:`DynamicalSemigroup_affine`
1158-
1159-
# EXAMPLES::
1160-
1161-
# sage: A.<x> = AffineSpace(QQ, 1)
1162-
# sage: f1 = DynamicalSystem(x, A)
1163-
# sage: f2 = DynamicalSystem(x^2, A)
1164-
# sage: g1 = DynamicalSystem(x^3, A)
1165-
# sage: g2 = DynamicalSystem(x^4, A)
1166-
# sage: f = DynamicalSemigroup((f1, f2))
1167-
# sage: g = DynamicalSemigroup((g1, g2))
1168-
# sage: f*g
1169-
# Dynamical semigroup over Affine Space of dimension 1 over Rational Field defined by 8 dynamical systems:
1170-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1171-
# Defn: Defined on coordinates by sending (x) to
1172-
# (x^3)
1173-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1174-
# Defn: Defined on coordinates by sending (x) to
1175-
# (x^4)
1176-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1177-
# Defn: Defined on coordinates by sending (x) to
1178-
# (x^6)
1179-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1180-
# Defn: Defined on coordinates by sending (x) to
1181-
# (x^8)
1182-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1183-
# Defn: Defined on coordinates by sending (x) to
1184-
# (x^3)
1185-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1186-
# Defn: Defined on coordinates by sending (x) to
1187-
# (x^6)
1188-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1189-
# Defn: Defined on coordinates by sending (x) to
1190-
# (x^4)
1191-
# Dynamical System of Affine Space of dimension 1 over Rational Field
1192-
# Defn: Defined on coordinates by sending (x) to
1193-
# (x^8)
1194-
1195-
# TESTS::
1196-
1197-
# sage: A.<x> = AffineSpace(QQ, 1)
1198-
# sage: f1 = DynamicalSystem(x, A)
1199-
# sage: f2 = DynamicalSystem(x^2, A)
1200-
# sage: g1 = DynamicalSystem(x^3, A)
1201-
# sage: g2 = DynamicalSystem(x^4, A)
1202-
# sage: f = DynamicalSemigroup((f1, f2))
1203-
# sage: g = DynamicalSemigroup((g1, g2))
1204-
# sage: f*g == g*f
1205-
# True
1206-
1207-
# ::
1208-
1209-
# sage: A.<x> = AffineSpace(QQ, 1)
1210-
# sage: B.<y> = AffineSpace(QQ, 1)
1211-
# sage: f1 = DynamicalSystem(x, A)
1212-
# sage: f2 = DynamicalSystem(x^2, A)
1213-
# sage: g1 = DynamicalSystem(y^3, B)
1214-
# sage: g2 = DynamicalSystem(y^4, B)
1215-
# sage: f = DynamicalSemigroup((f1, f2))
1216-
# sage: g = DynamicalSemigroup((g1, g2))
1217-
# sage: f*g == g*f
1218-
# True
1219-
1220-
# ::
1221-
1222-
# sage: A.<x> = AffineSpace(QQ, 1)
1223-
# sage: f1 = DynamicalSystem(x, A)
1224-
# sage: f2 = DynamicalSystem(x^2, A)
1225-
# sage: g1 = DynamicalSystem(x^3, A)
1226-
# sage: g2 = DynamicalSystem(x^4, A)
1227-
# sage: h1 = DynamicalSystem(x^5, A)
1228-
# sage: h2 = DynamicalSystem(x^6, A)
1229-
# sage: f = DynamicalSemigroup((f1, f2))
1230-
# sage: g = DynamicalSemigroup((g1, g2))
1231-
# sage: h = DynamicalSemigroup((h1, h2))
1232-
# sage: f*(g*h) == (f*g)*h
1233-
# True
1234-
1235-
# ::
1236-
1237-
# sage: A.<x> = AffineSpace(QQ, 1)
1238-
# sage: B.<y> = AffineSpace(QQ, 1)
1239-
# sage: C.<z> = AffineSpace(QQ, 1)
1240-
# sage: f1 = DynamicalSystem(x, A)
1241-
# sage: f2 = DynamicalSystem(x^2, A)
1242-
# sage: g1 = DynamicalSystem(y^3, B)
1243-
# sage: g2 = DynamicalSystem(y^4, B)
1244-
# sage: h1 = DynamicalSystem(z^5, C)
1245-
# sage: h2 = DynamicalSystem(z^6, C)
1246-
# sage: f = DynamicalSemigroup((f1, f2))
1247-
# sage: g = DynamicalSemigroup((g1, g2))
1248-
# sage: h = DynamicalSemigroup((h1, h2))
1249-
# sage: f*(g*h) == (f*g)*h
1250-
# True
1251-
1252-
# ::
1253-
1254-
# sage: A.<x> = AffineSpace(QQ, 1)
1255-
# sage: P.<y,z> = ProjectiveSpace(QQ, 1)
1256-
# sage: f1 = DynamicalSystem(x, A)
1257-
# sage: f2 = DynamicalSystem(x^2, A)
1258-
# sage: g1 = DynamicalSystem([y^3, z^3], P)
1259-
# sage: g2 = DynamicalSystem([y^4, z^4], P)
1260-
# sage: f = DynamicalSemigroup((f1, f2))
1261-
# sage: g = DynamicalSemigroup((g1, g2))
1262-
# sage: f*g
1263-
# Traceback (most recent call last):
1264-
# ...
1265-
# TypeError: can only multiply `DynamicalSemigroup_affine` objects
1266-
1267-
# ::
1268-
1269-
# sage: A.<x> = AffineSpace(QQ, 1)
1270-
# sage: B.<y,z> = AffineSpace(QQ, 2)
1271-
# sage: f1 = DynamicalSystem(x, A)
1272-
# sage: f2 = DynamicalSystem(x^2, A)
1273-
# sage: g1 = DynamicalSystem([y^3, z^3], B)
1274-
# sage: g2 = DynamicalSystem([y^4, z^4], B)
1275-
# sage: f = DynamicalSemigroup((f1, f2))
1276-
# sage: g = DynamicalSemigroup((g1, g2))
1277-
# sage: f*g
1278-
# Traceback (most recent call last):
1279-
# ...
1280-
# ValueError: cannot multiply dynamical semigroups of different dimensions
1281-
# """
1282-
# if not isinstance(other_dynamical_semigroup, DynamicalSemigroup_affine):
1283-
# raise TypeError("can only multiply `DynamicalSemigroup_affine` objects")
1284-
# if self._dynamical_systems[0].domain().dimension() != other_dynamical_semigroup._dynamical_systems[0].domain().dimension():
1285-
# raise ValueError("cannot multiply dynamical semigroups of different dimensions")
1286-
composite_systems = []
1287-
# my_polys = self.defining_polynomials()
1288-
# other_polys = other_dynamical_semigroup.defining_polynomials()
1289-
# for my_poly in my_polys:
1290-
# for other_poly in other_polys:
1291-
# composite_poly = []
1292-
# for coordinate_poly in my_poly:
1293-
# composite_poly.append(coordinate_poly(other_poly))
1294-
# composite_system = DynamicalSystem_affine(composite_poly)
1295-
# composite_systems.append(composite_system)
1296-
# for other_poly in other_polys:
1297-
# for my_poly in my_polys:
1298-
# composite_poly = []
1299-
# for coordinate_poly in other_poly:
1300-
# composite_poly.append(coordinate_poly(my_poly))
1301-
# composite_system = DynamicalSystem_affine(composite_poly)
1302-
# composite_systems.append(composite_system)
1303-
# for f in self.defining_systems():
1304-
# for g in other_dynamical_semigroup.defining_systems():
1305-
# composite_systems.append(f*g)
1306-
# return DynamicalSemigroup_affine(composite_systems)
1307-
13081143
class DynamicalSemigroup_affine_field(DynamicalSemigroup_affine):
13091144
pass
13101145

0 commit comments

Comments
 (0)