Skip to content

Commit

Permalink
add randomization for commatrices
Browse files Browse the repository at this point in the history
  • Loading branch information
mkborregaard committed Jan 7, 2019
1 parent f9c5fa5 commit b28b37e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Randomizations.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Random


matrixrandomizer(com::ComMatrix, rng = Xoroshiro128Plus();
method::matrixrandomizations = curveball) = "Only defined for Boolean Assemblages"
matrixrandomizer(asm::SEAssemblage, rng = Xoroshiro128Plus();
method::matrixrandomizations = curveball) = "Only defined for Boolean Assemblages"

Expand All @@ -12,8 +13,22 @@ function matrixrandomizer(asm::S, rng = Xoroshiro128Plus();
ret
end

Random.rand(r::MatrixGenerator{R, Assemblage}) where R = copy(rand!(r))
function matrixrandomizer(com::C, rng = Xoroshiro128Plus();
method::matrixrandomizations = curveball) where C <: ComMatrix{Bool}
cm = copy(com)
ret = MatrixGenerator{typeof(rng), typeof(cm)}(as, method, rng)
dropzeros!(ret.m.occurrences)
ret
end

Random.rand(r::MatrixGenerator{R, <:Assemblage}) where R = copy(rand!(r))
function Random.rand!(r::MatrixGenerator{R, A}) where {R} where {A <: Assemblage}
RandomBooleanMatrices._curveball!(r.m.occ.commatrix.occurrences)
r.m
end

Random.rand(r::MatrixGenerator{<:ComMatrix}) where R = copy(rand!(r))
function Random.rand!(r::MatrixGenerator{C}) where {A <: ComMatrix}
RandomBooleanMatrices._curveball!(r.m.occurrences)
r.m
end

0 comments on commit b28b37e

Please sign in to comment.