mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-11-11 12:35:27 +01:00
Merge branch 'enh/Nemoification' of git.wmi.amu.edu.pl:kalmar/GroupRings.jl into enh/Nemoification
# Conflicts: # src/GroupRings.jl
This commit is contained in:
commit
a726462488
@ -11,13 +11,13 @@ import Base: convert, show, hash, ==, +, -, *, //, /, length, norm, rationalize,
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
type GroupRing <: Ring
|
type GroupRing{Gr<:Group, T<:GroupElem} <: Ring
|
||||||
group::Group
|
group::Gr
|
||||||
basis::Vector{GroupElem}
|
basis::Vector{T}
|
||||||
basis_dict::Dict{GroupElem, Int}
|
basis_dict::Dict{T, Int}
|
||||||
pm::Array{Int,2}
|
pm::Array{Int,2}
|
||||||
|
|
||||||
function GroupRing(G::Group; initialise=true)
|
function GroupRing(G::Gr; initialise=true)
|
||||||
A = new(G)
|
A = new(G)
|
||||||
if initialise
|
if initialise
|
||||||
complete(A)
|
complete(A)
|
||||||
@ -25,11 +25,15 @@ type GroupRing <: Ring
|
|||||||
return A
|
return A
|
||||||
end
|
end
|
||||||
|
|
||||||
function GroupRing(G::Group, basis, basis_dict, pm::Array{Int,2})
|
function GroupRing(G::Gr, basis::Vector{T}, basis_dict::Dict{T,Int}, pm::Array{Int,2})
|
||||||
return new(G, basis, basis_dict, pm)
|
return new(G, basis, basis_dict, pm)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
GroupRing{Gr<:Group}(G::Gr;initialise=true) = GroupRing{Gr, elem_type(G)}(G, initialise=initialise)
|
||||||
|
|
||||||
|
GroupRing{Gr<:Group, T<:GroupElem}(G::Gr, b::Vector{T}, b_d::Dict{T,Int}, pm::Array{Int,2}) = GroupRing{Gr, T}(G, b, b_d, pm)
|
||||||
|
|
||||||
type GroupRingElem{T<:Number} <: RingElem
|
type GroupRingElem{T<:Number} <: RingElem
|
||||||
coeffs::AbstractVector{T}
|
coeffs::AbstractVector{T}
|
||||||
parent::GroupRing
|
parent::GroupRing
|
||||||
@ -108,23 +112,23 @@ end
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
function (RG::GroupRing)(T::Type=Int)
|
function {Gr,T}(RG::GroupRing{Gr,T})(S::Type=Int)
|
||||||
isdefined(RG, :basis) || throw("Complete the definition of GroupRing first")
|
isdefined(RG, :basis) || throw("Complete the definition of GroupRing first")
|
||||||
return GroupRingElem(spzeros(T,length(RG.basis)), RG)
|
return GroupRingElem(spzeros(S,length(RG.basis)), RG)
|
||||||
end
|
end
|
||||||
|
|
||||||
function (RG::GroupRing)(g::GroupElem, T::Type=Int)
|
function {Gr,T}(RG::GroupRing{Gr,T})(g::GroupElem, S::Type=Int)
|
||||||
g = try
|
g = try
|
||||||
RG.group(g)
|
RG.group(g)
|
||||||
catch
|
catch
|
||||||
throw("Can't coerce $g to the underlying group of $RG")
|
throw("Can't coerce $g to the underlying group of $RG")
|
||||||
end
|
end
|
||||||
result = RG(T)
|
result = RG(S)
|
||||||
result[g] = one(T)
|
result[g] = one(S)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function (RG::GroupRing)(x::AbstractVector)
|
function {Gr,T}(RG::GroupRing{Gr,T})(x::AbstractVector)
|
||||||
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
length(x) == length(RG.basis) || throw("Can not coerce to $RG: lengths differ")
|
||||||
result = RG(eltype(x))
|
result = RG(eltype(x))
|
||||||
result.coeffs = x
|
result.coeffs = x
|
||||||
@ -291,7 +295,8 @@ end
|
|||||||
(+)(X::GroupRingElem, Y::GroupRingElem) = add(X,Y)
|
(+)(X::GroupRingElem, Y::GroupRingElem) = add(X,Y)
|
||||||
(-)(X::GroupRingElem, Y::GroupRingElem) = add(X,-Y)
|
(-)(X::GroupRingElem, Y::GroupRingElem) = add(X,-Y)
|
||||||
|
|
||||||
function mul!(X,Y,pm,result)
|
function mul!{T<:Number}(X::AbstractVector{T}, Y::AbstractVector{T},
|
||||||
|
pm::Array{Int,2}, result::AbstractVector{T})
|
||||||
for (j,y) in enumerate(Y)
|
for (j,y) in enumerate(Y)
|
||||||
if y != zero(eltype(Y))
|
if y != zero(eltype(Y))
|
||||||
for (i, index) in enumerate(pm[:,j])
|
for (i, index) in enumerate(pm[:,j])
|
||||||
|
Loading…
Reference in New Issue
Block a user