1
1
module ApproxFunBaseTest
2
2
3
+ Base. Experimental. @optlevel 1
4
+
3
5
using ApproxFunBase
4
6
using ApproxFunBase: plan_transform, plan_itransform, israggedbelow, RaggedMatrix, isbandedbelow, isbanded,
5
7
blockstart, blockstop, resizedata!
@@ -142,11 +144,18 @@ function backend_testinfoperator(A)
142
144
@test isa (A[k,j],eltype (A))
143
145
end
144
146
145
- @test A[1 : 5 ,1 : 5 ][2 : 5 ,1 : 5 ] ≈ A[2 : 5 ,1 : 5 ]
146
- @test A[1 : 5 ,2 : 5 ] ≈ A[1 : 5 ,1 : 5 ][:,2 : end ]
147
- @test A[1 : 10 ,1 : 10 ][5 : 10 ,5 : 10 ] ≈ [A[k,j] for k= 5 : 10 ,j= 5 : 10 ]
148
- @test A[1 : 10 ,1 : 10 ][5 : 10 ,5 : 10 ] ≈ A[5 : 10 ,5 : 10 ]
149
- @test A[1 : 30 ,1 : 30 ][20 : 30 ,20 : 30 ] ≈ A[20 : 30 ,20 : 30 ]
147
+ A10 = A[1 : 10 ,1 : 10 ]
148
+ A10m = Matrix (A10)
149
+ A10_510 = A10m[5 : 10 ,5 : 10 ]
150
+ A30 = A[1 : 30 ,1 : 30 ]
151
+ A30_2030 = A30[20 : 30 ,20 : 30 ]
152
+ A30_2030m = Matrix (A30_2030)
153
+
154
+ @test Matrix (B[2 : 5 ,1 : 5 ]) ≈ Matrix (A[2 : 5 ,1 : 5 ])
155
+ @test Matrix (A[1 : 5 ,2 : 5 ]) ≈ Matrix (B[:,2 : end ])
156
+ @test A10_510 ≈ [A[k,j] for k= 5 : 10 ,j= 5 : 10 ]
157
+ @test A10_510 ≈ Matrix (A[5 : 10 ,5 : 10 ])
158
+ @test A30_2030m ≈ Matrix (A[20 : 30 ,20 : 30 ])
150
159
151
160
@test Matrix (A[Block (1 ): Block (3 ),Block (1 ): Block (3 )]) ≈ Matrix (A[blockstart (rangespace (A),1 ): blockstop (rangespace (A),3 ),blockstart (domainspace (A),1 ): blockstop (domainspace (A),3 )])
152
161
@test Matrix (A[Block (3 ): Block (4 ),Block (2 ): Block (4 )]) ≈ Matrix (A[blockstart (rangespace (A),3 ): blockstop (rangespace (A),4 ),blockstart (domainspace (A),2 ): blockstop (domainspace (A),4 )])
@@ -157,29 +166,39 @@ function backend_testinfoperator(A)
157
166
end
158
167
159
168
co= cache (A)
160
- @test co[1 : 10 ,1 : 10 ] ≈ A[1 : 10 ,1 : 10 ]
161
- @test co[1 : 10 ,1 : 10 ] ≈ A[1 : 10 ,1 : 10 ]
162
- @test co[20 : 30 ,20 : 30 ] ≈ A[1 : 30 ,1 : 30 ][20 : 30 ,20 : 30 ]
169
+ @test Matrix (co[1 : 10 ,1 : 10 ]) ≈ A10m
170
+ @test Matrix (co[20 : 30 ,20 : 30 ]) ≈ A30_2030m
163
171
164
172
let C= cache (A)
165
173
resizedata! (C,5 ,35 )
166
174
resizedata! (C,10 ,35 )
167
- @test C. data[1 : 10 ,1 : C. datasize[2 ]] ≈ A[1 : 10 ,1 : C. datasize[2 ]]
175
+ @test Matrix ( C. data[1 : 10 ,1 : C. datasize[2 ]]) ≈ Matrix ( A[1 : 10 ,1 : C. datasize[2 ]])
168
176
end
169
177
end
170
178
171
179
# Check that the tests pass after conversion as well
172
180
function testinfoperator (A:: Operator{T} ) where T<: Real
173
181
backend_testinfoperator (A)
174
- backend_testinfoperator (strictconvert (Operator{Float64}, A))
175
- backend_testinfoperator (strictconvert (Operator{Float32}, A))
176
- backend_testinfoperator (strictconvert (Operator{ComplexF64}, A))
182
+ if T != Float64
183
+ B = strictconvert (Operator{Float64}, A)
184
+ backend_testinfoperator (B)
185
+ end
186
+ if T != Float32
187
+ B = strictconvert (Operator{Float32}, A)
188
+ backend_testinfoperator (B)
189
+ end
190
+ B = strictconvert (Operator{ComplexF64}, A)
191
+ backend_testinfoperator (B)
177
192
end
178
193
179
194
function testinfoperator (A:: Operator{T} ) where T<: Complex
180
195
backend_testinfoperator (A)
181
- backend_testinfoperator (strictconvert (Operator{ComplexF32}, A))
182
- backend_testinfoperator (strictconvert (Operator{ComplexF64}, A))
196
+ if T != ComplexF32
197
+ backend_testinfoperator (strictconvert (Operator{ComplexF32}, A))
198
+ end
199
+ if T != ComplexF64
200
+ backend_testinfoperator (strictconvert (Operator{ComplexF64}, A))
201
+ end
183
202
end
184
203
185
204
function testraggedbelowoperator (A)
0 commit comments