Skip to content

Commit 151abdc

Browse files
committed
improved support for tangent SubManifld operations
1 parent 9df2073 commit 151abdc

4 files changed

Lines changed: 40 additions & 14 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DirectSum"
22
uuid = "22fd7b30-a8c0-5bf2-aabe-97783860d07c"
33
authors = ["Michael Reed"]
4-
version = "0.4.0"
4+
version = "0.4.1"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/DirectSum.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,16 @@ end
275275
d<0 ? typemax(Bits)-v : v
276276
end
277277

278+
@pure function symmetricsplit(V::M,a) where M<:Manifold
279+
sm,dm = symmetricmask(V,a),diffmask(V)
280+
mixedmode(V)<0 ? (sm&dm[1],sm&dm[2]) : sm
281+
end
282+
283+
@pure function symmetricmask(V::M,a) where M<:Manifold
284+
d = diffmask(V)
285+
a&(mixedmode(V)<0 ? |(d...) : d)
286+
end
287+
278288
@pure function symmetricmask(V::M,a,b) where M<:Manifold
279289
d = diffmask(V)
280290
D = mixedmode(V)<0 ? |(d...) : d

src/indices.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,16 @@ end
186186

187187
@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
188188

189+
@pure function indexstring(V::M,D) where M<:Manifold
190+
io = IOBuffer()
191+
printlabel(io,V,D,true,"x","X","x","X")
192+
String(take!(io))
193+
end
194+
195+
@pure indexsymbol(V::M,D) where M<:Manifold = Symbol(indexstring(V,D))
196+
197+
@pure indexsplit(B,N) = [UInt(1)<<(k-1) for k indices(B,N)]
198+
189199
function indexparity!(ind::Vector{Int},s::M) where M<:Manifold
190200
k = 1
191201
t = false

src/operations.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ end
7171
for op (:*,:)
7272
@eval begin
7373
@pure $op(a::T,::Q) where {T<:VectorBundle{N,M,S},Q<:VectorBundle{N,M,S}} where {N,M,S} = a
74-
@pure $op(a::M,::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = a
75-
@pure $op(::T,b::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = b
76-
@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)
77-
@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}
74+
@pure $op(a::M,::SubManifold{Y,m,B}) where {Y,m,M<:VectorBundle,A,B} = am
75+
@pure $op(::SubManifold{X,m,A},b::M) where {X,m,M<:VectorBundle,A,B} = mb
76+
@pure $op(::SubManifold{X,M,A} where X,::SubManifold{Y,M,B} where Y) where {M,A,B} = SubManifold{M}(A|B)
77+
@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}
7878
D1,O1,C1 = options_list(a)
7979
D2,O2,C2 = options_list(b)
80-
if ((C1C2)&&(C10)&&(C20)) && a==b'
80+
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
81+
(T<:Signature ? Signature : DiagnoalManifold){max(N1,N2),M1,S1,max(V1,V2),max(d1,d2)}()
82+
elseif ((C1C2)&&(C10)&&(C20)) && a==b'
8183
return C1>0 ? ba : ab
8284
elseif min(C1,C2)<0 && max(C1,C2)0
8385
Y = C1<0 ? ba : ab
@@ -92,18 +94,20 @@ for op ∈ (:*,:∪)
9294
end
9395
end
9496

95-
(x::T) where T<:Manifold = x
96-
(a::A,b::B,c::C...) where {A<:Manifold,B<:Manifold,C<:Manifold} = (ab,c...)
97+
@pure (x::T) where T<:Manifold = x
98+
(a::A,b::B,c::C...) where {A<:Manifold,B<:Manifold,C<:Manifold} = (a*b,c...)
9799

98100
@pure (a::T,::Q) where {T<:VectorBundle{N,M,S},Q<:VectorBundle{N,M,S}} where {N,M,S} = a
99101
@pure (a::T,::S) where {T<:VectorBundle{N},S<:VectorBundle{N}} where N = V0
100-
@pure (::M,b::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = b
101-
@pure (a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = a
102+
#@pure ∩(::M,b::Q) where Q<:SubManifold{Y,M,B} where Y where {M<:VectorBundle,A,B} = b
103+
#@pure ∩(a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = a
102104
@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)
103-
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1},S<:VectorBundle{N2,M2,S2}} where {N1,M1,S1,N2,M2,S2}
105+
@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}
104106
D1,O1,C1 = options_list(a)
105107
D2,O2,C2 = options_list(b)
106-
if ((C1C2)&&(C10)&&(C20))
108+
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
109+
(T<:Signature ? Signature : DiagnoalManifold){min(N1,N2),M1,S1,min(V1,V2),min(d1,d2)}()
110+
elseif ((C1C2)&&(C10)&&(C20))
107111
return V0
108112
elseif min(C1,C2)<0 && max(C1,C2)0
109113
Y = C1<0
@@ -122,10 +126,12 @@ end
122126
@pure (::M,b::Q) where Q<:SubManifold{Y,M,B} where {M<:VectorBundle,A,B,Y} = ndims(M) == Y
123127
@pure (a::T,::M) where T<:SubManifold{X,M,A} where X where {M<:VectorBundle,A,B} = true
124128
@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
125-
@pure function (a::T,b::S) where {T<:VectorBundle{N1,M1,S1},S<:VectorBundle{N2,M2,S2}} where {N1,M1,S1,N2,M2,S2}
129+
@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}
126130
D1,O1,C1 = options_list(a)
127131
D2,O2,C2 = options_list(b)
128-
if ((C1C2)&&(C10)&&(C20)) || ((C1<0)&&(C20))
132+
if (M1,S1) == (M2,S2) && (V1,d1) (V2,d2)
133+
V1 V2 && d1 d2
134+
elseif ((C1C2)&&(C10)&&(C20)) || ((C1<0)&&(C20))
129135
return false
130136
elseif C2<0 && C10
131137
return (C1>0 ? a'a : aa') == b

0 commit comments

Comments
 (0)