Skip to content

Commit 5bfe08f

Browse files
authored
Short-circuit promotedomainspace for Multiplication (#584)
1 parent db0ed61 commit 5bfe08f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/Operators/banded/Multiplication.jl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,21 @@ getindex(D::ConcreteMultiplication{F,UnsetSpace,T},k::Integer,j::Integer) where
7777

7878

7979
##multiplication can always be promoted, range space is allowed to change
80-
promotedomainspace(D::Multiplication,sp::UnsetSpace) = D
81-
promotedomainspace(D::Multiplication,sp::Space) = Multiplication(D.f,sp)
82-
promoterangespace(D::ConcreteMultiplication{P,UnsetSpace},sp::UnsetSpace) where {P} = D
83-
promoterangespace(D::ConcreteMultiplication{P,UnsetSpace},sp::Space) where {P} =
80+
promotedomainspace(D::Multiplication, sp::UnsetSpace) = D
81+
function promotedomainspace(D::Multiplication, sp::Space)
82+
if domainspace(D) == sp
83+
D
84+
else
85+
Multiplication(D.f,sp)
86+
end
87+
end
88+
promoterangespace(D::ConcreteMultiplication{P,UnsetSpace}, sp::UnsetSpace) where {P} = D
89+
promoterangespace(D::ConcreteMultiplication{P,UnsetSpace}, sp::Space) where {P} =
8490
promoterangespace(Multiplication(D.f,ConstantSpace(domain(sp))), sp)
8591

86-
choosedomainspace(M::ConcreteMultiplication{D,UnsetSpace},::UnsetSpace) where {D} = space(M.f)
92+
choosedomainspace(M::ConcreteMultiplication{D,UnsetSpace}, ::UnsetSpace) where {D} = space(M.f)
8793
# we assume multiplication maps spaces to themselves
88-
choosedomainspace(M::ConcreteMultiplication{D,UnsetSpace},sp::Space) where {D} = sp
94+
choosedomainspace(M::ConcreteMultiplication{D,UnsetSpace}, sp::Space) where {D} = sp
8995

9096

9197
diagm(a::Fun) = Multiplication(a)

0 commit comments

Comments
 (0)