@@ -6,6 +6,9 @@ using LinearAlgebra
6
6
using Static
7
7
8
8
@verbose @testset " Ultraspherical" begin
9
+ @testset " promotion" begin
10
+ @inferred (() -> [Ultraspherical (1 ), Ultraspherical (2.0 )])()
11
+ end
9
12
@testset " identity fun" begin
10
13
for d in (ChebyshevInterval (), 3 .. 4 , Segment (2 , 5 ), Segment (1 , 4im )), order in (1 , 2 , 0.5 )
11
14
s = Ultraspherical (order, d)
@@ -25,27 +28,27 @@ using Static
25
28
26
29
# Conversions from Chebyshev to Ultraspherical should lead to a small union of types
27
30
Tallowed = Union{
28
- ApproxFunBase. ConcreteConversion{
29
- Chebyshev{ChebyshevInterval{Float64}, Float64},
30
- Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}, Float64},
31
- ApproxFunBase. ConversionWrapper{TimesOperator{Float64, Tuple{Int64, Int64}}, Float64}};
31
+ typeof (Conversion (Chebyshev (), Ultraspherical (1 ))),
32
+ typeof (Conversion (Chebyshev (), Ultraspherical (2 )))};
32
33
@inferred Tallowed Conversion (Chebyshev (), Ultraspherical (1 ));
33
34
@inferred Tallowed Conversion (Chebyshev (), Ultraspherical (2 ));
35
+ @inferred Conversion (Chebyshev (), Ultraspherical (static (2 )));
36
+ @inferred Conversion (Chebyshev (), Ultraspherical (static (0.5 )));
37
+ @inferred (() -> Conversion (Chebyshev (), Ultraspherical (2 )))();
38
+ @inferred (() -> Conversion (Chebyshev (), Ultraspherical (0.5 )))();
39
+ @inferred (() -> Conversion (Chebyshev (), Ultraspherical (2.5 )))();
40
+
34
41
# Conversions between Ultraspherical should lead to a small union of types
35
42
Tallowed = Union{
36
- ApproxFunBase. ConcreteConversion{
37
- Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64},
38
- Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}, Float64},
39
- ApproxFunBase. ConversionWrapper{
40
- ConstantOperator{Float64,
41
- Ultraspherical{Int64, ChebyshevInterval{Float64}, Float64}}, Float64},
42
- ApproxFunBase. ConversionWrapper{TimesOperator{Float64, Tuple{Int64, Int64}}, Float64}};
43
+ typeof (Conversion (Ultraspherical (1 ), Ultraspherical (2 ))),
44
+ typeof (Conversion (Ultraspherical (1 ), Ultraspherical (3 )))}
43
45
@inferred Tallowed Conversion (Ultraspherical (1 ), Ultraspherical (2 ));
46
+ @inferred Tallowed Conversion (Ultraspherical (1 ), Ultraspherical (3 ));
44
47
45
48
@inferred Conversion (Ultraspherical (static (1 )), Ultraspherical (static (4 )))
46
- # these cases should be handled by constant-propagation
47
- @inferred (() -> Conversion (Ultraspherical (static ( 1 )) , Ultraspherical (4 )))()
48
- @inferred (() -> Conversion (Ultraspherical (1 ), Ultraspherical (static ( 4 ))))()
49
+ @inferred (() -> Conversion ( Ultraspherical ( 1 ), Ultraspherical ( 4 )))()
50
+ @inferred (() -> Conversion (Ultraspherical (1.0 ) , Ultraspherical (4.0 )))();
51
+ @inferred (() -> Conversion (Ultraspherical (1.0 ), Ultraspherical (3.5 )))();
49
52
50
53
for n in (2 ,5 )
51
54
C1 = Conversion (Chebyshev (), Ultraspherical (n))
@@ -62,19 +65,24 @@ using Static
62
65
g = CLC * f
63
66
@test g ≈ Fun (x-> x^ 2 , Chebyshev ())
64
67
65
- f = Fun (x-> x^ 2 , Chebyshev ()) # Legendre
66
- CCL = Conversion (Chebyshev (), Ultraspherical (0.5 ))
67
- @test ! isdiag (CCL)
68
- g = CCL * f
69
- @test g ≈ Fun (x-> x^ 2 , Ultraspherical (0.5 ))
70
-
71
- f = Fun (x-> x^ 2 , Ultraspherical (0.5 )) # Legendre
72
- for n in (2.5 , 3 )
73
- CLU = Conversion (Ultraspherical (0.5 ), Ultraspherical (n))
74
- @test ! isdiag (CLU)
75
- g = CLU * f
68
+ for n in (0.5 , 1 , 1.5 , 2 )
69
+ f = Fun (x-> x^ 2 , Chebyshev ())
70
+ CCL = Conversion (Chebyshev (), Ultraspherical (n))
71
+ @test ! isdiag (CCL)
72
+ g = CCL * f
76
73
@test g ≈ Fun (x-> x^ 2 , Ultraspherical (n))
77
74
end
75
+
76
+ ff = x-> x^ 2 + 2 x^ 3 + 3 x^ 4
77
+ for n1 in (0.5 , 1 )
78
+ f = Fun (ff, Ultraspherical (n1))
79
+ for n2 in (2.5 , 3 )
80
+ CLU = Conversion (Ultraspherical (n1), Ultraspherical (n2))
81
+ @test ! isdiag (CLU)
82
+ g = CLU * f
83
+ @test g ≈ Fun (ff, Ultraspherical (n1))
84
+ end
85
+ end
78
86
end
79
87
80
88
@testset " Normalized space" begin
@@ -110,12 +118,12 @@ using Static
110
118
@test transform (S, v) ≈ transform (J, v)
111
119
end
112
120
@testset for T in (Float32, Float64), ET in (T, complex (T))
113
- v = Array {ET} (undef, 10 )
114
- v2 = similar (v)
115
- M = Array {ET} (undef, 10 , 10 )
116
- M2 = similar (M)
117
- A = Array {ET} (undef, 10 , 10 , 10 )
118
- A2 = similar (A)
121
+ v = Array {ET} (undef, 10 );
122
+ v2 = similar (v);
123
+ M = Array {ET} (undef, 10 , 10 );
124
+ M2 = similar (M);
125
+ A = Array {ET} (undef, 10 , 10 , 10 );
126
+ A2 = similar (A);
119
127
@testset for d in ((), (0 .. 1 ,)), order in (0.5 , 0.7 , 1.5 , 1 , 3 )
120
128
U = Ultraspherical (order, d... )
121
129
NU = NormalizedPolynomialSpace (U)
0 commit comments