1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-26 17:05:27 +01:00

use NCRing[Elem]s instead of MatSpace and use NCRing in Settings

This commit is contained in:
kalmarek 2019-06-30 19:05:46 +02:00
parent 80e338f191
commit 88b460a959
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
3 changed files with 13 additions and 21 deletions

View File

@ -10,7 +10,7 @@ abstract type Settings end
struct Naive{El} <: Settings struct Naive{El} <: Settings
name::String name::String
G::Group G::Union{Group, NCRing}
S::Vector{El} S::Vector{El}
halfradius::Int halfradius::Int
upper_bound::Float64 upper_bound::Float64
@ -21,7 +21,7 @@ end
struct Symmetrized{El} <: Settings struct Symmetrized{El} <: Settings
name::String name::String
G::Group G::Union{Group, NCRing}
S::Vector{El} S::Vector{El}
autS::Group autS::Group
halfradius::Int halfradius::Int
@ -32,14 +32,14 @@ struct Symmetrized{El} <: Settings
end end
function Settings(name::String, function Settings(name::String,
G::Group, S::Vector{<:GroupElem}, solver::JuMP.OptimizerFactory; G::Union{Group, NCRing}, S::AbstractVector{El}, solver::JuMP.OptimizerFactory;
halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) where El <: Union{GroupElem, NCRingElem}
return Naive(name, G, S, halfradius, upper_bound, solver, warmstart) return Naive(name, G, S, halfradius, upper_bound, solver, warmstart)
end end
function Settings(name::String, function Settings(name::String,
G::Group, S::Vector{<:GroupElem}, autS::Group, solver::JuMP.OptimizerFactory; G::Union{Group, NCRing}, S::AbstractVector{El}, autS::Group, solver::JuMP.OptimizerFactory;
halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) halfradius::Integer=2, upper_bound::Float64=1.0, warmstart=true) where El <: Union{GroupElem, NCRingElem}
return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, warmstart) return Symmetrized(name, G, S, autS, halfradius, upper_bound, solver, warmstart)
end end

View File

@ -13,7 +13,7 @@ using GroupRings
using JLD using JLD
using JuMP using JuMP
import AbstractAlgebra: Group, Ring, perm import AbstractAlgebra: Group, NCRing, perm
import MathProgBase.SolverInterface.AbstractMathProgSolver import MathProgBase.SolverInterface.AbstractMathProgSolver

View File

@ -4,30 +4,22 @@
# #
############################################################################### ###############################################################################
function spLaplacian(RG::GroupRing, S, T::Type=Float64) function spLaplacian(RG::GroupRing, S::AbstractVector{El}, T::Type=Float64) where El
result = RG(T) result = RG(T)
result[RG.group()] = T(length(S)) id = (El <: AbstractAlgebra.NCRingElem ? one(RG.group) : RG.group())
result[id] = T(length(S))
for s in S for s in S
result[s] -= one(T) result[s] -= one(T)
end end
return result return result
end end
function spLaplacian(RG::GroupRing, S::Vector{REl}, T::Type=Float64) where {REl<:AbstractAlgebra.ModuleElem} function Laplacian(S::AbstractVector{REl}, halfradius) where REl<:AbstractAlgebra.NCRingElem
result = RG(T)
result[one(RG.group)] = T(length(S))
for s in S
result[s] -= one(T)
end
return result
end
function Laplacian(S::Vector{E}, halfradius) where E<:AbstractAlgebra.ModuleElem
R = parent(first(S)) R = parent(first(S))
return Laplacian(S, one(R), halfradius) return Laplacian(S, one(R), halfradius)
end end
function Laplacian(S::Vector{E}, halfradius) where E<:AbstractAlgebra.GroupElem function Laplacian(S::AbstractVector{E}, halfradius) where E<:AbstractAlgebra.GroupElem
G = parent(first(S)) G = parent(first(S))
return Laplacian(S, G(), halfradius) return Laplacian(S, G(), halfradius)
end end
@ -56,7 +48,7 @@ function loadGRElem(fname::String, RG::GroupRing)
return GroupRingElem(coeffs, RG) return GroupRingElem(coeffs, RG)
end end
function loadGRElem(fname::String, G::Group) function loadGRElem(fname::String, G::Union{Group, NCRing})
pm = load(fname, "pm") pm = load(fname, "pm")
RG = GroupRing(G, pm) RG = GroupRing(G, pm)
return loadGRElem(fname, RG) return loadGRElem(fname, RG)