Skip to content

Commit

Permalink
improved support for tangent SubManifld operations
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Sep 29, 2019
1 parent 9df2073 commit 151abdc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DirectSum"
uuid = "22fd7b30-a8c0-5bf2-aabe-97783860d07c"
authors = ["Michael Reed"]
version = "0.4.0"
version = "0.4.1"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
10 changes: 10 additions & 0 deletions src/DirectSum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,16 @@ end
d<0 ? typemax(Bits)-v : v
end

@pure function symmetricsplit(V::M,a) where M<:Manifold
sm,dm = symmetricmask(V,a),diffmask(V)
mixedmode(V)<0 ? (sm&dm[1],sm&dm[2]) : sm
end

@pure function symmetricmask(V::M,a) where M<:Manifold
d = diffmask(V)
a&(mixedmode(V)<0 ? |(d...) : d)
end

@pure function symmetricmask(V::M,a,b) where M<:Manifold
d = diffmask(V)
D = mixedmode(V)<0 ? |(d...) : d
Expand Down
10 changes: 10 additions & 0 deletions src/indices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@ end

@inline printlabel(V::T,e::Bits,label::Bool,vec,cov,duo,dif) where T<:Manifold = printlabel(IOBuffer(),V,e,label,vec,cov,duo,dif) |> take! |> String

@pure function indexstring(V::M,D) where M<:Manifold
io = IOBuffer()
printlabel(io,V,D,true,"x","X","x","X")
String(take!(io))
end

@pure indexsymbol(V::M,D) where M<:Manifold = Symbol(indexstring(V,D))

@pure indexsplit(B,N) = [UInt(1)<<(k-1) for k indices(B,N)]

function indexparity!(ind::Vector{Int},s::M) where M<:Manifold
k = 1
t = false
Expand Down
32 changes: 19 additions & 13 deletions src/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ end
for op (:*,:)
@eval begin
@pure $op(a::T,::Q) where {T<:VectorBundle{N,M,S},Q<:VectorBundle{N,M,S}} where {N,M,S} = a
@pure $op(a::M,::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = a
@pure $op(::T,b::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = b
@pure $op(::T,::Q) where {T<:SubManifold{X,M,A} where X,Q<:SubManifold{Y,M,B} where Y} where {M,A,B} = SubManifold{M}(A|B)
@pure function $op(a::T,b::S) where {T<:VectorBundle{N1,M1,S1},S<:VectorBundle{N2,M2,S2}} where {N1,M1,S1,N2,M2,S2}
@pure $op(a::M,::SubManifold{Y,m,B}) where {Y,m,M<:VectorBundle,A,B} = am
@pure $op(::SubManifold{X,m,A},b::M) where {X,m,M<:VectorBundle,A,B} = mb
@pure $op(::SubManifold{X,M,A} where X,::SubManifold{Y,M,B} where Y) where {M,A,B} = SubManifold{M}(A|B)
@pure function $op(a::T,b::S) where {T<:VectorBundle{N1,M1,S1,V1,d1},S<:VectorBundle{N2,M2,S2,V2,d2}} where {N1,M1,S1,V1,d1,N2,M2,S2,V2,d2}
D1,O1,C1 = options_list(a)
D2,O2,C2 = options_list(b)
if ((C1C2)&&(C10)&&(C20)) && a==b'
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
(T<:Signature ? Signature : DiagnoalManifold){max(N1,N2),M1,S1,max(V1,V2),max(d1,d2)}()
elseif ((C1C2)&&(C10)&&(C20)) && a==b'
return C1>0 ? ba : ab
elseif min(C1,C2)<0 && max(C1,C2)0
Y = C1<0 ? ba : ab
Expand All @@ -92,18 +94,20 @@ for op ∈ (:*,:∪)
end
end

(x::T) where T<:Manifold = x
(a::A,b::B,c::C...) where {A<:Manifold,B<:Manifold,C<:Manifold} = (ab,c...)
@pure (x::T) where T<:Manifold = x
(a::A,b::B,c::C...) where {A<:Manifold,B<:Manifold,C<:Manifold} = (a*b,c...)

@pure (a::T,::Q) where {T<:VectorBundle{N,M,S},Q<:VectorBundle{N,M,S}} where {N,M,S} = a
@pure (a::T,::S) where {T<:VectorBundle{N},S<:VectorBundle{N}} where N = V0
@pure (::M,b::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = b
@pure (a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = a
#@pure ∩(::M,b::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = b
#@pure ∩(a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = a
@pure (::T,::Q) where {T<:SubManifold{X,M,A} where X,Q<:SubManifold{Y,M,B} where Y} where {M,A,B} = SubManifold{M}(A&B)
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1},S<:VectorBundle{N2,M2,S2}} where {N1,M1,S1,N2,M2,S2}
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1,V1,d1},S<:VectorBundle{N2,M2,S2,V2,d2}} where {N1,M1,S1,V1,d1,N2,M2,S2,V2,d2}
D1,O1,C1 = options_list(a)
D2,O2,C2 = options_list(b)
if ((C1C2)&&(C10)&&(C20))
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
(T<:Signature ? Signature : DiagnoalManifold){min(N1,N2),M1,S1,min(V1,V2),min(d1,d2)}()
elseif ((C1C2)&&(C10)&&(C20))
return V0
elseif min(C1,C2)<0 && max(C1,C2)0
Y = C1<0
Expand All @@ -122,10 +126,12 @@ end
@pure (::M,b::Q) where Q<:SubManifold{Y,M,B} where {M<:VectorBundle,A,B,Y} = ndims(M) == Y
@pure (a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = true
@pure (::T,::Q) where {T<:SubManifold{X,M,A},Q<:SubManifold{Y,M,B} where Y} where {M,A,B,X} = count_ones(A&B) == X
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1},S<:VectorBundle{N2,M2,S2}} where {N1,M1,S1,N2,M2,S2}
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1,V1,d1},S<:VectorBundle{N2,M2,S2,V2,d2}} where {N1,M1,S1,V1,d1,N2,M2,S2,V2,d2}
D1,O1,C1 = options_list(a)
D2,O2,C2 = options_list(b)
if ((C1C2)&&(C10)&&(C20)) || ((C1<0)&&(C20))
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
V1 V2 && d1 d2
elseif ((C1C2)&&(C10)&&(C20)) || ((C1<0)&&(C20))
return false
elseif C2<0 && C10
return (C1>0 ? a'a : aa') == b
Expand Down

2 comments on commit 151abdc

@chakravala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/3905

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" 151abdc884393964163eca55c88c7f4b081328e6
git push origin v0.4.1

Please sign in to comment.