Skip to content

Commit

Permalink
add diagonal_with_transform for abstract product spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
StevellM committed Oct 5, 2023
1 parent f8f033a commit f8b2f63
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/src/quad_forms/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ gram_matrix(::AbstractSpace{T}, ::Vector{Vector{U}}) where {T, U}
inner_product(::AbstractSpace, ::Vector, ::Vector)
orthogonal_basis(::AbstractSpace)
diagonal(::AbstractSpace)
diagonal_with_transform(::AbstractSpace)
restrict_scalars(::AbstractSpace, ::QQField, ::FieldElem)
```

Expand Down
16 changes: 12 additions & 4 deletions src/QuadForm/Herm/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,22 @@ inner_product(V::HermSpace{S,T,U,W}, v::U, w::U) where {S,T,U,W}= v*gram_matrix(
#
################################################################################

function diagonal(V::HermSpace)
diagonal(V::HermSpace) = _diagonal(V, false)[1]

diagonal_with_transform(V::HermSpace) = _diagonal(V)

function _diagonal(V::HermSpace, with_transform::Bool = true)
E = base_ring(V)
g = gram_matrix(V)
k, K = left_kernel(g)
B = complete_to_basis(K)
g = B[k+1:end,:]*g*transpose(B[k+1:end,:])
D, _ = _gram_schmidt(g, involution(V))
D = append!(zeros(base_ring(V),k), diagonal(D))
return map(fixed_field(V), D)
D, U = _gram_schmidt(g, involution(V))
diagE = append!(zeros(base_ring(V),k), diagonal(D))
diagK = map(fixed_field(V), diagE)
!with_transform && return diagK, E[;]
B[k+1:end, :] = U*view(B, k+1:nrows(B), :)
return diagK, B
end

################################################################################
Expand Down
14 changes: 11 additions & 3 deletions src/QuadForm/Quad/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,21 @@ end
#
################################################################################

function diagonal(V::QuadSpace)
diagonal(V::QuadSpace) = _diagonal(V, false)[1]

diagonal_with_transform(V::QuadSpace) = _diagonal(V)

function _diagonal(V::QuadSpace, with_transform::Bool = true)
E = base_ring(V)
g = gram_matrix(V)
k, K = left_kernel(g)
B = complete_to_basis(K)
g = B[k+1:end,:]*g*transpose(B[k+1:end,:])
D, _ = _gram_schmidt(g, involution(V))
return append!(zeros(base_ring(V),k),diagonal(D))
D, U = _gram_schmidt(g, involution(V))
diag = append!(zeros(base_ring(V), k), diagonal(D))
!with_transform && return diag, E[;]
B[k+1:end, :] = U*view(B, k+1:nrows(B), :)
return diag, B
end

################################################################################
Expand Down
15 changes: 14 additions & 1 deletion src/QuadForm/Spaces.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export ambient_space, rank, gram_matrix, inner_product, involution, is_hermitian, is_quadratic, is_regular,
is_local_square, is_isometric, is_rationally_isometric, is_isotropic, is_isotropic_with_vector, quadratic_space,
hermitian_space, diagonal, invariants, hasse_invariant, witt_invariant, orthogonal_basis, fixed_field,
restrict_scalars, orthogonal_complement, orthogonal_projection
restrict_scalars, orthogonal_complement, orthogonal_projection, diagonal_with_transform

################################################################################
#
Expand Down Expand Up @@ -319,6 +319,19 @@ The elements are contained in the fixed field of `V`.
"""
diagonal(V::AbstractSpace)

@doc raw"""
diagonal_with_transform(V::AbstractSpace) -> Vector{FieldElem},
MatElem{FieldElem}
Return a vector of elements $a_1,\dotsc,a_n$ such that the space `V` is
isometric to the diagonal space $\langle a_1,\dotsc,a_n \rangle$. The second
output is a matrix `U` whose rows span an orthogonal basis of `V` for which the
Gram matrix is given by the diagonal matrix of the $a_i$'s.
The elements are contained in the fixed field of `V`.
"""
diagonal_with_transform(V::AbstractSpace)

################################################################################
#
# Gram-Schmidt
Expand Down
9 changes: 9 additions & 0 deletions test/QuadForm/Herm/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,12 @@
@test is_isometric(V1, V2)

end

@testset "diagonal with transform" begin
E, b = cyclotomic_field_as_cm_extension(3)
K = base_field(E)
s = involution(E)
Vh = hermitian_space(E, E[1 b 1; s(b) 4 s(b); 1 b 1])
diag, U = @inferred diagonal_with_transform(Vh)
@test diagonal(map_entries(K, U*gram_matrix(Vh)*map_entries(s, transpose(U)))) == diag
end
7 changes: 7 additions & 0 deletions test/QuadForm/Quad/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,3 +524,10 @@ end
@test !is_isotropic(V, 5)
@test_throws ArgumentError is_isotropic(V, 4)
end

@testset "diagonal with transform" begin
K, a = cyclotomic_field(8)
V = quadratic_space(K, K[a 3 a; 3 3 3; a 3 a])
diag, U = @inferred diagonal_with_transform(V)
@test diagonal(U*gram_matrix(V)*transpose(U)) == diag
end

0 comments on commit f8b2f63

Please sign in to comment.