@@ -6,7 +6,7 @@ iterate(f::Fun{SequenceSpace}, st) = f[st], st+1
6
6
7
7
getindex (f:: Fun{SequenceSpace} , k:: Integer ) =
8
8
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)
10
10
getindex (f:: Fun{SequenceSpace} ,K) = cfstype (f)[f[k] for k in K]
11
11
12
12
length (f:: Fun{SequenceSpace} ) = ℵ₀
@@ -80,7 +80,10 @@ ones(S::ConstantSpace) = Fun(S,fill(1.0,1))
80
80
ones (S:: Union{AnyDomain,UnsetSpace} ) = ones (ConstantSpace ())
81
81
zeros (S:: AnyDomain ) = zero (ConstantSpace ())
82
82
zero (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
84
87
evaluate (f:: AbstractVector ,:: ZeroSpace ,x... )= zero (eltype (f))
85
88
86
89
@@ -173,8 +176,15 @@ defaultMultiplication(f::Fun,b::ConstantSpace) = ConcreteMultiplication(f,b)
173
176
174
177
bandwidths (D:: ConcreteMultiplication{CS1,CS2,T} ) where {CS1<: ConstantSpace ,CS2<: ConstantSpace ,T} =
175
178
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
178
188
179
189
rangespace (D:: ConcreteMultiplication{CS1,CS2,T} ) where {CS1<: ConstantSpace ,CS2<: ConstantSpace ,T} =
180
190
D. space
0 commit comments