From a28f34edd45e649f9bcd8100f57c812d917d46b4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 29 Jul 2019 00:11:56 -0400 Subject: [PATCH] eja: add and update a few docstrings and tests. --- mjo/eja/eja_algebra.py | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/mjo/eja/eja_algebra.py b/mjo/eja/eja_algebra.py index cd39704..f88a552 100644 --- a/mjo/eja/eja_algebra.py +++ b/mjo/eja/eja_algebra.py @@ -481,7 +481,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): SETUP:: - sage: from mjo.eja.eja_algebra import RealSymmetricEJA + sage: from mjo.eja.eja_algebra import (RealSymmetricEJA, + ....: random_eja) EXAMPLES: @@ -501,6 +502,18 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): ... ArithmeticError: vector is not in free module + TESTS: + + Ensure that we can convert any element of the parent's + underlying vector space back into an algebra element whose + vector representation is what we started with:: + + sage: set_random_seed() + sage: J = random_eja() + sage: v = J.vector_space().random_element() + sage: J(v).vector() == v + True + """ # Goal: if we're given a matrix, and if it lives in our # parent algebra's "natural ambient space," convert it @@ -533,21 +546,21 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): Jordan algebras are always power-associative; see for example Faraut and Koranyi, Proposition II.1.2 (ii). - .. WARNING: - - We have to override this because our superclass uses row vectors - instead of column vectors! We, on the other hand, assume column - vectors everywhere. + We have to override this because our superclass uses row + vectors instead of column vectors! We, on the other hand, + assume column vectors everywhere. SETUP:: sage: from mjo.eja.eja_algebra import random_eja - EXAMPLES:: + TESTS: + + The definition of `x^2` is the unambiguous `x*x`:: sage: set_random_seed() sage: x = random_eja().random_element() - sage: x.operator()(x) == (x^2) + sage: x*x == (x^2) True A few examples of power-associativity:: @@ -653,6 +666,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: J.zero().characteristic_polynomial() t^3 + TESTS: + The characteristic polynomial of an element should evaluate to zero on that element:: @@ -770,8 +785,8 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): sage: lhs == rhs True - Test the first polarization identity from my notes, Koecher Chapter - III, or from Baes (2.3):: + Test the first polarization identity from my notes, Koecher + Chapter III, or from Baes (2.3):: sage: set_random_seed() sage: J = random_eja() @@ -954,9 +969,6 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): """ Return whether or not this element is invertible. - We can't use the superclass method because it relies on - the algebra being associative. - ALGORITHM: The usual way to do this is to check if the determinant is @@ -966,6 +978,9 @@ class FiniteDimensionalEuclideanJordanAlgebra(FiniteDimensionalAlgebra): whether or not the paren't algebra's zero element is a root of this element's minimal polynomial. + Beware that we can't use the superclass method, because it + relies on the algebra being associative. + SETUP:: sage: from mjo.eja.eja_algebra import random_eja -- 2.43.2