return x.trace_inner_product(y)
+ def is_trivial(self):
+ """
+ Return whether or not this algebra is trivial.
+
+ A trivial algebra contains only the zero element.
+
+ SETUP::
+
+ sage: from mjo.eja.eja_algebra import ComplexHermitianEJA
+
+ EXAMPLES::
+
+ sage: J = ComplexHermitianEJA(3)
+ sage: J.is_trivial()
+ False
+ sage: A = J.zero().subalgebra_generated_by()
+ sage: A.is_trivial()
+ True
+
+ """
+ return self.dimension() == 0
+
+
def multiplication_table(self):
"""
Return a visual representation of this algebra's multiplication
return self.linear_combination(zip(self.gens(), coeffs))
+ def random_element(self):
+ # Temporary workaround for https://trac.sagemath.org/ticket/28327
+ if self.is_trivial():
+ return self.zero()
+ else:
+ s = super(FiniteDimensionalEuclideanJordanAlgebra, self)
+ return s.random_element()
+
+
def rank(self):
"""
Return the rank of this EJA.
sage: e2*e2
e2
+ TESTS:
+
+ We can change the generator prefix::
+
+ sage: RealCartesianProductEJA(3, prefix='r').gens()
+ (r0, r1, r2)
+
"""
- def __init__(self, n, field=QQ):
+ def __init__(self, n, field=QQ, **kwargs):
V = VectorSpace(field, n)
mult_table = [ [ V.gen(i)*(i == j) for j in range(n) ]
for i in range(n) ]
fdeja = super(RealCartesianProductEJA, self)
- return fdeja.__init__(field, mult_table, rank=n)
+ return fdeja.__init__(field, mult_table, rank=n, **kwargs)
def inner_product(self, x, y):
return _usual_ip(x,y)
sage: J(expected) == x*y
True
+ We can change the generator prefix::
+
+ sage: RealSymmetricEJA(3, prefix='q').gens()
+ (q0, q1, q2, q3, q4, q5)
+
"""
- def __init__(self, n, field=QQ):
+ def __init__(self, n, field=QQ, **kwargs):
S = _real_symmetric_basis(n, field=field)
Qs = _multiplication_table_from_matrix_basis(S)
return fdeja.__init__(field,
Qs,
rank=n,
- natural_basis=S)
+ natural_basis=S,
+ **kwargs)
def inner_product(self, x, y):
return _matrix_ip(x,y)
sage: J(expected) == x*y
True
+ We can change the generator prefix::
+
+ sage: ComplexHermitianEJA(2, prefix='z').gens()
+ (z0, z1, z2, z3)
+
"""
- def __init__(self, n, field=QQ):
+ def __init__(self, n, field=QQ, **kwargs):
S = _complex_hermitian_basis(n)
Qs = _multiplication_table_from_matrix_basis(S)
return fdeja.__init__(field,
Qs,
rank=n,
- natural_basis=S)
+ natural_basis=S,
+ **kwargs)
def inner_product(self, x, y):
sage: J(expected) == x*y
True
+ We can change the generator prefix::
+
+ sage: QuaternionHermitianEJA(2, prefix='a').gens()
+ (a0, a1, a2, a3, a4, a5)
+
"""
- def __init__(self, n, field=QQ):
+ def __init__(self, n, field=QQ, **kwargs):
S = _quaternion_hermitian_basis(n)
Qs = _multiplication_table_from_matrix_basis(S)
return fdeja.__init__(field,
Qs,
rank=n,
- natural_basis=S)
+ natural_basis=S,
+ **kwargs)
def inner_product(self, x, y):
# Since a+bi+cj+dk on the diagonal is represented as
sage: e2*e3
0
+ We can change the generator prefix::
+
+ sage: JordanSpinEJA(2, prefix='B').gens()
+ (B0, B1)
+
"""
- def __init__(self, n, field=QQ):
+ def __init__(self, n, field=QQ, **kwargs):
V = VectorSpace(field, n)
mult_table = [[V.zero() for j in range(n)] for i in range(n)]
for i in range(n):
# one-dimensional ambient space (because the rank is bounded by
# the ambient dimension).
fdeja = super(JordanSpinEJA, self)
- return fdeja.__init__(field, mult_table, rank=min(n,2))
+ return fdeja.__init__(field, mult_table, rank=min(n,2), **kwargs)
def inner_product(self, x, y):
return _usual_ip(x,y)