From 5ef1bcbd0deb612295329b3cc439c8663fd229b2 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Wed, 24 Jan 2024 22:50:20 -0500 Subject: [PATCH] more fixes --- src/entanglement.jl | 2 +- src/randoms.jl | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/entanglement.jl b/src/entanglement.jl index fafeec4dd..31e7c3e8c 100644 --- a/src/entanglement.jl +++ b/src/entanglement.jl @@ -201,7 +201,7 @@ function entanglement_entropy(state::AbstractStabilizer, subsystem::AbstractVect graph = Graphs.Graph(state) adjmat = Graphs.adjacency_matrix(graph) other_subsystem = filter(i->!(i in collect(subsystem)), 1:Graphs.nv(graph)) - subadjmat = Nemo.matrix(Nemo.residue_ring(Nemo.ZZ, 2), collect(adjmat[subsystem,other_subsystem])) + subadjmat = Nemo.matrix(Nemo.GF(2), collect(adjmat[subsystem,other_subsystem])) LinearAlgebra.rank(subadjmat) end diff --git a/src/randoms.jl b/src/randoms.jl index 1af3dd392..ce3cbe0b5 100644 --- a/src/randoms.jl +++ b/src/randoms.jl @@ -167,10 +167,8 @@ function precise_inv(a)::Matrix{UInt8} end function nemo_inv(a, n)::Matrix{UInt8} - binaryring = Nemo.residue_ring(Nemo.ZZ, 2) # TODO should I use GF(2) instead of ResidueRing(ZZ, 2)? - M = Nemo.matrix_space(binaryring, n, n) - inverted = inv(M(Matrix{Int}(a))) # Nemo is very picky about input data types - return (x->mod(UInt8(x.data),0x2)).(inverted) + inverted = inv(Nemo.matrix(Nemo.GF(2),a)) + return UInt8.(inverted.==1) # maybe there is a better way to do the conversion end """Sample (h, S) from the distribution P_n(h, S) from Bravyi and Maslov Algorithm 1."""