Skip to content

Commit 3d5dfc4

Browse files
committed
improved default dispatch
1 parent 8fc6ac2 commit 3d5dfc4

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/DirectSum.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function Base.show(io::IO,s::SubManifold{V,NN,S}) where {V,NN,S}
266266
ind = indices(S)
267267
for k hasinf(s)+hasorigin(s)+1+(d<0 ? abs(d) : 0):NM
268268
print(io,k ind ? sig(M,k) : '_')
269-
printsep(io,M,k,NN)
269+
printsep(io,M,k,NM)
270270
end
271271
d>0 && print(io,[((C>0)!polymode(s) ? sups : subs)[x-NM] for x ind[N+1:N+abs(d)]]...)
272272
d>0 && C<0 && print(io,[sups[x-NM] for x ind[N+abs(d)+1:end]]...)
@@ -299,6 +299,10 @@ end
299299
@pure Signature(V::DiagonalForm{N,M}) where {N,M} = Signature{N,M}(Vector(signbit.(V[:])))
300300
@pure DiagonalForm(V::Signature{N,M}) where {N,M} = DiagonalForm{N,M}([t ? -1 : 1 for tV[:]])
301301

302+
@pure submanifold(V::SubManifold) = isbasis(V) ? V(Manifold(V)) : V
303+
@pure submanifold(V::TensorBundle) = SubManifold(V)
304+
@pure submanifold(V::Int) = SubManifold(V)
305+
302306
# indices
303307

304308
#@pure supblade(N,S,B) = bladeindex(N,expandbits(N,S,B))
@@ -362,8 +366,8 @@ Simplex type with pseudoscalar `V::Manifold`, grade/rank `G::Int`, `B::SubManifo
362366
"""
363367
struct Simplex{V,G,B,T} <: TensorTerm{V,G}
364368
v::T
365-
Simplex{A,B,C,D}(t::E) where E<:D where {A,B,C,D} = new{A,B,C,D}(t)
366-
Simplex{A,B,C,D}(t::E) where E<:TensorAlgebra{A} where {A,B,C,D} = new{A,B,C,D}(t)
369+
Simplex{A,B,C,D}(t::E) where E<:D where {A,B,C,D} = new{submanifold(A),B,C,D}(t)
370+
Simplex{A,B,C,D}(t::E) where E<:TensorAlgebra{A} where {A,B,C,D} = new{submanifold(A),B,C,D}(t)
367371
end
368372

369373
export Simplex

src/operations.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ end
176176
end
177177

178178
@pure function (W::SubManifold{Q,M})(b::SubManifold{V,G,R}) where {Q,M,V,G,R}
179-
if isbasis(W)
179+
if isbasis(W) && !isbasis(b)
180+
RS = R&UInt(W)
181+
L = count_ones(RS)
182+
L == G ? b : SubManifold{V,L,RS}()
183+
elseif isbasis(W)
180184
if Q == V
181185
if G == M == 1
182186
y,v = evaluate1(W,b)

0 commit comments

Comments
 (0)