if orthonormalize:
# Now "self._matrix_span" is the vector space of our
- # algebra coordinates. The variables "X1", "X2",... refer
+ # algebra coordinates. The variables "X0", "X1",... refer
# to the entries of vectors in self._matrix_span. Thus to
# convert back and forth between the orthonormal
# coordinates and the given ones, we need to stick the
sage: J = JordanSpinEJA(3)
sage: p = J.characteristic_polynomial_of(); p
- X1^2 - X2^2 - X3^2 + (-2*t)*X1 + t^2
+ X0^2 - X1^2 - X2^2 + (-2*t)*X0 + t^2
sage: xvec = J.one().to_vector()
sage: p(*xvec)
t^2 - 2*t + 1
sage: J = HadamardEJA(2)
sage: J.coordinate_polynomial_ring()
- Multivariate Polynomial Ring in X1, X2...
+ Multivariate Polynomial Ring in X0, X1...
sage: J = RealSymmetricEJA(3,field=QQ,orthonormalize=False)
sage: J.coordinate_polynomial_ring()
- Multivariate Polynomial Ring in X1, X2, X3, X4, X5, X6...
+ Multivariate Polynomial Ring in X0, X1, X2, X3, X4, X5...
"""
- var_names = tuple( "X%d" % z for z in range(1, self.dimension()+1) )
+ var_names = tuple( "X%d" % z for z in range(self.dimension()) )
return PolynomialRing(self.base_ring(), var_names)
def inner_product(self, x, y):
sage: J = JordanSpinEJA(3)
sage: J._charpoly_coefficients()
- (X1^2 - X2^2 - X3^2, -2*X1)
+ (X0^2 - X1^2 - X2^2, -2*X0)
sage: a0 = J._charpoly_coefficients()[0]
sage: J.base_ring()
Algebraic Real Field
correct every once in a while. And they're in this separate file
because they are visually horrific.
-The function used to turn SageMath's output into the appropriate input
-can be found in the eja_utils module.
+SageMath's output can be converted back into "input form" using a sed
+script, for example:
+
+ $ sed -e 's/\^/\*\*/g' -e 's/X\([0-9][0-9]*\)/X\[\1\]/g' <input>
The simple algebras _not_ represented here all have rank two or less,
and are "easy" to compute even over the algebraic reals.
from sage.structure.element import is_Matrix
-def _charpoly_sage_input(s):
- r"""
- Helper function that you can use on the string output from sage
- to convert a charpoly coefficient into the corresponding input
- to be cached.
-
- SETUP::
-
- sage: from mjo.eja.eja_algebra import JordanSpinEJA
- sage: from mjo.eja.eja_utils import _charpoly_sage_input
-
- EXAMPLES::
-
- sage: J = JordanSpinEJA(4,QQ)
- sage: a = J._charpoly_coefficients()
- sage: a[0]
- X1^2 - X2^2 - X3^2 - X4^2
- sage: _charpoly_sage_input(str(a[0]))
- 'X[0]**2 - X[1]**2 - X[2]**2 - X[3]**2'
-
- """
- import re
-
- exponent_out = r"\^"
- exponent_in = r"**"
-
- digit_out = r"X([0-9]+)"
-
- def replace_digit(m):
- # m is a match object
- return "X[" + str(int(m.group(1)) - 1) + "]"
-
- s = re.sub(exponent_out, exponent_in, s)
- return re.sub(digit_out, replace_digit, s)
-
-
def _scale(x, alpha):
r"""
Scale the vector, matrix, or cartesian-product-of-those-things