DGCV 0.2.4__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of DGCV might be problematic. Click here for more details.

Files changed (50) hide show
  1. {dgcv-0.2.4/src/DGCV.egg-info → dgcv-0.2.5}/PKG-INFO +1 -1
  2. {dgcv-0.2.4 → dgcv-0.2.5}/pyproject.toml +7 -3
  3. {dgcv-0.2.4 → dgcv-0.2.5}/setup.cfg +1 -1
  4. {dgcv-0.2.4 → dgcv-0.2.5}/setup.py +1 -1
  5. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/DGCVCore.py +1 -1
  6. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/RiemannianGeometry.py +2 -1
  7. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/_DGCV_display.py +60 -7
  8. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/__init__.py +19 -64
  9. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/complexStructures.py +3 -3
  10. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/coordinateMaps.py +1 -1
  11. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/finiteDimAlgebras.py +385 -2
  12. {dgcv-0.2.4 → dgcv-0.2.5/src/DGCV.egg-info}/PKG-INFO +1 -1
  13. {dgcv-0.2.4 → dgcv-0.2.5}/LICENSE.txt +0 -0
  14. {dgcv-0.2.4 → dgcv-0.2.5}/MANIFEST.in +0 -0
  15. {dgcv-0.2.4 → dgcv-0.2.5}/README.md +0 -0
  16. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/CRGeometry.py +0 -0
  17. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/DGCVFormatter.py +0 -0
  18. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/_safeguards.py +0 -0
  19. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/__init__.py +0 -0
  20. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Black.ttf +0 -0
  21. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Black.woff2 +0 -0
  22. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Bold.ttf +0 -0
  23. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Bold.woff2 +0 -0
  24. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-ExtraBold.ttf +0 -0
  25. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-ExtraBold.woff2 +0 -0
  26. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Medium.ttf +0 -0
  27. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Medium.woff2 +0 -0
  28. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Regular.ttf +0 -0
  29. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-Regular.woff2 +0 -0
  30. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-SemiBold.ttf +0 -0
  31. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/Orbitron-SemiBold.woff2 +0 -0
  32. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/PatrickHand-Regular.ttf +0 -0
  33. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/fonts/fonts.css +0 -0
  34. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/__init__.py +0 -0
  35. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/populator.ipynb +0 -0
  36. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_2x2.py +0 -0
  37. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_3x3.py +0 -0
  38. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_4x4.py +0 -0
  39. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_5x5.py +0 -0
  40. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_6x6.py +0 -0
  41. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/assets/inversions/precomputed_7x7.py +0 -0
  42. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/combinatorics.py +0 -0
  43. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/config.py +0 -0
  44. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/polynomials.py +0 -0
  45. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/styles.py +0 -0
  46. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV/vectorFieldsAndDifferentialForms.py +0 -0
  47. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV.egg-info/SOURCES.txt +0 -0
  48. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV.egg-info/dependency_links.txt +0 -0
  49. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV.egg-info/requires.txt +0 -0
  50. {dgcv-0.2.4 → dgcv-0.2.5}/src/DGCV.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DGCV
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Differential Geometry with Complex Variables
5
5
  Author: David Sykes
6
6
  Author-email: David Sykes <david@realandimaginary.com>
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  requires-python = ">=3.6"
7
7
  name = "DGCV"
8
- version = "0.2.4"
8
+ version = "0.2.5"
9
9
  description = "Differential Geometry with Complex Variables"
10
10
  authors = [{ name = "David Sykes", email = "david@realandimaginary.com" }]
11
11
  license = { text = "MIT" }
@@ -14,11 +14,15 @@ readme = "README.md"
14
14
 
15
15
  [tool.ruff]
16
16
  line-length = 88
17
- select = ["F", "E", "W", "I"]
18
17
  extend-exclude = ["_build", "buck-out", "build", "dist", "tutorials"]
19
18
 
20
19
  [tool.ruff.lint]
21
- ignore = ["E501", "Q", "W291"]
20
+ select = ["F", "E", "W", "I"] # Move linter rules to this section
21
+ ignore = ["E501", "Q", "W291"] # Add global ignores here if needed
22
+
23
+ # Move per-file-ignores to the lint section
24
+ [tool.ruff.lint.per-file-ignores]
25
+ "__init__.py" = ["E402"]
22
26
 
23
27
  [tool.black]
24
28
  line-length = 88
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = DGCV
3
- version = 0.2.4
3
+ version = 0.2.5
4
4
  description = A package for Differential Geometry with Complex Variables
5
5
  author = David Sykes
6
6
  author_email = david@realandimaginary.com
@@ -15,7 +15,7 @@ To get started, check out the Jupyter Notebook tutorials:
15
15
 
16
16
  setup(
17
17
  name="DGCV",
18
- version="0.2.4",
18
+ version="0.2.5",
19
19
  description="Differential Geometry with Complex Variables",
20
20
  long_description=long_description, # This shows up on PyPI
21
21
  long_description_content_type="text/markdown",
@@ -4126,7 +4126,7 @@ def createVariables(
4126
4126
  warnings.warn(
4127
4127
  "`createVariables` was called with `complex=True` and `assumeReal=True`. The latter keyword was disregarded because DGCV has fixed variable assumptions for elements in its complex variable systems."
4128
4128
  )
4129
- if not complex and any([real_label is not None, imaginary_label is not None]):
4129
+ if complex == False and any([real_label is not None, imaginary_label is not None]): # noqa: E712
4130
4130
  warnings.warn(
4131
4131
  "`createVariables` recieved `complex=False` and recieved values for the `real_label` or `imaginary_label` keywords. Honoring `complex=False`, only a standard variable system was created, and latter labels were disregarded. Set `complex=True` if a complex variable system is needed instead."
4132
4132
  )
@@ -23,6 +23,7 @@ Dependencies:
23
23
  License:
24
24
  MIT License
25
25
  """
26
+ import re
26
27
  import warnings
27
28
 
28
29
  import sympy as sp
@@ -887,7 +888,7 @@ class metricClass(sp.Basic):
887
888
  var_str = var_str[3:]
888
889
 
889
890
  # Regular expression to match label part and trailing number part
890
- match = sp.re.match(
891
+ match = re.match(
891
892
  r"([a-zA-Z_]+)(\d*)$", var_str
892
893
  ) # Match label followed by optional digits
893
894
 
@@ -1,7 +1,7 @@
1
1
  """
2
2
  _display.py
3
3
 
4
- This module provides functions for customizing font display in Jupyter notebooks.
4
+ This module provides functions for customizing the display in Jupyter notebooks.
5
5
  The `load_fonts()` function loads web fonts and applies them to the notebook
6
6
  environment using HTML and CSS.
7
7
 
@@ -10,10 +10,14 @@ Functions
10
10
  - load_fonts: Injects HTML and CSS to load Google Fonts and apply custom fonts to the notebook.
11
11
  """
12
12
 
13
- import sympy
13
+
14
+ ############# for printing
15
+ import sympy as sp
14
16
  from IPython.display import HTML, Latex, display
15
- from sympy import Basic, latex
17
+ from sympy import Basic, latex # Rename SymPy's latex
18
+ from sympy.printing.latex import LatexPrinter
16
19
 
20
+ ############# DGCV classes to format
17
21
  from .DGCVCore import (
18
22
  DFClass,
19
23
  DGCVPolyClass,
@@ -100,7 +104,7 @@ def _display_DGCV_single(arg):
100
104
  display(Latex(arg))
101
105
  elif isinstance(
102
106
  arg,
103
- (sympy.Expr, metricClass, DFClass, VFClass, TFClass, STFClass, DGCVPolyClass),
107
+ (sp.Expr, metricClass, DFClass, VFClass, TFClass, STFClass, DGCVPolyClass),
104
108
  ):
105
109
  _complexDisplay(arg)
106
110
  elif isinstance(arg, FAClass):
@@ -157,13 +161,13 @@ class _alglabeldisplayclass(Basic):
157
161
  ) # Suppress 1 but keep the negative sign
158
162
  else:
159
163
  # Check if the coefficient has more than one term (e.g., 1 + I)
160
- if isinstance(coeff, sympy.Expr) and len(coeff.args) > 1:
164
+ if isinstance(coeff, sp.Expr) and len(coeff.args) > 1:
161
165
  terms.append(
162
- rf"({sympy.latex(coeff)}) \cdot {basis_label}"
166
+ rf"({sp.latex(coeff)}) \cdot {basis_label}"
163
167
  ) # Wrap multi-term coefficient in parentheses
164
168
  else:
165
169
  terms.append(
166
- rf"{sympy.latex(coeff)} \cdot {basis_label}"
170
+ rf"{sp.latex(coeff)} \cdot {basis_label}"
167
171
  ) # Single-term coefficient
168
172
 
169
173
  # Handle special case: all zero coefficients
@@ -215,3 +219,52 @@ def load_fonts():
215
219
  </style>
216
220
  """
217
221
  display(HTML(font_links))
222
+
223
+
224
+
225
+ # DGCV-specific SymPy LatexPrinter for VFClass and DFClass
226
+ class DGCVLatexPrinter(LatexPrinter):
227
+ def _print_VFClass(self, expr):
228
+ return expr._repr_latex_()
229
+
230
+ def _print_DFClass(self, expr):
231
+ return expr._repr_latex_()
232
+
233
+
234
+ def DGCV_collection_latex_printer(obj):
235
+ if isinstance(obj, (tuple, list)):
236
+ return tuple(
237
+ Latex(element._repr_latex_() if hasattr(element, "_repr_latex_") else latex(element))
238
+ for element in obj
239
+ )
240
+ return None
241
+
242
+
243
+ def DGCV_latex_printer(obj, **kwargs):
244
+ if isinstance(
245
+ obj,
246
+ (
247
+ VFClass,
248
+ DFClass,
249
+ TFClass,
250
+ STFClass,
251
+ metricClass,
252
+ FAClass,
253
+ AlgebraElement,
254
+ DGCVPolyClass,
255
+ ),
256
+ ):
257
+ latex_str = obj._repr_latex_()
258
+ return latex_str.strip("$")
259
+ elif isinstance(obj, (list, tuple)):
260
+ latex_elements = [DGCV_latex_printer(elem) for elem in obj]
261
+ return r"\left( " + r" , ".join(latex_elements) + r" \right)"
262
+ return latex(obj, **kwargs)
263
+
264
+
265
+ def DGCV_init_printing(*args, **kwargs):
266
+ load_fonts()
267
+ from sympy import init_printing
268
+
269
+ kwargs["latex_printer"] = DGCV_latex_printer
270
+ init_printing(*args, **kwargs)
@@ -51,14 +51,20 @@ License:
51
51
  """
52
52
 
53
53
  # Imports
54
- from IPython.display import Latex
55
- from sympy import latex
56
- from sympy.printing.latex import LatexPrinter
57
54
 
58
- from ._DGCV_display import LaTeX, display_DGCV, load_fonts
55
+ from .config import cache_globals, configure_warnings, get_variable_registry
56
+
57
+ ############# Variable Management Framework (VMF) tools
58
+ # Initialize the globals pointer cache when DGCV is imported
59
+ cache_globals()
60
+
61
+ # Initialize variable_registry when DGCV is imported
62
+ _ = get_variable_registry()
63
+
64
+
65
+ from ._DGCV_display import DGCV_init_printing, LaTeX, display_DGCV
59
66
  from .combinatorics import carProd, chooseOp, permSign
60
67
  from .complexStructures import Del, DelBar, KahlerStructure
61
- from .config import cache_globals, configure_warnings, get_variable_registry
62
68
  from .coordinateMaps import coordinate_map
63
69
  from .CRGeometry import (
64
70
  findWeightedCRSymmetries,
@@ -123,6 +129,7 @@ from .finiteDimAlgebras import (
123
129
  adjointRepresentation,
124
130
  algebraDataFromMatRep,
125
131
  algebraDataFromVF,
132
+ createClassicalLA,
126
133
  createFiniteAlg,
127
134
  killingForm,
128
135
  )
@@ -153,27 +160,17 @@ from .vectorFieldsAndDifferentialForms import (
153
160
  makeZeroForm,
154
161
  )
155
162
 
156
- # Initialize global caches and variable registry
157
- cache_globals()
158
- _ = get_variable_registry()
159
-
160
- # Configure warnings
161
- configure_warnings()
162
-
163
163
  # Default functions/classes
164
164
  __all__ = [
165
165
  ############ DGCV default functions/classes ####
166
- # From config
167
- "cache_globals", # Initialize global caches
168
- "configure_warnings", # Configure DGCV warnings
169
- "get_variable_registry",# Get the DGCV variable registry
170
166
 
171
167
  # From _DGCV_display
172
- "LaTeX", # Custom LaTeX renderer
173
- "load_fonts", # Load custom fonts for LaTeX output
168
+ "LaTeX", # Custom LaTeX renderer for DGCV objects
174
169
  "display_DGCV", # Augments IPython.display.display
175
170
  # with support for DGCV object like
176
171
  # custom latex rendering
172
+ "DGCV_init_printing", # Augments SymPy.init_printing for DGCV
173
+ # objects
177
174
 
178
175
  # From combinatorics
179
176
  "carProd", # Cartesian product
@@ -251,6 +248,7 @@ __all__ = [
251
248
  # From finiteDimAlgebras
252
249
  "AlgebraElement", # Algebra element class
253
250
  "FAClass", # Finite dimensional algebra class
251
+ "createClassicalLA", # Initialize classicle simple L.A.
254
252
  "adjointRepresentation",# Adjoint representation of algebra
255
253
  "algebraDataFromMatRep",# Algebra data from matrix representation
256
254
  "algebraDataFromVF", # Algebra data from vector fields
@@ -286,49 +284,6 @@ __all__ = [
286
284
  "makeZeroForm", # Create zero-form from scalar
287
285
  ]
288
286
 
289
- # DGCV-specific SymPy LatexPrinter for VFClass and DFClass
290
- class DGCVLatexPrinter(LatexPrinter):
291
- def _print_VFClass(self, expr):
292
- return expr._repr_latex_()
293
-
294
- def _print_DFClass(self, expr):
295
- return expr._repr_latex_()
296
-
297
-
298
- def DGCV_collection_latex_printer(obj):
299
- if isinstance(obj, (tuple, list)):
300
- return tuple(
301
- Latex(element._repr_latex_() if hasattr(element, "_repr_latex_") else latex(element))
302
- for element in obj
303
- )
304
- return None
305
-
306
-
307
- def DGCV_latex_printer(obj, **kwargs):
308
- if isinstance(
309
- obj,
310
- (
311
- VFClass,
312
- DFClass,
313
- TFClass,
314
- STFClass,
315
- metricClass,
316
- FAClass,
317
- AlgebraElement,
318
- DGCVPolyClass,
319
- ),
320
- ):
321
- latex_str = obj._repr_latex_()
322
- return latex_str.strip("$")
323
- elif isinstance(obj, (list, tuple)):
324
- latex_elements = [DGCV_latex_printer(elem) for elem in obj]
325
- return r"\left( " + r" , ".join(latex_elements) + r" \right)"
326
- return latex(obj, **kwargs)
327
-
328
-
329
- def DGCV_init_printing(*args, **kwargs):
330
- load_fonts()
331
- from sympy import init_printing
332
-
333
- kwargs["latex_printer"] = DGCV_latex_printer
334
- init_printing(*args, **kwargs)
287
+
288
+ # Configure warnings
289
+ configure_warnings()
@@ -38,7 +38,7 @@ from .DGCVCore import (
38
38
  symToReal,
39
39
  )
40
40
  from .RiemannianGeometry import metricClass
41
- from .vectorFieldsAndDifferentialForms import makeZeroForm
41
+ from .vectorFieldsAndDifferentialForms import exteriorDerivative, makeZeroForm
42
42
 
43
43
  ############## Dolbeault operators
44
44
 
@@ -467,7 +467,7 @@ class KahlerStructure(sp.Basic):
467
467
  @property
468
468
  def metric(self):
469
469
  if self._metric is None:
470
- if not self._is_closed:
470
+ if not self.is_closed:
471
471
  warnings.warn(
472
472
  "The provided symplectic form does not define a Kahler structure, so the associated metric tensor may not actually describe a metric."
473
473
  )
@@ -587,5 +587,5 @@ class KahlerStructure(sp.Basic):
587
587
  @property
588
588
  def is_closed(self):
589
589
  if self._is_closed is None:
590
- self._is_closed = self.kahlerForm.is_zero()
590
+ self._is_closed = exteriorDerivative(self.kahlerForm).is_zero()
591
591
  return self._is_closed
@@ -77,7 +77,7 @@ class coordinate_map(Basic):
77
77
 
78
78
  @property
79
79
  def JacobianMatrix(self):
80
- if self._JacobianMatrix:
80
+ if self._JacobianMatrix is None:
81
81
  self._JacobianMatrix = [
82
82
  [simplify(j(k)) for j in self.domain_frame]
83
83
  for k in self.coordinate_formulas
@@ -3,7 +3,6 @@ import random
3
3
  import warnings
4
4
 
5
5
  import sympy as sp
6
- from vectorFieldsAndDifferentialForms import VF_bracket
7
6
 
8
7
  from ._safeguards import (
9
8
  create_key,
@@ -16,6 +15,7 @@ from ._safeguards import (
16
15
  from .config import _cached_caller_globals
17
16
  from .DGCVCore import VFClass, addVF, allToReal, clearVar, listVar, variableProcedure
18
17
  from .styles import get_style
18
+ from .vectorFieldsAndDifferentialForms import VF_bracket
19
19
 
20
20
  ############## Algebras
21
21
 
@@ -1155,6 +1155,65 @@ class FAClass(sp.Basic):
1155
1155
  # Return as a list of lists
1156
1156
  return structure_matrix
1157
1157
 
1158
+ def is_ideal(self, subspace_elements):
1159
+ """
1160
+ Checks if the given list of elgebra elements spans an ideal.
1161
+
1162
+ Parameters
1163
+ ----------
1164
+ subspace_elements : list
1165
+ A list of AlgebraElement instances representing the subspace
1166
+ they span.
1167
+
1168
+ Returns
1169
+ -------
1170
+ bool
1171
+ True if the subspace is an ideal, False otherwise.
1172
+
1173
+ Raises
1174
+ ------
1175
+ ValueError
1176
+ If the provided elements do not belong to this algebra.
1177
+ """
1178
+ # Ensure all subspace elements belong to this algebra
1179
+ for el in subspace_elements:
1180
+ if not isinstance(el, AlgebraElement) or el.algebra != self:
1181
+ raise ValueError("All elements in subspace_elements must belong to this algebra.")
1182
+
1183
+ # Check the ideal condition
1184
+ for el in subspace_elements:
1185
+ for other in self.basis:
1186
+ # Compute the product and check if it is in the span of subspace_elements
1187
+ product = el * other
1188
+ if not self.is_in_span(product, subspace_elements):
1189
+ return False
1190
+ return True
1191
+
1192
+ def is_in_span(self, element, subspace_elements):
1193
+ """
1194
+ Checks if a given AlgebraElement is in the span of subspace_elements.
1195
+
1196
+ Parameters
1197
+ ----------
1198
+ element : AlgebraElement
1199
+ The element to check.
1200
+ subspace_elements : list
1201
+ A list of AlgebraElement instances representing the subspace they span.
1202
+
1203
+ Returns
1204
+ -------
1205
+ bool
1206
+ True if the element is in the span of subspace_elements, False otherwise.
1207
+ """
1208
+ # Build a matrix where columns are the coefficients of subspace_elements
1209
+ span_matrix = sp.Matrix.hstack(*[el.coeffs for el in subspace_elements])
1210
+
1211
+ # Solve for the coefficients that express `element` as a linear combination
1212
+ product_vector = sp.Matrix(element.coeffs)
1213
+ solution = span_matrix.solve_least_squares(product_vector)
1214
+
1215
+ # Check if the solution satisfies the equation
1216
+ return span_matrix * solution == product_vector
1158
1217
 
1159
1218
  # algebra element class
1160
1219
  class AlgebraElement(sp.Basic):
@@ -1462,7 +1521,7 @@ class AlgebraElement(sp.Basic):
1462
1521
  return self.algebra.check_element_weight(self)
1463
1522
 
1464
1523
 
1465
- ############## finite algebra creation and tools
1524
+ ############## finite algebra creation
1466
1525
 
1467
1526
 
1468
1527
  def createFiniteAlg(
@@ -1498,6 +1557,10 @@ def createFiniteAlg(
1498
1557
  If True, provides detailed feedback during the creation process.
1499
1558
  """
1500
1559
 
1560
+ if label in listVar(algebras_only=True):
1561
+ warnings.warn('`createFiniteAlg` was called with a `label` already assigned to another algebra, so `createFiniteAlg` will overwrite the other algebra.')
1562
+ clearVar(label)
1563
+
1501
1564
  def validate_structure_data(data, process_matrix_rep=False):
1502
1565
  """
1503
1566
  Validates the structure data and converts it to a list of lists of lists.
@@ -1951,6 +2014,326 @@ def algebraDataFromMatRep(mat_list):
1951
2014
  raise Exception("algebraDataFromMatRep expects a list of square matrices.")
1952
2015
 
1953
2016
 
2017
+ def createClassicalLA(
2018
+ series: str,
2019
+ label: str = None,
2020
+ basis_labels: list = None,
2021
+ ):
2022
+ """
2023
+ Creates a simple (with 2 exceptions) complex Lie algebra specified from the classical
2024
+ series
2025
+ - A_n = sl(n+1) for n>0
2026
+ - B_n = so(2n+1) for n>0
2027
+ - C_n = sp(2n) for n>0
2028
+ - D_n = so(2n) for n>0 (not simple for n=1,2)
2029
+
2030
+
2031
+ Parameters
2032
+ ----------
2033
+ series : str
2034
+ The type and rank of the Lie algebra, e.g., "A1", "A2", ..., "Dn".
2035
+ label : str, optional
2036
+ Custom label for the Lie algebra. If not provided, defaults to a standard notation,
2037
+ like sl2 for A2 etc.
2038
+ basis_labels : list, optional
2039
+ Custom labels for the basis elements. If not provided, default labels will be generated.
2040
+
2041
+ Returns
2042
+ -------
2043
+ FAClass
2044
+ The resulting Lie algebra as an FAClass instance.
2045
+
2046
+ Raises
2047
+ ------
2048
+ ValueError
2049
+ If the series is not recognized or not implemented.
2050
+
2051
+ Notes
2052
+ -----
2053
+ - Currently supports only the A series (special linear Lie algebras: A_n = sl(n+1)).
2054
+ """
2055
+ # Extract series type and rank
2056
+ try:
2057
+ series_type, rank = series[0], int(series[1:])
2058
+ except (IndexError, ValueError):
2059
+ raise ValueError(f"Invalid series format: {series}. Expected a letter 'A', 'B', 'C', or 'D' followed by a positive integer, like 'A1', 'B5', etc.")
2060
+ if rank <= 0:
2061
+ raise ValueError(f"Sequence index must be a positive integer, but got: {rank}.")
2062
+
2063
+ def generate_A_series_structure_data(n):
2064
+ """
2065
+ Generates the structure data and weights for the A_n series (special linear: sl(n+1)).
2066
+
2067
+ Parameters
2068
+ ----------
2069
+ n : int
2070
+ The relevant term in the A-series
2071
+
2072
+ Returns
2073
+ -------
2074
+ tuple
2075
+ - basis (list): A 3-dimensional list representing the structure data for sl(n+1).
2076
+ Each element is a 2D list of lists representing a trace-free (n+1)x(n+1) matrix.
2077
+ - weight_vectors (list): A list containing one inner list representing the weight vectors of the basis.
2078
+
2079
+ Notes
2080
+ -----
2081
+ - Basis includes off-diagonal elementary matrices E_{j,k} (j < k first, then j > k).
2082
+ - Diagonal basis elements are trace-free combinations of E_{j,j}.
2083
+ - Weight vectors:
2084
+ - Off-diagonal E_{j,k} is assigned weight j-k.
2085
+ - Diagonal trace-free matrices are assigned weight 0.
2086
+ """
2087
+ # Dimension of the matrices
2088
+ matrix_dim = n + 1
2089
+
2090
+ # Basis elements and weight vectors
2091
+ basis = []
2092
+ weight_vectors = []
2093
+
2094
+ # Add off-diagonal elements with j < k
2095
+ for j in range(matrix_dim):
2096
+ for k in range(j + 1, matrix_dim):
2097
+ E_jk = [[0] * matrix_dim for _ in range(matrix_dim)]
2098
+ E_jk[j][k] = 1 # Set the (j, k)-entry to 1
2099
+ basis.append(E_jk)
2100
+ weight_vectors.append(j - k)
2101
+
2102
+ # Add diagonal trace-free elements
2103
+ for j in range(matrix_dim - 1):
2104
+ E_diag = [[0] * matrix_dim for _ in range(matrix_dim)]
2105
+ E_diag[j][j] = 1 # +1 for the j-th diagonal entry
2106
+ E_diag[j + 1][j + 1] = -1 # -1 for the (j+1)-th diagonal entry
2107
+ basis.append(E_diag)
2108
+ weight_vectors.append(0)
2109
+
2110
+ # Add off-diagonal elements with j > k
2111
+ for j in range(matrix_dim):
2112
+ for k in range(j):
2113
+ E_jk = [[0] * matrix_dim for _ in range(matrix_dim)]
2114
+ E_jk[j][k] = 1 # Set the (j, k)-entry to 1
2115
+ basis.append(E_jk)
2116
+ weight_vectors.append(j - k)
2117
+
2118
+ # Wrap weight vectors in a list (for compatibility with multiple weight systems)
2119
+ weight_vectors = [weight_vectors]
2120
+
2121
+ return basis, weight_vectors
2122
+
2123
+ def generate_B_series_structure_data(n):
2124
+ """
2125
+ Generates the structure data the B_n series
2126
+ (special orthogonal: so(2n+1)).
2127
+
2128
+ Parameters
2129
+ ----------
2130
+ n : int
2131
+ The rank of the B-series Lie algebra (2n+1 is the matrix dimension).
2132
+
2133
+ Returns
2134
+ -------
2135
+ tuple
2136
+ - basis (list): A 3-dimensional list representing the structure data for so(2n+1).
2137
+ Each element is a 2D list of lists representing a skew-symmetric (2n+1)x(2n+1) matrix.
2138
+ - weight_vectors (list): An empty list (weights not assigned for B-series).
2139
+
2140
+ Notes
2141
+ -----
2142
+ - Basis includes skew-symmetric matrices E_{j,k} - E_{k,j} (j < k).
2143
+ - Weight vector assignment for B-series is non-trivial and left empty for now.
2144
+ """
2145
+ # Dimension of the matrices
2146
+ matrix_dim = 2 * n + 1
2147
+
2148
+ # Basis elements
2149
+ basis = []
2150
+
2151
+ # Generate skew-symmetric off-diagonal matrices E_{j,k} - E_{k,j}
2152
+ for j in range(matrix_dim):
2153
+ for k in range(j + 1, matrix_dim):
2154
+ # Create a zero matrix
2155
+ skew_symmetric = [[0] * matrix_dim for _ in range(matrix_dim)]
2156
+ skew_symmetric[j][k] = 1 # Set the (j, k)-entry to 1
2157
+ skew_symmetric[k][j] = -1 # Set the (k, j)-entry to -1
2158
+ basis.append(skew_symmetric)
2159
+
2160
+ # Return basis and empty weight_vectors
2161
+ return basis, None
2162
+
2163
+ def generate_C_series_structure_data(n):
2164
+ """
2165
+ Generates the structure data and weight vectors for the C_n series
2166
+ (symplectic Lie algebra: sp(2n)).
2167
+
2168
+ Parameters
2169
+ ----------
2170
+ n : int
2171
+ The rank of the C-series Lie algebra (2n is the matrix dimension).
2172
+
2173
+ Returns
2174
+ -------
2175
+ tuple
2176
+ - basis (list): A 3-dimensional list representing the structure data for sp(2n).
2177
+ Each element is a 2D list of lists representing a matrix.
2178
+ - weight_vectors (list): A single weight vector for the basis elements,
2179
+ representing a grading of the algebra.
2180
+
2181
+ Notes
2182
+ -----
2183
+ - Basis matrices are partitioned into nxn blocks and constructed in three groups:
2184
+ 1. Lower block triangular: [[0, 0], [S_{j,k}, 0]] (weight = -1).
2185
+ 2. Block diagonal: [[E_{j,k}, 0], [0, -E_{k,j}]] (weight = 0).
2186
+ 3. Upper block triangular: [[0, S_{j,k}], [0, 0]] (weight = 1).
2187
+ """
2188
+ # Dimension of the full matrices
2189
+ matrix_dim = 2 * n
2190
+
2191
+ # Basis elements and weight vector
2192
+ basis = []
2193
+ weight_vector = []
2194
+
2195
+ # Step 1: Create symmetric matrices S_{j,k} = E_{j,k} + E_{k,j} for j ≤ k
2196
+ symmetric_matrices = []
2197
+ for j in range(n):
2198
+ for k in range(j, n):
2199
+ S = [[0] * n for _ in range(n)]
2200
+ S[j][k] = 1
2201
+ if j != k:
2202
+ S[k][j] = 1
2203
+ symmetric_matrices.append(S)
2204
+
2205
+ # Step 2: Create pairs P_{j,k} = (E_{j,k}, -E_{k,j})
2206
+ matrix_pairs = []
2207
+ for j in range(n):
2208
+ for k in range(n):
2209
+ P1 = [[0] * n for _ in range(n)]
2210
+ P2 = [[0] * n for _ in range(n)]
2211
+ P1[j][k] = 1
2212
+ P2[k][j] = -1
2213
+ matrix_pairs.append((P1, P2))
2214
+
2215
+ # Step 3: Create basis matrices in three groups
2216
+ # Group 1: Lower block triangular [[0, 0], [S_{j,k}, 0]] (weight = -1)
2217
+ for S in symmetric_matrices:
2218
+ lower_triangular = [[0] * matrix_dim for _ in range(matrix_dim)]
2219
+ # Insert S into the lower-left block
2220
+ for i in range(n):
2221
+ for j in range(n):
2222
+ lower_triangular[n + i][j] = S[i][j]
2223
+ basis.append(lower_triangular)
2224
+ weight_vector.append(-1)
2225
+
2226
+ # Group 2: Block diagonal [[E_{j,k}, 0], [0, -E_{k,j}]] (weight = 0)
2227
+ for P1, P2 in matrix_pairs:
2228
+ block_diagonal = [[0] * matrix_dim for _ in range(matrix_dim)]
2229
+ # Insert P1 into the top-left block and P2 into the bottom-right block
2230
+ for i in range(n):
2231
+ for j in range(n):
2232
+ block_diagonal[i][j] = P1[i][j]
2233
+ block_diagonal[n + i][n + j] = P2[i][j]
2234
+ basis.append(block_diagonal)
2235
+ weight_vector.append(0)
2236
+
2237
+ # Group 3: Upper block triangular [[0, S_{j,k}], [0, 0]] (weight = 1)
2238
+ for S in symmetric_matrices:
2239
+ upper_triangular = [[0] * matrix_dim for _ in range(matrix_dim)]
2240
+ # Insert S into the upper-right block
2241
+ for i in range(n):
2242
+ for j in range(n):
2243
+ upper_triangular[i][n + j] = S[i][j]
2244
+ basis.append(upper_triangular)
2245
+ weight_vector.append(1)
2246
+
2247
+ # Return basis and weight vector wrapped in a list (to allow multiple gradings)
2248
+ return basis, [weight_vector]
2249
+
2250
+ def generate_D_series_structure_data(n):
2251
+ """
2252
+ Generates the structure data and an empty weight vector for the D_n series
2253
+ (special orthogonal Lie algebra: so(2n)).
2254
+
2255
+ Parameters
2256
+ ----------
2257
+ n : int
2258
+ The rank of the D-series Lie algebra (2n is the matrix dimension).
2259
+
2260
+ Returns
2261
+ -------
2262
+ tuple
2263
+ - basis (list): A 3-dimensional list representing the structure data for so(2n).
2264
+ Each element is a 2D list of lists representing a matrix.
2265
+ - weight_vectors (list): An empty list (weights not assigned for D-series).
2266
+
2267
+ Notes
2268
+ -----
2269
+ - Reuses the skew-symmetric construction logic from the B-series generator.
2270
+ - The weight vector assignment for D-series is left empty for now.
2271
+ """
2272
+ return generate_B_series_structure_data(n)
2273
+
2274
+ # A-series implementation
2275
+ if series_type == "A":
2276
+ default_label = f"sl{rank + 1}" if label is None else label
2277
+ # Compute structure data for sl(n+1)
2278
+ structure_data, grading = generate_A_series_structure_data(rank)
2279
+ # Create and return the Lie algebra
2280
+ return createFiniteAlg(
2281
+ structure_data,
2282
+ default_label,
2283
+ basis_labels=basis_labels,
2284
+ grading=grading,
2285
+ process_matrix_rep=True
2286
+ )
2287
+
2288
+ # B-series implementation
2289
+ elif series_type == "B":
2290
+ default_label = f"so{2*rank + 1}" if label is None else label
2291
+ # Compute structure data for so(2n+1)
2292
+ structure_data, grading = generate_B_series_structure_data(rank)
2293
+ # Create and return the Lie algebra
2294
+ return createFiniteAlg(
2295
+ structure_data,
2296
+ default_label,
2297
+ basis_labels=basis_labels,
2298
+ grading=grading,
2299
+ process_matrix_rep=True
2300
+ )
2301
+
2302
+ # C-series implementation
2303
+ elif series_type == "C":
2304
+ default_label = f"sp{2*rank}" if label is None else label
2305
+ # Compute structure data for sp(2n)
2306
+ structure_data, grading = generate_C_series_structure_data(rank)
2307
+ # Create and return the Lie algebra
2308
+ return createFiniteAlg(
2309
+ structure_data,
2310
+ default_label,
2311
+ basis_labels=basis_labels,
2312
+ grading=grading,
2313
+ process_matrix_rep=True
2314
+ )
2315
+
2316
+ # D-series implementation
2317
+ elif series_type == "D":
2318
+ default_label = f"so{2*rank}" if label is None else label
2319
+ # Compute structure data for so(2n)
2320
+ structure_data, grading = generate_D_series_structure_data(rank)
2321
+ # Create and return the Lie algebra
2322
+ return createFiniteAlg(
2323
+ structure_data,
2324
+ default_label,
2325
+ basis_labels=basis_labels,
2326
+ grading=grading,
2327
+ process_matrix_rep=True
2328
+ )
2329
+
2330
+ # Raise an error for unrecognized series
2331
+ else:
2332
+ raise ValueError(f"Series type '{series_type}' is not recognized. Expected 'A', 'B', 'C', or 'D'.")
2333
+
2334
+
2335
+ ############## algebra tools
2336
+
1954
2337
  def killingForm(arg1, list_processing=False):
1955
2338
  if arg1.__class__.__name__ == "FAClass":
1956
2339
  # Convert the structure data to a mutable array
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DGCV
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Differential Geometry with Complex Variables
5
5
  Author: David Sykes
6
6
  Author-email: David Sykes <david@realandimaginary.com>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes