Skip to content

Commit

Permalink
improved complement parity for *,∧,∨,⋅ products
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Apr 30, 2020
1 parent 7bbc28e commit 7bd38c3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Project.toml
@@ -1,7 +1,7 @@
name = "Grassmann"
uuid = "4df31cd9-4c27-5bea-88d0-e6a7146666d8"
authors = ["Michael Reed"]
version = "0.5.9"
version = "0.5.10"

[deps]
AbstractTensors = "a8e43f4a-99b7-5565-8bf1-0165161caaea"
Expand All @@ -17,7 +17,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[compat]
julia = "1"
Leibniz = "0.0.5"
DirectSum = "0.5.7"
DirectSum = "0.5.8"
AbstractTensors = "0.4.3"
ComputedFieldTypes = "0.1"
StaticArrays = "0"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/algebra.md
Expand Up @@ -102,9 +102,9 @@ The first part of the book focused on anti-symmetric exterior algebra, while the
Elements ``\omega_k`` in the space ``\Lambda V`` of anti-symmetric algebra are often studied as unit quantum state vectors in a unitary probability space, where ``\sum_k\omega_k\neq\bigotimes_k\omega_k`` is entanglement.

**Definition** (Reverse, involute, conjugate).
The `reverse` of ``\langle\omega\rangle_r`` is defined as ``\langle\tilde\omega\rangle_r = (-1)^{(r-1)r/2}\langle\omega\rangle_r``, while the `involute` is ``\langle\omega\rangle_r^\times=(-1)^r\langle\omega\rangle_r`` and Clifford `conj` ``\langle\omega\rangle_r^\ddagger`` is the composition of `involute` and `reverse`.
The `reverse` of ``\langle\omega\rangle_r`` is defined as ``\langle\tilde\omega\rangle_r = (-1)^{(r-1)r/2}\langle\omega\rangle_r``, while the `involute` is ``\langle\omega\rangle_r^\times=(-1)^r\langle\omega\rangle_r`` and `clifford` ``\langle\omega\rangle_r^\ddagger`` is the composition of `involute` and `reverse`.
```@repl ga
conj(v234) == involute(~v234)
clifford(v234) == involute(~v234)
```
**Definition** (Reversed product).
Define the index reversed product ``\ast`` which yields a Hilbert space structure:
Expand Down
16 changes: 11 additions & 5 deletions src/parity.jl
Expand Up @@ -37,22 +37,28 @@ end
return pcc, bas, cc, zero(UInt)
end

function paritycomplementinverse(N,G)#,S)
parityreverse(N-G)parityreverse(G)isodd(binomial(N,2))#⊻isodd(count_ones(S))
end

@pure function parityregressive(V::Signature{N,M,S},a,b,::Val{skew}=Val{false}()) where {N,M,S,skew}
D = diffvars(V)
(A,B,Q,Z),NG = symmetricmask(V,a,b),N-D
A,B,Q,Z = symmetricmask(V,a,b)
α,β = complement(N,A,D),complement(N,B,D)
cc = skew && (hasinforigin(V,A,β) || hasorigininf(V,A,β))
if ((count_ones&β)==0) && !diffcheck(V,α,β)) || cc
C,L = α β, count_ones(A)+count_ones(B)
bas = complement(N,C,D)
pcc,bas = if skew
A3,β3,i2o,o2i,xor = conformalcheck(V,A,β)
cx,bas = cc || xor, complement(N,C,D)
cx = cc || xor
cx && parity(V,A3,β3)(i2o || o2i)(xor&!i2o), cx ? (A3|β3)bas : bas
else
false, A+B0 ? complement(N,C,D) : g_zero(UInt)
false, A+B0 ? bas : g_zero(UInt)
end
par = parityrighthodge(S,A,N)parityrighthodge(S,B,N)parityrighthodge(S,C,N)
return (isodd(L*(L-grade(V)))parparity(N,S,α,β)pcc)::Bool, bas|Q, true, Z
par = parityright(S,A,N)parityright(S,B,N)parityright(S,C,N)
invert = paritycomplementinverse(N-D,count_ones(C))#,UInt(0))
return (invertparparity(N,S,α,β)pcc)::Bool, bas|Q, true, Z
else
return false, g_zero(UInt), false, Z
end
Expand Down
18 changes: 9 additions & 9 deletions src/products.jl
Expand Up @@ -58,10 +58,10 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
@generated function *(a::Chain{V,G,T},b::SubManifold{V,L}) where {V,G,L,T<:$Field}
if G == 0
return :(a[1]*b)
elseif L == ndims(V) && !istangent(V) && !DirectSum.hasconformal(V)
elseif L == ndims(V) && !istangent(V)
return :((~a))
elseif G == ndims(V) && !istangent(V)
return :(a[1]*(~involute(b)))
return :(a[1]*complementlefthodge(~b))
elseif binomial(ndims(V),G)<(1<<cache_limit)
$(insert_expr((:N,:t,:out,:ib,),:svec)...)
for i 1:binomial(N,G)
Expand All @@ -84,8 +84,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
return :(a*b[1])
elseif G == ndims(V) && !istangent(V)
return :((~a)*b[1])
#=elseif L == ndims(V) && !istangent(V)
return :(⋆(~involute(b)))=#
elseif L == ndims(V) && !istangent(V)
return :(complementlefthodge(~b))
elseif binomial(ndims(V),G)<(1<<cache_limit)
$(insert_expr((:N,:t,:out,:ib,),:svec)...)
for i 1:binomial(N,G)
Expand All @@ -106,10 +106,10 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
@generated function *(a::Chain{V,G,T},b::Simplex{V,L,B,S}) where {V,G,T<:$Field,L,B,S<:$Field}
if G == 0
return :(a[1]*b)
elseif L == ndims(V) && !istangent(V) && !DirectSum.hasconformal(V)
elseif L == ndims(V) && !istangent(V)
return :((~a)*value(b))
elseif G == ndims(V) && !istangent(V)
return :(a[1]*(~involute(b)))
return :(a[1]*complementlefthodge(~b))
elseif ndims(V)<cache_limit
$(insert_expr((:N,:t,:out,:ib,),:svec)...)
X = bits(B)
Expand All @@ -134,8 +134,8 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
return :(a*b[1])
elseif G == ndims(V) && !istangent(V)
return :((~a)*b[1])
#=elseif L == ndims(V) && !istangent(V)
return :(value(a)*⋆(~involute(b)))=#
elseif L == ndims(V) && !istangent(V)
return :(value(a)*complementlefthodge(~b))
elseif ndims(V)<cache_limit
$(insert_expr((:N,:t,:out,:ib,),:svec)...)
A = bits(B)
Expand All @@ -161,7 +161,7 @@ function generate_products(Field=Field,VEC=:mvec,MUL=:*,ADD=:+,SUB=:-,CONJ=:conj
elseif L == 0
return :(Chain{V,G}(broadcast($$MUL,a.v,Ref(b[1]))))
elseif G == ndims(V) && !istangent(V)
return :(a[1]*(~involute(b)))
return :(a[1]*complementlefthodge(~b))
elseif L == ndims(V) && !istangent(V)
return :((~a)*b[1])
elseif binomial(ndims(V),G)*binomial(ndims(V),L)<(1<<cache_limit)
Expand Down

0 comments on commit 7bd38c3

Please sign in to comment.