Skip to content

Commit

Permalink
new file: test/test1.jl
Browse files Browse the repository at this point in the history
modified:   src/PermPlain.jl
modified:   test/runtests.jl
  • Loading branch information
jlapeyre committed Dec 13, 2014
1 parent 404eb72 commit 1013729
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/PermPlain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ end

# Compute power of permutation. Both input and output are PCYC
# see pari perm.c
# Careful of degeneracy, and empty array may be returned.
function permpower{T<:Real}(cyc::AbstractArray{Array{T,1},1}, exp::Integer)
r = 1
for j in 1:length(cyc)
Expand Down
3 changes: 1 addition & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using PermPlain
using Base.Test

# write your own tests here
@test 1 == 1
include("test1.jl")
20 changes: 20 additions & 0 deletions test/test1.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
c = Array(Array{Int,1},0)
push!(c, Int[1,6,14,7,3,11])
push!(c, Int[2,8,12,9,10,5,15,4])

@test PermPlain.permcycles(PermPlain.cycstoperm(c)) == c
np = 3
p = PermPlain.cycstoperm(c)
pp = PermPlain.permpower(p,np);
pp1 = PermPlain.permpower2(p,np);
c1 = PermPlain.permpower(c,np);
p2 = PermPlain.cycstoperm(c1);
@test pp == p2
@test pp1 == p2
@test PermPlain.permcycles(pp) == PermPlain.canoncycles(c1)
@test PermPlain.cyc_pow_perm(c,np) == pp





0 comments on commit 1013729

Please sign in to comment.