Skip to content

Commit

Permalink
set reverse=True by default in basis_for_quaternion_lattice()
Browse files Browse the repository at this point in the history
  • Loading branch information
yyyyx4 committed Apr 7, 2023
1 parent 27b077e commit eed894f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
21 changes: 11 additions & 10 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2534,11 +2534,11 @@ def __mul__(self, right):
sage: I = BrandtModule(3,5).right_ideals()[1]; I
Fractional ideal (2 + 6*j + 4*k, 2*i + 4*j + 34*k, 8*j + 32*k, 40*k)
sage: I*I
Fractional ideal (8 + 24*j + 16*k, 8*i + 16*j + 136*k, 32*j + 128*k, 160*k)
Fractional ideal (32, 160*i, 24 + 112*i + 8*j, 16 + 72*i + 8*k)
sage: I*I.conjugate()
Fractional ideal (16 + 16*j + 224*k, 8*i + 16*j + 136*k, 32*j + 128*k, 320*k)
Fractional ideal (32, 320*i, 16 + 224*i + 16*j, 16 + 232*i + 8*k)
sage: I.multiply_by_conjugate(I)
Fractional ideal (16 + 16*j + 224*k, 8*i + 16*j + 136*k, 32*j + 128*k, 320*k)
Fractional ideal (32, 320*i, 16 + 224*i + 16*j, 16 + 232*i + 8*k)
"""
if isinstance(right, QuaternionOrder):
right = right.unit_ideal()
Expand Down Expand Up @@ -2685,9 +2685,9 @@ def multiply_by_conjugate(self, J):
sage: R = BrandtModule(3,5).right_ideals()
sage: R[0].multiply_by_conjugate(R[1])
Fractional ideal (8 + 8*j + 112*k, 8*i + 16*j + 136*k, 32*j + 128*k, 160*k)
Fractional ideal (32, 160*i, 8 + 112*i + 8*j, 16 + 72*i + 8*k)
sage: R[0]*R[1].conjugate()
Fractional ideal (8 + 8*j + 112*k, 8*i + 16*j + 136*k, 32*j + 128*k, 160*k)
Fractional ideal (32, 160*i, 8 + 112*i + 8*j, 16 + 72*i + 8*k)
"""
Jbar = [b.conjugate() for b in J.basis()]
gens = [a * b for a in self.basis() for b in Jbar]
Expand Down Expand Up @@ -2899,7 +2899,7 @@ def cyclic_right_subideals(self, p, alpha=None):
#######################################################################


def basis_for_quaternion_lattice(gens, reverse=False):
def basis_for_quaternion_lattice(gens, reverse=True):
r"""
Return a basis for the `\ZZ`-lattice in a quaternion algebra
spanned by the given gens.
Expand All @@ -2909,16 +2909,17 @@ def basis_for_quaternion_lattice(gens, reverse=False):
- ``gens`` -- list of elements of a single quaternion algebra
- ``reverse`` -- when computing the HNF do it on the basis
`(k,j,i,1)` instead of `(1,i,j,k)`; this ensures
that if ``gens`` are the generators for an order,
the first returned basis vector is 1
`(k,j,i,1)` instead of `(1,i,j,k)`; this ensures that if
``gens`` are the generators for a fractional ideal (in
particular, an order), the first returned basis vector
equals the norm of the ideal (in case of an order, `1`)
EXAMPLES::
sage: from sage.algebras.quatalg.quaternion_algebra import basis_for_quaternion_lattice
sage: A.<i,j,k> = QuaternionAlgebra(-1,-7)
sage: basis_for_quaternion_lattice([i+j, i-j, 2*k, A(1/3)])
[1/3, i + j, 2*j, 2*k]
[1/3, 2*i, i + j, 2*k]
sage: basis_for_quaternion_lattice([A(1),i,j,k])
[1, i, j, k]
Expand Down
24 changes: 12 additions & 12 deletions src/sage/modular/quatalg/brandt.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def basis_for_left_ideal(R, gens):
sage: B = BrandtModule(17); A = B.quaternion_algebra(); i,j,k = A.gens()
sage: sage.modular.quatalg.brandt.basis_for_left_ideal(B.maximal_order(), [i+j,i-j,2*k,A(3)])
[1/2 + 1/6*i + 1/3*k, 1/3*i + 2/3*k, 1/2*j + 1/2*k, k]
[1, 1/2 + 1/2*i, j, 1/3*i + 1/2*j + 1/6*k]
sage: sage.modular.quatalg.brandt.basis_for_left_ideal(B.maximal_order(), [3*(i+j),3*(i-j),6*k,A(3)])
[3/2 + 1/2*i + k, i + 2*k, 3/2*j + 3/2*k, 3*k]
[3, 3/2 + 3/2*i, 3*j, i + 3/2*j + 1/2*k]
"""
return basis_for_quaternion_lattice([b * g for b in R.basis() for g in gens])

Expand All @@ -424,7 +424,7 @@ def right_order(R, basis):
sage: sage.modular.quatalg.brandt.right_order(B.maximal_order(), basis)
Order of Quaternion Algebra (-3, -17) with base ring Rational Field with basis (1/2 + 1/6*i + 1/3*k, 1/3*i + 2/3*k, 1/2*j + 1/2*k, k)
sage: basis
[1/2 + 1/6*i + 1/3*k, 1/3*i + 2/3*k, 1/2*j + 1/2*k, k]
[1, 1/2 + 1/2*i, j, 1/3*i + 1/2*j + 1/6*k]
sage: B = BrandtModule(17); A = B.quaternion_algebra(); i,j,k = A.gens()
sage: basis = sage.modular.quatalg.brandt.basis_for_left_ideal(B.maximal_order(), [i*j-j])
Expand Down Expand Up @@ -1393,16 +1393,16 @@ def _ideal_products(self, diagonal_only=False):
sage: B = BrandtModule(37)
sage: B._ideal_products()
[[Fractional ideal (8 + 8*j + 8*k, 4*i + 8*j + 4*k, 16*j, 16*k)],
[Fractional ideal (8 + 24*j + 8*k, 4*i + 8*j + 4*k, 32*j, 32*k),
Fractional ideal (16 + 16*j + 48*k, 4*i + 8*j + 36*k, 32*j + 32*k, 64*k)],
[Fractional ideal (8 + 24*j + 24*k, 4*i + 24*j + 4*k, 32*j, 32*k),
Fractional ideal (8 + 4*i + 16*j + 28*k, 8*i + 16*j + 8*k, 32*j, 64*k),
Fractional ideal (16 + 16*j + 16*k, 4*i + 24*j + 4*k, 32*j + 32*k, 64*k)]]
[[Fractional ideal (16, 16*i, 8 + 8*i + 8*j, 8 + 12*i + 4*k)],
[Fractional ideal (32, 32*i, 8 + 24*i + 8*j, 24 + 12*i + 4*k),
Fractional ideal (32, 64*i, 16 + 48*i + 16*j, 36*i + 8*j + 4*k)],
[Fractional ideal (32, 32*i, 8 + 8*i + 8*j, 8 + 12*i + 4*k),
Fractional ideal (64, 32 + 32*i, 16 + 16*i + 16*j, 40 + 12*i + 4*k),
Fractional ideal (32, 64*i, 16 + 16*i + 16*j, 16 + 52*i + 8*j + 4*k)]]
sage: B._ideal_products(diagonal_only=True)
[Fractional ideal (8 + 8*j + 8*k, 4*i + 8*j + 4*k, 16*j, 16*k),
Fractional ideal (16 + 16*j + 48*k, 4*i + 8*j + 36*k, 32*j + 32*k, 64*k),
Fractional ideal (16 + 16*j + 16*k, 4*i + 24*j + 4*k, 32*j + 32*k, 64*k)]
[Fractional ideal (16, 16*i, 8 + 8*i + 8*j, 8 + 12*i + 4*k),
Fractional ideal (32, 64*i, 16 + 48*i + 16*j, 36*i + 8*j + 4*k),
Fractional ideal (32, 64*i, 16 + 16*i + 16*j, 16 + 52*i + 8*j + 4*k)]
"""
L = self.right_ideals()
n = len(L)
Expand Down

0 comments on commit eed894f

Please sign in to comment.