diff --git a/.travis.yml b/.travis.yml index edc5a30..4c7dc0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,10 @@ matrix: allow_failures: - julia: nightly - os: osx +addons: + apt: + packages: + - hdf5-tools ## uncomment the following lines to override the default test # script: diff --git a/Manifest.toml b/Manifest.toml index caf452f..0f5e58b 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -2,9 +2,9 @@ [[AbstractAlgebra]] deps = ["InteractiveUtils", "LinearAlgebra", "Markdown", "Random", "SparseArrays", "Test"] -git-tree-sha1 = "56bdd9e9bb2cfdf0876d0846b337c8f395d9a4b7" +git-tree-sha1 = "c0d57a3f0618bfbb214005860b9b5e5bceafa61c" uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" -version = "0.4.6" +version = "0.5.0" [[Base64]] uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" @@ -16,10 +16,10 @@ uuid = "9e28174c-4ba2-5203-b857-d8d62c4213ee" version = "0.8.10" [[BinaryProvider]] -deps = ["Libdl", "Pkg", "SHA", "Test"] -git-tree-sha1 = "055eb2690182ebc31087859c3dd8598371d3ef9e" +deps = ["Libdl", "SHA"] +git-tree-sha1 = "c7361ce8a2129f20b0e05a89f7070820cfed6648" uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" -version = "0.5.3" +version = "0.5.4" [[Blosc]] deps = ["BinaryProvider", "CMakeWrapper", "Compat", "Libdl"] @@ -34,19 +34,16 @@ uuid = "e1450e63-4bb3-523b-b2a4-4ffa8c0fd77d" version = "1.0.0" [[CMake]] -deps = ["BinDeps", "Libdl", "Test"] -git-tree-sha1 = "6e39bef3cbb8321e8a464b18a5c20d7cef813938" +deps = ["BinDeps"] +git-tree-sha1 = "c67a8689dc5444adc5eb2be7d837100340ecba11" uuid = "631607c0-34d2-5d66-819e-eb0f9aa2061a" -version = "1.1.1" +version = "1.1.2" [[CMakeWrapper]] deps = ["BinDeps", "CMake", "Libdl", "Parameters", "Test"] -git-tree-sha1 = "2b43d451639984e3571951cc687b8509b0a86c6d" +git-tree-sha1 = "16d4acb3d37dc05b714977ffefa8890843dc8985" uuid = "d5fb7624-851a-54ee-a528-d3f3bac0b4a0" -version = "0.2.2" - -[[CRC32c]] -uuid = "8bf52ea8-c179-5cab-976a-9e18b702a9bc" +version = "0.2.3" [[CRlibm]] deps = ["Libdl", "Test"] @@ -103,10 +100,9 @@ deps = ["Random", "Serialization", "Sockets"] uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" [[ErrorfreeArithmetic]] -deps = ["Test"] -git-tree-sha1 = "e38834f24946eb8c7dcf2bb00580e087faa60c44" +git-tree-sha1 = "a2b7d5a7962e5bfaab0e2e87c9cde7d3087f4e2c" uuid = "90fa49ef-747e-5e6f-a989-263ba693cf1a" -version = "0.3.2" +version = "0.4.0" [[FastRounding]] deps = ["ErrorfreeArithmetic", "Test"] @@ -115,10 +111,10 @@ uuid = "fa42c844-2597-5d31-933b-ebd51ab2693f" version = "0.2.0" [[FileIO]] -deps = ["Pkg", "Random", "Test"] -git-tree-sha1 = "da32159d4a2e526338506685e280e39ed2f18961" +deps = ["Pkg"] +git-tree-sha1 = "351f001a78aa1b7ad2696e386e110b5abd071c71" uuid = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" -version = "1.0.6" +version = "1.0.7" [[ForwardDiff]] deps = ["CommonSubexpressions", "DiffResults", "DiffRules", "InteractiveUtils", "LinearAlgebra", "NaNMath", "Random", "SparseArrays", "SpecialFunctions", "StaticArrays", "Test"] @@ -128,25 +124,25 @@ version = "0.10.3" [[GroupRings]] deps = ["AbstractAlgebra", "LinearAlgebra", "Markdown", "SparseArrays"] -git-tree-sha1 = "0d259b2e2254cc22c526938f37936618784fd03d" -repo-rev = "enh/julia-v0.7" +git-tree-sha1 = "30ed912be2eb74523699bfdaaefd5d5426c43afa" +repo-rev = "master" repo-url = "https://github.com/kalmarek/GroupRings.jl" uuid = "0befed6a-bd73-11e8-1e41-a1190947c2f5" version = "0.2.0" [[Groups]] deps = ["AbstractAlgebra", "LinearAlgebra", "Markdown"] -git-tree-sha1 = "35b712a91e9910bbf150ef1d20d78393e244deaf" -repo-rev = "enh/julia-v0.7" +git-tree-sha1 = "64dcaa46affb4568501d35e6fae36a71a7ae5cbb" +repo-rev = "master" repo-url = "https://github.com/kalmarek/Groups.jl" uuid = "5d8bd718-bd84-11e8-3b40-ad14f4a32557" -version = "0.2.0" +version = "0.2.1" [[HDF5]] -deps = ["BinDeps", "Blosc", "CRC32c", "Distributed", "Homebrew", "Libdl", "LinearAlgebra", "Mmap", "Pkg", "Test", "WinRPM"] -git-tree-sha1 = "dd83e1e9c72e44e3a156438b552cf75dbdda722f" +deps = ["BinDeps", "Blosc", "Homebrew", "Libdl", "Mmap", "WinRPM"] +git-tree-sha1 = "e6f0c154d01faef0d0831d075aa8f279f95946da" uuid = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f" -version = "0.11.0" +version = "0.11.1" [[HTTPClient]] deps = ["Compat", "LibCURL"] @@ -183,10 +179,10 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" version = "0.20.0" [[JuMP]] -deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics", "Test"] -git-tree-sha1 = "db9f08540c1a23269acbae5d520c79f4722899f4" +deps = ["Calculus", "DataStructures", "ForwardDiff", "LinearAlgebra", "MathOptInterface", "NaNMath", "Random", "SparseArrays", "Statistics"] +git-tree-sha1 = "a37fdb14ee3a04b4df44c20a73da89c57035bdf2" uuid = "4076af6c-e467-56ae-b986-b466b2749572" -version = "0.19.0" +version = "0.19.2" [[LegacyStrings]] deps = ["Compat"] @@ -195,10 +191,10 @@ uuid = "1b4a561d-cfcb-5daf-8433-43fcf8b4bea3" version = "0.4.1" [[LibCURL]] -deps = ["BinaryProvider", "Libdl", "Printf", "Test"] -git-tree-sha1 = "d051c8057512ca38a273aaa514145a0b25f24d46" +deps = ["BinaryProvider", "Libdl"] +git-tree-sha1 = "5ee138c679fa202ebe211b2683d1eee2a87b3dbe" uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.5.0" +version = "0.5.1" [[LibExpat]] deps = ["Compat"] @@ -252,15 +248,15 @@ version = "0.3.2" [[Nemo]] deps = ["AbstractAlgebra", "BinaryProvider", "InteractiveUtils", "Libdl", "LinearAlgebra", "Markdown", "Test"] -git-tree-sha1 = "a152b26c888fbe3c191424938243552935ca2f51" +git-tree-sha1 = "b359c25b708c3edcc2f17345d59da7169c207385" uuid = "2edaba10-b0f1-5616-af89-8c11ac63239a" -version = "0.13.1" +version = "0.14.0" [[OrderedCollections]] deps = ["Random", "Serialization", "Test"] -git-tree-sha1 = "85619a3f3e17bb4761fe1b1fd47f0e979f964d5b" +git-tree-sha1 = "c4c13474d23c60d20a67b217f1d7f22a40edf8f1" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.0.2" +version = "1.1.0" [[Parameters]] deps = ["Markdown", "OrderedCollections", "REPL", "Test"] @@ -289,10 +285,9 @@ deps = ["Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[RecipesBase]] -deps = ["Random", "Test"] -git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884" +git-tree-sha1 = "7bdce29bc9b2f5660a6e5e64d64d91ec941f6aa2" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "0.6.0" +version = "0.7.0" [[SHA]] uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" @@ -324,10 +319,10 @@ uuid = "276daf66-3868-5448-9aa4-cd146d93841b" version = "0.7.2" [[StaticArrays]] -deps = ["InteractiveUtils", "LinearAlgebra", "Random", "Statistics", "Test"] -git-tree-sha1 = "3841b39ed5f047db1162627bf5f80a9cd3e39ae2" +deps = ["LinearAlgebra", "Random", "Statistics"] +git-tree-sha1 = "db23bbf50064c582b6f2b9b043c8e7e98ea8c0c6" uuid = "90137ffa-7385-5640-81b9-e52037218182" -version = "0.10.3" +version = "0.11.0" [[Statistics]] deps = ["LinearAlgebra", "SparseArrays"] diff --git a/Project.toml b/Project.toml index 55b843e..21135bd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PropertyT" uuid = "03b72c93-0167-51e2-8a1e-eb4ff1fb940d" authors = ["Marek Kaluba "] -version = "0.2.0" +version = "0.2.1" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" @@ -20,7 +20,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] GroupRings = "^0.2.0" -Groups = "^0.2.0" +Groups = "^0.2.1" JuMP = "^0.19.0" [extras] diff --git a/src/checksolution.jl b/src/checksolution.jl index c102191..8a4a166 100644 --- a/src/checksolution.jl +++ b/src/checksolution.jl @@ -37,7 +37,7 @@ function compute_SOS(RG::GroupRing, Q::AbstractMatrix{<:Real}) return GroupRingElem(result, RG) end -function compute_SOS_square(pm::AbstractMatrix{<:Integer}, Q::AbstractMatrix{<:Real}) +function compute_SOS_square(pm::AbstractMatrix{<:Integer}, Q::AbstractMatrix) result = zeros(eltype(Q), maximum(pm)); for i in 1:size(Q,2) @@ -47,12 +47,12 @@ function compute_SOS_square(pm::AbstractMatrix{<:Integer}, Q::AbstractMatrix{<:R return result end -function compute_SOS_square(RG::GroupRing, Q::AbstractMatrix{<:Real}) +function compute_SOS_square(RG::GroupRing, Q::AbstractMatrix) return GroupRingElem(compute_SOS_square(RG.pm, Q), RG) end -function augIdproj(Q::AbstractMatrix{T}) where {T<:Real} - result = zeros(size(Q)) +function augIdproj(Q::AbstractMatrix{T}) where T + result = zeros(T, size(Q)) l = size(Q, 2) Threads.@threads for j in 1:l col = sum(view(Q, :,j))/l diff --git a/src/orbitdata.jl b/src/orbitdata.jl index 4a8b61f..13fe2da 100644 --- a/src/orbitdata.jl +++ b/src/orbitdata.jl @@ -58,9 +58,9 @@ function orthSVD(M::AbstractMatrix{T}) where {T<:AbstractFloat} return fact.U[:,1:M_rank] end -function orbit_decomposition(G::Group, E::Vector, rdict=GroupRings.reverse_dict(E)) +orbit_decomposition(G::Group, E::AbstractVector, rdict=GroupRings.reverse_dict(E)) = orbit_decomposition(collect(G), E, rdict) - elts = collect(G) +function orbit_decomposition(elts::AbstractVector{<:GroupElem}, E::AbstractVector, rdict=GroupRings.reverse_dict(E)) tovisit = trues(size(E)); orbits = Vector{Vector{Int}}() @@ -178,13 +178,47 @@ end # ############################################################################### -function (p::perm)(A::GroupRingElem) - RG = parent(A) - result = zero(RG, eltype(A.coeffs)) +function (g::GroupRingElem)(y::GroupRingElem) + res = parent(y)() + for elt in GroupRings.supp(g) + res += g[elt]*elt(y) + end + return res +end - for (idx, c) in enumerate(A.coeffs) - if c!= zero(eltype(A.coeffs)) - result[p(RG.basis[idx])] = c +############################################################################### +# +# perm actions +# +############################################################################### + +function (g::perm)(y::GroupRingElem) + RG = parent(y) + result = zero(RG, eltype(y.coeffs)) + + for (idx, c) in enumerate(y.coeffs) + if c!= zero(eltype(y.coeffs)) + result[g(RG.basis[idx])] = c + end + end + return result +end + +function (g::perm)(y::GroupRingElem{T, <:SparseVector}) where T + RG = parent(y) + index = [RG.basis_dict[g(RG.basis[idx])] for idx in y.coeffs.nzind] + + result = GroupRingElem(sparsevec(index, y.coeffs.nzval, y.coeffs.n), RG) + + return result +end + +function (p::perm)(A::MatElem) + length(p.d) == size(A, 1) == size(A,2) || throw("Can't act via $p on matrix of size $(size(A))") + result = similar(A) + @inbounds for i in 1:size(A, 1) + for j in 1:size(A, 2) + result[i, j] = A[p[i], p[j]] # action by permuting rows and colums/conjugation end end return result @@ -192,45 +226,35 @@ end ############################################################################### # -# Action of WreathProductElems on Nemo.MatElem +# WreathProductElems action on Nemo.MatElem # ############################################################################### -function matrix_emb(n::DirectPowerGroupElem, p::perm) - Id = parent(n.elts[1])() - elt = Diagonal([(-1)^(el == Id ? 0 : 1) for el in n.elts]) - return elt[:, p.d] +function (g::WreathProductElem)(y::GroupRingElem) + RG = parent(y) + result = zero(RG, eltype(y.coeffs)) + + for (idx, c) in enumerate(y.coeffs) + if c!= zero(eltype(y.coeffs)) + result[g(RG.basis[idx])] = c + end + end + return result end -function (g::WreathProductElem)(A::MatElem) - g_inv = inv(g) - G = matrix_emb(g.n, g_inv.p) - G_inv = matrix_emb(g_inv.n, g.p) - M = parent(A) - return M(G)*A*M(G_inv) -end - -import Base.* - -@doc doc""" - *(x::AbstractAlgebra.MatElem, P::Generic.perm) -> Apply the pemutation $P$ to the rows of the matrix $x$ and return the result. -""" -function *(x::AbstractAlgebra.MatElem, P::Generic.perm) - z = similar(x) - m = nrows(x) - n = ncols(x) - for i = 1:m - for j = 1:n - z[i, j] = x[i,P[j]] - end - end - return z -end - -function (p::perm)(A::MatElem) - length(p.d) == A.r == A.c || throw("Can't act via $p on matrix of size ($(A.r), $(A.c))") - return p*A*inv(p) +function (g::WreathProductElem{N})(A::MatElem) where N + # @assert N == size(A,1) == size(A,2) + flips = ntuple(i->(g.n[i].d[1]==1 && g.n[i].d[2]==2 ? 1 : -1), N) + result = similar(A) + @inbounds for i = 1:size(A,1) + for j = 1:size(A,2) + x = A[g.p[i], g.p[j]] + result[i, j] = x*(flips[i]*flips[j]) + # result[i, j] = AbstractAlgebra.mul!(x, x, flips[i]*flips[j]) + # this mul! needs to be separately defined, but is 2x faster + end + end + return result end ############################################################################### @@ -250,23 +274,18 @@ function AutFG_emb(A::AutGroup, g::WreathProductElem) return elt end -function AutFG_emb(A::AutGroup, p::perm) - isa(A.objectGroup, FreeGroup) || throw("Not an Aut(Fₙ)") - parent(p).n == length(A.objectGroup.gens) || throw("No natural embedding of $(parent(p)) into $A") - return A(Groups.perm_autsymbol(p)) -end - function (g::WreathProductElem)(a::Groups.Automorphism) A = parent(a) - g = AutFG_emb(A,g) - res = A() - Groups.r_multiply!(res, g.symbols, reduced=false) - Groups.r_multiply!(res, a.symbols, reduced=false) - Groups.r_multiply!(res, [inv(s) for s in reverse!(g.symbols)]) + g_emb = AutFG_emb(A,g) + res = deepcopy(g_emb) + res = Groups.r_multiply!(res, a.symbols, reduced=false) + res = Groups.r_multiply!(res, [inv(s) for s in reverse!(g_emb.symbols)]) return res end function (p::perm)(a::Groups.Automorphism) - g = AutFG_emb(parent(a),p) - return g*a*inv(g) + res = parent(a)(Groups.perm_autsymbol(p)) + res = Groups.r_multiply!(res, a.symbols, reduced=false) + res = Groups.r_multiply!(res, [Groups.perm_autsymbol(inv(p))]) + return res end