The dimension of this algebra is `(n^2 + n) / 2`::
sage: set_random_seed()
- sage: n_max = RealSymmetricEJA._max_random_instance_size()
- sage: n = ZZ.random_element(1, n_max)
+ sage: d = RealSymmetricEJA._max_random_instance_dimension()
+ sage: n = RealSymmetricEJA._max_random_instance_size(d)
sage: J = RealSymmetricEJA(n)
sage: J.dimension() == (n^2 + n)/2
True
@staticmethod
def _max_random_instance_size(max_dimension):
# Obtained by solving d = (n^2 + n)/2.
- return int(ZZ(8*max_dimension + 1).sqrt()/2 - 1/2)
+ # The ZZ-int-ZZ thing is just "floor."
+ return ZZ(int(ZZ(8*max_dimension + 1).sqrt()/2 - 1/2))
@classmethod
def random_instance(cls, max_dimension=None, **kwargs):
The dimension of this algebra is `n^2`::
sage: set_random_seed()
- sage: n_max = ComplexHermitianEJA._max_random_instance_size()
- sage: n = ZZ.random_element(1, n_max)
+ sage: d = ComplexHermitianEJA._max_random_instance_dimension()
+ sage: n = ComplexHermitianEJA._max_random_instance_size(d)
sage: J = ComplexHermitianEJA(n)
sage: J.dimension() == n^2
True
@staticmethod
def _max_random_instance_size(max_dimension):
# Obtained by solving d = n^2.
- return int(ZZ(max_dimension).sqrt())
+ # The ZZ-int-ZZ thing is just "floor."
+ return ZZ(int(ZZ(max_dimension).sqrt()))
@classmethod
def random_instance(cls, max_dimension=None, **kwargs):
The dimension of this algebra is `2*n^2 - n`::
sage: set_random_seed()
- sage: n_max = QuaternionHermitianEJA._max_random_instance_size()
- sage: n = ZZ.random_element(1, n_max)
+ sage: d = QuaternionHermitianEJA._max_random_instance_dimension()
+ sage: n = QuaternionHermitianEJA._max_random_instance_size(d)
sage: J = QuaternionHermitianEJA(n)
sage: J.dimension() == 2*(n^2) - n
True
The maximum rank of a random QuaternionHermitianEJA.
"""
# Obtained by solving d = 2n^2 - n.
- return int(ZZ(8*max_dimension + 1).sqrt()/4 + 1/4)
+ # The ZZ-int-ZZ thing is just "floor."
+ return ZZ(int(ZZ(8*max_dimension + 1).sqrt()/4 + 1/4))
@classmethod
def random_instance(cls, max_dimension=None, **kwargs):
two here so that said elements actually exist::
sage: set_random_seed()
- sage: n_max = max(2, JordanSpinEJA._max_random_instance_size())
- sage: n = ZZ.random_element(2, n_max)
+ sage: d_max = JordanSpinEJA._max_random_instance_dimension()
+ sage: n = ZZ.random_element(2, max(2,d_max))
sage: J = JordanSpinEJA(n)
sage: y = J.random_element()
sage: while y == y.coefficient(0)*J.one():
and in particular, a re-scaling of the basis::
sage: set_random_seed()
- sage: n_max = RealSymmetricEJA._max_random_instance_size()
- sage: n = ZZ.random_element(1, n_max)
+ sage: d_max = RealSymmetricEJA._max_random_instance_dimension()
+ sage: n = ZZ.random_element(1, d_max)
sage: J1 = RealSymmetricEJA(n)
sage: J2 = RealSymmetricEJA(n,orthonormalize=False)
sage: X = random_matrix(AA,n)