@@ -6,7 +6,7 @@ iterate(f::Fun{SequenceSpace}, st) = f[st], st+1
66
77getindex (f:: Fun{SequenceSpace} , k:: Integer ) =
88 k ≤ ncoefficients (f) ? f. coefficients[k] : zero (cfstype (f))
9- getindex (f:: Fun{SequenceSpace} ,K:: CartesianIndex{0} ) = f[ 1 ]
9+ getindex (f:: Fun{SequenceSpace} ,K:: CartesianIndex{0} ) = _first_or_zero (f)
1010getindex (f:: Fun{SequenceSpace} ,K) = cfstype (f)[f[k] for k in K]
1111
1212length (f:: Fun{SequenceSpace} ) = ℵ₀
@@ -80,7 +80,10 @@ ones(S::ConstantSpace) = Fun(S,fill(1.0,1))
8080ones (S:: Union{AnyDomain,UnsetSpace} ) = ones (ConstantSpace ())
8181zeros (S:: AnyDomain ) = zero (ConstantSpace ())
8282zero (S:: UnsetSpace ) = zero (ConstantSpace ())
83- evaluate (f:: AbstractVector ,:: ConstantSpace ,x... )= f[1 ]
83+ _first_or_zero (f:: AbstractVector ) = get (f, 1 , zero (eltype (f)))
84+ function evaluate (f:: AbstractVector ,:: ConstantSpace ,x... )
85+ _first_or_zero (f)
86+ end
8487evaluate (f:: AbstractVector ,:: ZeroSpace ,x... )= zero (eltype (f))
8588
8689
@@ -173,8 +176,15 @@ defaultMultiplication(f::Fun,b::ConstantSpace) = ConcreteMultiplication(f,b)
173176
174177bandwidths (D:: ConcreteMultiplication{CS1,CS2,T} ) where {CS1<: ConstantSpace ,CS2<: ConstantSpace ,T} =
175178 0 ,0
176- getindex (D:: ConcreteMultiplication{CS1,CS2,T} ,k:: Integer ,j:: Integer ) where {CS1<: ConstantSpace ,CS2<: ConstantSpace ,T} =
177- k== j== 1 ? strictconvert (T,D. f. coefficients[1 ]) : one (T)
179+
180+ function getindex (D:: ConcreteMultiplication{<:ConstantSpace,<:ConstantSpace,T} ,k:: Integer ,j:: Integer ) where {T}
181+ if k== j== 1
182+ c = _first_or_zero (coefficients (D. f))
183+ strictconvert (T, c)
184+ else
185+ one (T)
186+ end
187+ end
178188
179189rangespace (D:: ConcreteMultiplication{CS1,CS2,T} ) where {CS1<: ConstantSpace ,CS2<: ConstantSpace ,T} =
180190 D. space
0 commit comments