1
1
using ApproxFunBase
2
- using Test
3
2
using ApproxFunBase: PointSpace, HeavisideSpace, PiecewiseSegment, dimension, SVector, checkpoints, AnyDomain
4
- using StaticArrays
5
3
using BandedMatrices: rowrange, colrange, BandedMatrix
4
+ using DomainSets: Point
6
5
using LinearAlgebra
6
+ using StaticArrays
7
+ using Test
7
8
8
9
@testset " Spaces" begin
9
10
@testset " PointSpace" begin
10
11
@test eltype (domain (PointSpace ([0 ,0.1 ,1 ])) ) == Float64
11
12
12
13
f = @inferred Fun (x-> (x- 0.1 ),PointSpace ([0 ,0.1 ,1 ]))
13
14
@test roots (f) == [0.1 ]
15
+ @test first (f) == - 0.1
16
+ @test last (f) == 0.9
17
+ @test f (Point (0 )) == - 0.1
14
18
15
19
a = @inferred Fun (exp, space (f))
16
20
@test f/ a == @inferred Fun (x-> (x- 0.1 )* exp (- x),space (f))
@@ -204,6 +208,11 @@ using LinearAlgebra
204
208
F = Fun{typeof (PointSpace (1 : 3 )), Float32}
205
209
@test ApproxFunBase. cfstype (F) == Float32
206
210
end
211
+
212
+ @testset " isconstantfun" begin
213
+ f = Fun (PointSpace (1 : 4 ), ones (4 ))
214
+ @test ApproxFunBase. isconstantfun (f)
215
+ end
207
216
end
208
217
209
218
@testset " DiracSpace" begin
@@ -212,6 +221,8 @@ using LinearAlgebra
212
221
@test f (0.5 ) == 0
213
222
@test f (5 ) == 0
214
223
@test isinf (f (0 ))
224
+ @test isinf (f (Point (0 )))
225
+ @test sum (f) == 6
215
226
end
216
227
217
228
@testset " Derivative operator for HeavisideSpace" begin
@@ -317,6 +328,12 @@ using LinearAlgebra
317
328
@test g >= f
318
329
@test 1 < f < 3
319
330
@test differentiate (f) == Fun (0 , ConstantSpace (0 .. 1 ))
331
+ @test f (- 1 ) == 0
332
+ @test first (f) == last (f) == 2
333
+ @test ApproxFunBase. isconstantfun (f)
334
+
335
+ f = Fun (2 , ConstantSpace ())
336
+ @test first (f) == last (f) == 2
320
337
321
338
@test maxspace (ConstantSpace (Point (1 )), ConstantSpace (Point (2 ))) == ConstantSpace (Point (1 ) ∪ Point (2 ))
322
339
@test maxspace (ConstantSpace (Point (1 )), ConstantSpace (AnyDomain ())) == ConstantSpace (Point (1 ))
0 commit comments