Skip to content

Commit

Permalink
Hack around non-existing matrices for noncommutative rings
Browse files Browse the repository at this point in the history
(Fixes #419)

- AA does not have matrices for noncommutative rings (yet)
- We make our algberas/orders subtypes of Ring (to make matrices work)
- But we want NCPolynomialRing for polynomials over this ring
  • Loading branch information
thofma committed Nov 7, 2021
1 parent feee9be commit 16b8115
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"

[compat]
AbstractAlgebra = "^0.22.0"
AbstractAlgebra = "^0.22.1"
Nemo = "^0.27.0"
RandomExtensions = "0.4.3"
Requires = "^0.5.2, 1.0"
Expand Down
2 changes: 1 addition & 1 deletion src/AlgAss/AlgMat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ If `isbasis` is `true`, it is assumed that the given matrices are an $R$-basis
of this algebra, i. e. that the spanned $R$-module is closed under
multiplication.
"""
function matrix_algebra(R::Ring, S::Ring, gens::Vector{<:MatElem}; isbasis::Bool = false)
function matrix_algebra(R::AbstractAlgebra.NCRing, S::AbstractAlgebra.NCRing, gens::Vector{<:MatElem}; isbasis::Bool = false)
@assert length(gens) > 0
A = AlgMat{elem_type(R), dense_matrix_type(elem_type(S))}(R, S)
A.degree = nrows(gens[1])
Expand Down
22 changes: 11 additions & 11 deletions src/AlgAss/AlgMatElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,17 @@ function (A::AlgMat{T, S})(M::S) where { T, S }
return AlgMatElem{T, typeof(A), S}(A, deepcopy(M))
end

function (A::AlgMat{T, S})(a::T) where { T, S }
return a*one(A)
end

function (A::AlgMat)(x::fmpz)
return x * one(A)
end

function (A::AlgMat)(x::Integer)
return x * one(A)
end
#function (A::AlgMat{T, S})(a::T) where { T, S }
# return a*one(A)
#end
#
#function (A::AlgMat)(x::fmpz)
# return x * one(A)
#end
#
#function (A::AlgMat)(x::Integer)
# return x * one(A)
#end

function (A::AlgMat{T, S})(v::Vector{T}) where { T, S }
@assert length(v) == dim(A)
Expand Down
36 changes: 22 additions & 14 deletions src/AlgAss/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export reduced_charpoly
#
################################################################################

function AbstractAlgebra.promote_rule(U::Type{<:AbsAlgAssElem{T}}, ::Type{S}) where {T, S}
if AbstractAlgebra.promote_rule(T, S) === T
return U
else
return Union{}
end
end

parent_type(::Type{AlgAssElem{T, S}}) where {T, S} = S

parent_type(::Type{AlgGrpElem{T, S}}) where {T, S} = S
Expand Down Expand Up @@ -426,11 +434,11 @@ divexact_left(a::AbsAlgAssElem, b::AbsAlgAssElem) = divexact(a, b, :left)
#
################################################################################

function *(a::AbsAlgAssElem{S}, b::T) where {T <: RingElem, S <: RingElem}
function *(a::AbsAlgAssElem{S}, b::S) where {S <: RingElem}
return typeof(a)(parent(a), coefficients(a, copy = false).* Ref(b))
end

*(b::T, a::AbsAlgAssElem{S}) where {T <: RingElem, S <: RingElem } = a*b
*(b::S, a::AbsAlgAssElem{S}) where {S <: RingElem } = a*b

*(a::AbsAlgAssElem{T}, b::Integer) where {T} = a*base_ring(parent(a))(b)

Expand Down Expand Up @@ -619,21 +627,21 @@ function (A::AlgGrp)(a::AlgGrpElem)
end

# For polynomial substitution
function (A::AlgAss)(a::Union{ Int, fmpz })
return a*one(A)
end

function (A::AlgGrp)(a::Union{ Int, fmpz })
return a*one(A)
end
for T in subtypes(AbsAlgAss)
@eval begin
function (A::$T)(a::Union{Int, fmpz})
return A(base_ring(A)(a))
end

function (A::AlgAss{T})(a::T) where T
return a*one(A)
function (A::$T{S})(a::S) where {S}
return a*one(A)
end
end
end

function (A::AlgGrp{T, S, U})(a::T) where { T, S, U }
return a*one(A)
end
#function (A::AbsAlgAss{T})(a::T) where T
# return a*one(A)
#end

################################################################################
#
Expand Down
10 changes: 10 additions & 0 deletions src/AlgAss/Types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,13 @@ mutable struct AlgMatElem{T, S, Mat} <: AbsAlgAssElem{T}
return z
end
end

################################################################################
#
# Polynomial ring hack
#
################################################################################

function AbstractAlgebra.PolynomialRing(A::AbsAlgAss, s::Symbol; cached::Bool = true)
return invoke(Generic.PolynomialRing, Tuple{AbstractAlgebra.NCRing, Symbol}, A, s; cached = cached)
end
2 changes: 2 additions & 0 deletions src/AlgAssAbsOrd/Conjugacy/Conjugacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ function _isGLZ_conjugate_integral(A::fmpq_mat, B::fmpq_mat)
end

OO = Order(AA, ordergens)
@show factor(discriminant(OO))
@show dim(AA)
OI = ideal_from_lattice_gens(AA, idealgens)
@hassert :Conjugacy 1 OO == right_order(OI)
@vprint :Conjugacy 1 "Testing if ideal is principal...\n"
Expand Down

0 comments on commit 16b8115

Please sign in to comment.