Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2609,7 +2609,7 @@ def scale(self, alpha, left=False):

INPUT:

- `\alpha` -- element of quaternion algebra
- `\alpha` -- nonzero element of quaternion algebra

- ``left`` -- boolean (default: ``False``); if ``True`` multiply
`\alpha` on the left, otherwise multiply `\alpha` on the right
Expand All @@ -2632,6 +2632,15 @@ def scale(self, alpha, left=False):
sage: I.gens()[0] * i
4*i

The scaling element must be nonzero::

sage: B.<i,j,k> = QuaternionAlgebra(419)
sage: O = B.quaternion_order([1/2 + 3/2*j, 1/6*i + 2/3*j + 1/2*k, 3*j, k])
sage: O * O.zero()
Traceback (most recent call last):
...
ValueError: the scaling factor must be nonzero

TESTS:

Scaling by `1` should not change anything (see :issue:`32245`)::
Expand All @@ -2657,6 +2666,8 @@ def scale(self, alpha, left=False):
"""
Q = self.quaternion_algebra()
alpha = Q(alpha)
if alpha.is_zero():
raise ValueError("the scaling factor must be nonzero")
if left:
gens = basis_for_quaternion_lattice([alpha * b for b in self.basis()])
else:
Expand Down Expand Up @@ -3657,7 +3668,9 @@ def is_right_equivalent(self, J, B=10, certificate=False):
sage: B = QuaternionAlgebra(101)
sage: i,j,k = B.gens()
sage: I = B.maximal_order().unit_ideal()
sage: beta = B.random_element() # random
sage: beta = B.random_element()
sage: while beta.is_zero():
....: beta = B.random_element()
sage: J = beta*I
sage: bool, alpha = I.is_right_equivalent(J, certificate=True)
sage: bool
Expand Down Expand Up @@ -3711,7 +3724,9 @@ def is_principal(self, certificate=False):

sage: B.<i,j,k> = QuaternionAlgebra(419)
sage: O = B.quaternion_order([1/2 + 3/2*j, 1/6*i + 2/3*j + 1/2*k, 3*j, k])
sage: beta = O.random_element() # random
sage: beta = O.random_element()
sage: while beta.is_zero():
....: beta = O.random_element()
sage: I = O*beta
sage: bool, alpha = I.is_principal(True)
sage: bool
Expand Down Expand Up @@ -3951,7 +3966,7 @@ def primitive_decomposition(self):

Check that randomly generated ideals decompose as expected::

sage: for d in ( m for m in range(400, 750) if is_squarefree(m) ):
sage: for d in ( m for m in range(400, 750) if is_squarefree(m) ): # long time (7s)
....: A = QuaternionAlgebra(d)
....: O = A.maximal_order()
....: for _ in range(10):
Expand Down
Loading