This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Grassmann; | |
@basis D"1,1,1,0"; | |
P = [ rand()*v124 + rand()*v134 + rand()*v234 + v123 for i=1:1000 ]; | |
L = [ rand()*v12 + rand()*v13 + rand()*v14 + rand()*v23 + rand()*v24 + rand()*v34 for i=1:1000 ]; | |
A = [ rand() for i=1:1000]; | |
test2(L,A,P) = (LA = exp.(L.*A); LA.*P.*.~LA); | |
R = test2(L,A,P); | |
f(L,A,P,i) = (LA = exp(L[i]*A[i]); LA*P[i]*~LA); | |
function test(L,A,P,R) | |
for k ∈ 1:1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dendriform, LightGraphs, GraphPlot, Colors | |
function highlight_sum(a::Grove,b::Grove) | |
d = a.degr + b.degr | |
g = DiGraph(Int(Cn(d))) | |
for i = 1:Int(Cn(d)) | |
u = Dendriform.posetnext(PBTree(d,i)) | |
for t in u | |
add_edge!(g,i,treeindex(t)) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Dendriform, ResumableFunctions | |
@resumable function trees(g::Union{Grove,PBTree}) | |
typeof(g) == PBTree && return ResumableFunctions.@yield g | |
for i ∈ 1:g.size-1 | |
ResumableFunctions.@yield PBTree(g.Y[i,:]) | |
end | |
return PBTree(g.Y[end,:]) | |
end | |
import Base.convert | |
convert(::Type{Array{PBTree,1}},g::Grove) = [trees(g)...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g(y::BigInt,x::BigInt) = BigInt((abs(y-x) + y-x)//2) | |
r(y::BigInt,x::BigInt)::BigInt = (x==0) ? y : mod(y,x) | |
p(n::Int) = sum(i->g(BigInt(1),g(sum(j->r((factorial(g(BigInt(j),BigInt(1))))^2,BigInt(j)),0:i),BigInt(n))),0:n^2) | |
map(p,1:17) |