@@ -8,85 +8,80 @@ import ApproxFunOrthogonalPolynomials: forwardrecurrence
8
8
end
9
9
10
10
@testset " ChebyshevInterval" begin
11
- @test Fun (x-> 2 ,10 )(.1 ) ≈ 2
12
- @test Fun (x-> 2 )(.1 ) ≈ 2
13
- @test Fun (Chebyshev,Float64[]).([0. ,1. ]) ≈ [0. ,0. ]
14
- @test Fun (Chebyshev,[])(0. ) ≈ 0.
15
- @test Fun (x-> 4 ,Chebyshev (),1 ). coefficients == [4.0 ]
16
- @test Fun (x-> 4 ). coefficients == [4.0 ]
17
- @test Fun (4 ). coefficients == [4.0 ]
11
+ @test @inferred Fun (x-> 2 ,10 )(.1 ) ≈ 2
12
+ @test @inferred Fun (x-> 2 )(.1 ) ≈ 2
13
+ @test @inferred Fun (Chebyshev,Float64[]).([0. ,1. ]) ≈ [0. ,0. ]
14
+ @test @inferred Fun (Chebyshev,[])(0. ) ≈ 0.
15
+ @test @inferred Fun (x-> 4 ,Chebyshev (),1 ). coefficients == [4.0 ]
16
+ @test @inferred Fun (x-> 4 ). coefficients == [4.0 ]
17
+ @test @inferred Fun (4 ). coefficients == [4.0 ]
18
18
19
19
20
- @test Fun (x-> 4 ). coefficients == [4.0 ]
21
- @test Fun (4 ). coefficients == [4.0 ]
20
+ @test @inferred Fun (x-> 4 ). coefficients == [4.0 ]
21
+ @test @inferred Fun (4 ). coefficients == [4.0 ]
22
22
23
- f = Fun (ChebyshevInterval (), [1 ])
23
+ f = @inferred Fun (ChebyshevInterval (), [1 ])
24
24
@test f (0.1 ) == 1
25
25
26
- ef = Fun (exp)
27
- @test ef (0.1 ) ≈ exp (0.1 )
26
+ ef = if VERSION >= v " 1.8"
27
+ @inferred Fun (exp)
28
+ else
29
+ Fun (exp)
30
+ end
31
+ @test @inferred ef (0.1 ) ≈ exp (0.1 )
32
+ @test @inferred ef (.5 ) ≈ exp (.5 )
28
33
29
34
for d in (ChebyshevInterval (),Interval (1. ,2. ),Segment (1.0 + im,2.0 + 2im ))
30
35
testspace (Chebyshev (d))
31
36
end
32
37
33
- ef = Fun (exp,ChebyshevInterval ())
34
-
35
- @test ef == - (- ef)
36
- @test ef == (ef- 1 ) + 1
37
-
38
- ef = Fun (exp)
39
-
40
- cf = Fun (cos)
41
-
42
- ecf = Fun (x-> cos (x).* exp (x))
43
- eocf = Fun (x-> cos (x)./ exp (x))
44
-
45
- @test ef (.5 ) ≈ exp (.5 )
46
- @test ecf (.123456 ) ≈ cos (.123456 ).* exp (.123456 )
38
+ y = @inferred Fun () + Fun (ChebyshevInterval {BigFloat} ())
39
+ @test y == 2 Fun ()
47
40
end
48
41
49
42
@testset " Algebra" begin
50
- ef = Fun (exp,ChebyshevInterval ())
51
-
52
- @test ef == - (- ef)
43
+ ef = @inferred Fun (exp,ChebyshevInterval ())
44
+ @test ef == @inferred - (- ef)
53
45
@test ef == (ef- 1 ) + 1
54
46
55
- @test ef / 3 == (3 \ ef)
56
-
47
+ if VERSION >= v " 1.8"
48
+ @test (@inferred ef / 3 ) == @inferred (3 \ ef)
49
+ else
50
+ @test ef / 3 == 3 \ ef
51
+ end
57
52
58
53
cf = Fun (cos)
59
54
60
- ecf = Fun (x-> cos (x). *exp (x))
61
- eocf = Fun (x-> cos (x). /exp (x))
55
+ ecf = VERSION >= v " 1.8 " ? @inferred ( Fun (x-> cos (x)* exp (x))) : Fun (x -> cos (x) * exp (x))
56
+ eocf = VERSION >= v " 1.8 " ? @inferred ( Fun (x-> cos (x)/ exp (x))) : Fun (x -> cos (x) / exp (x))
62
57
63
58
@test ef (.5 ) ≈ exp (.5 )
64
59
@test ecf (.123456 ) ≈ cos (.123456 ).* exp (.123456 )
65
60
66
61
r= 2 .* rand (100 ) .- 1
67
62
68
- @test maximum (abs,ef .(r)- exp .(r))< 200 eps ()
69
- @test maximum (abs,ecf .(r).- cos .(r).* exp .(r))< 200 eps ()
63
+ @test @inferred maximum (abs,ef .(r)- exp .(r))< 200 eps ()
64
+ @test @inferred maximum (abs,ecf .(r).- cos .(r).* exp .(r))< 200 eps ()
70
65
71
- @test (cf .* ef)(0.1 ) ≈ ecf (0.1 ) ≈ cos (0.1 )* exp (0.1 )
72
- @test domain (cf.* ef) ≈ domain (ecf)
73
- @test domain (cf.* ef) == domain (ecf)
66
+ @test (@inferred ( cf .* ef)(0.1 ) ) ≈ ecf (0.1 ) ≈ cos (0.1 )* exp (0.1 )
67
+ @test ( @inferred domain (cf.* ef) ) ≈ domain (ecf)
68
+ @test ( @inferred domain (cf.* ef) ) == domain (ecf)
74
69
75
- @test norm ((ecf- cf.* ef). coefficients)< 200 eps ()
76
- @test maximum (abs,( eocf- cf./ ef). coefficients)< 1000 eps ()
70
+ @test norm (@inferred (ecf- cf.* ef). coefficients)< 200 eps ()
71
+ @test maximum (abs,@inferred (( eocf- cf./ ef) ). coefficients)< 1000 eps ()
77
72
@test norm (((ef/ 3 ). * (3 / ef)- 1 ). coefficients)< 1000 eps ()
78
73
end
79
74
80
75
@testset " Diff and cumsum" begin
81
76
ef = Fun (exp)
82
77
cf = Fun (cos)
83
- @test norm ((ef - ef' ). coefficients)< 10E-11
78
+ @test norm (@inferred (ef - ef' ). coefficients)< 10E-11
84
79
85
- @test norm ((ef - cumsum (ef)' ). coefficients) < 20 eps ()
86
- @test norm ((cf - cumsum (cf)' ). coefficients) < 20 eps ()
80
+ @test norm (@inferred (ef - cumsum (ef)' ). coefficients) < 20 eps ()
81
+ @test norm (@inferred (cf - cumsum (cf)' ). coefficients) < 20 eps ()
87
82
88
- @test sum (ef) ≈ 2.3504023872876028
89
- @test norm (ef) ≈ 1.90443178083307
83
+ @test @inferred ( sum (ef) ) ≈ 2.3504023872876028
84
+ @test @inferred ( norm (ef) ) ≈ 1.90443178083307
90
85
end
91
86
92
87
@testset " other domains" begin
0 commit comments