@@ -11,8 +11,8 @@ V = rand(ComplexF64, 10, 3)
1111W = rand (ComplexF64, 20 , 3 )
1212α = rand ()
1313β = rand ()
14- M = LinearMap (A)
15- N = LinearMap (M)
14+ M = @inferred LinearMap (A)
15+ N = @inferred LinearMap (M)
1616
1717@testset " LinearMaps.jl" begin
1818 @test eltype (M) == eltype (A)
7474 @test @inferred LinearMap (M' )' * v == A * v
7575 @test @inferred transpose (transpose (M)) == M
7676 @test (M' )' == M
77- Mherm = LinearMap (A' A)
77+ Mherm = @inferred LinearMap (A' A)
7878 @test @inferred ishermitian (Mherm)
7979 @test @inferred ! issymmetric (Mherm)
8080 @test @inferred ! issymmetric (transpose (Mherm))
9898 @test @inferred mul! (copy (V), transpose (M), W) ≈ transpose (A) * W
9999 @test @inferred mul! (copy (V), adjoint (M), W) ≈ A' * W
100100
101- B = LinearMap (Symmetric (rand (10 , 10 )))
101+ B = @inferred LinearMap (Symmetric (rand (10 , 10 )))
102102 @test transpose (B) == B
103103 @test B == transpose (B)
104104
105- B = LinearMap (Hermitian (rand (ComplexF64, 10 , 10 )))
105+ B = @inferred LinearMap (Hermitian (rand (ComplexF64, 10 , 10 )))
106106 @test adjoint (B) == B
107107 @test B == B'
108108end
@@ -121,40 +121,40 @@ end
121121 end
122122 return w
123123 end
124- MyFT = LinearMap {ComplexF64} (myft, N) / sqrt (N)
124+ MyFT = @inferred LinearMap {ComplexF64} (myft, N) / sqrt (N)
125125 U = Matrix (MyFT) # will be a unitary matrix
126126 @test @inferred U' U ≈ Matrix {eltype(U)} (I, N, N)
127127
128- CS = LinearMap (cumsum, 2 )
128+ CS = @inferred LinearMap (cumsum, 2 )
129129 @test size (CS) == (2 , 2 )
130130 @test @inferred ! issymmetric (CS)
131131 @test @inferred ! ishermitian (CS)
132132 @test @inferred ! isposdef (CS)
133133 @test @inferred ! (LinearMaps. ismutating (CS))
134134 @test @inferred Matrix (CS) == [1. 0. ; 1. 1. ]
135135 @test @inferred Array (CS) == [1. 0. ; 1. 1. ]
136- CS = LinearMap (cumsum, 10 ; ismutating= false )
136+ CS = @inferred LinearMap (cumsum, 10 ; ismutating= false )
137137 v = rand (10 )
138138 cv = cumsum (v)
139139 @test CS * v == cv
140140 @test * (CS, v) == cv
141141 @test_throws ErrorException CS' * v
142- CS = LinearMap (cumsum, x -> cumsum (reverse (x)), 10 ; ismutating= false )
142+ CS = @inferred LinearMap (cumsum, x -> cumsum (reverse (x)), 10 ; ismutating= false )
143143 cv = cumsum (v)
144144 @test @inferred CS * v == cv
145145 @test @inferred * (CS, v) == cv
146146 @test @inferred CS' * v == cumsum (reverse (v))
147147 @test @inferred mul! (similar (v), transpose (CS), v) == cumsum (reverse (v))
148148
149- CS! = LinearMap (cumsum!, 10 ; ismutating= true )
149+ CS! = @inferred LinearMap (cumsum!, 10 ; ismutating= true )
150150 @test @inferred LinearMaps. ismutating (CS!)
151151 @test @inferred CS! * v == cv
152152 @test @inferred * (CS!, v) == cv
153153 @test @inferred mul! (similar (v), CS!, v) == cv
154154 @test_throws ErrorException CS!' v
155155 @test_throws ErrorException transpose (CS!) * v
156156
157- CS! = LinearMap {ComplexF64} (cumsum!, 10 ; ismutating= true )
157+ CS! = @inferred LinearMap {ComplexF64} (cumsum!, 10 ; ismutating= true )
158158 v = rand (ComplexF64, 10 )
159159 cv = cumsum (v)
160160 @test @inferred LinearMaps. ismutating (CS!)
@@ -173,17 +173,17 @@ end
173173 @test @inferred mul! (similar (v), adjoint (CS), v) == cumsum (reverse (v))
174174
175175 # Test fallback methods:
176- L = LinearMap (x -> x, x -> x, 10 )
176+ L = @inferred LinearMap (x -> x, x -> x, 10 )
177177 v = randn (10 )
178178 @test @inferred (2 * L)' * v ≈ 2 * v
179179 @test @inferred transpose (2 * L) * v ≈ 2 * v
180- L = LinearMap {ComplexF64} (x -> x, x -> x, 10 )
180+ L = @inferred LinearMap {ComplexF64} (x -> x, x -> x, 10 )
181181 v = rand (ComplexF64, 10 )
182182 @test @inferred (2 * L)' * v ≈ 2 * v
183183 @test @inferred transpose (2 * L) * v ≈ 2 * v
184184end
185185
186- CS! = LinearMap (cumsum!, 10 ; ismutating= true )
186+ CS! = @inferred LinearMap (cumsum!, 10 ; ismutating= true )
187187v = rand (10 )
188188u = similar (v)
189189b = @benchmarkable mul! (u, CS!, v)
@@ -196,9 +196,9 @@ b = @benchmarkable mul!(u, L, v)
196196
197197A = 2 * rand (ComplexF64, (10 , 10 )) .- 1
198198B = rand (size (A)... )
199- M = LinearMap (A)
200- N = LinearMap (B)
201- LC = M + N
199+ M = @inferred LinearMap (A)
200+ N = @inferred LinearMap (B)
201+ LC = @inferred M + N
202202v = rand (ComplexF64, 10 )
203203w = similar (v)
204204b = @benchmarkable mul! (w, M, v)
@@ -251,11 +251,11 @@ Base.:(*)(A::Union{SimpleFunctionMap,SimpleComplexFunctionMap}, v::Vector) = A.f
251251mul! (y:: Vector , A:: Union{SimpleFunctionMap,SimpleComplexFunctionMap} , x:: Vector ) = copyto! (y, * (A, x))
252252
253253@testset " composition" begin
254- F = LinearMap (cumsum, 10 ; ismutating= false )
254+ F = @inferred LinearMap (cumsum, 10 ; ismutating= false )
255255 A = 2 * rand (ComplexF64, (10 , 10 )) .- 1
256256 B = rand (size (A)... )
257- M = 1 * LinearMap (A)
258- N = LinearMap (B)
257+ M = @inferred 1 * LinearMap (A)
258+ N = @inferred LinearMap (B)
259259 @test @inferred (F * F) * v == @inferred F * (F * v)
260260 @test @inferred (F * A) * v == @inferred F * (A * v)
261261 @test @inferred (A * F) * v == @inferred A * (F * v)
@@ -276,20 +276,21 @@ mul!(y::Vector, A::Union{SimpleFunctionMap,SimpleComplexFunctionMap}, x::Vector)
276276 @test @inferred transpose (M * F) == @inferred transpose (F) * transpose (M)
277277 @test @inferred (4 * ((- 3 * M)* 2 )) == @inferred - 12 M* 2
278278 @test @inferred (4 * ((3 * (- M))* 2 )* (- 5 )) == @inferred - 12 M* (- 10 )
279- L = 3 * F + 1im * A + F * M' * F
279+ L = @inferred 3 * F + 1im * A + F * M' * F
280280 LF = 3 * Matrix (F) + 1im * A + Matrix (F) * Matrix (M)' * Matrix (F)
281281 @test Array (L) ≈ LF
282282 R1 = rand (ComplexF64, 10 , 10 ); L1 = LinearMap (R1)
283283 R2 = rand (ComplexF64, 10 , 10 ); L2 = LinearMap (R2)
284284 R3 = rand (ComplexF64, 10 , 10 ); L3 = LinearMap (R3)
285285 CompositeR = prod (R -> LinearMap (R), [R1, R2, R3])
286- @test transpose (CompositeR) == transpose (L3) * transpose (L2) * transpose (L1)
287- @test adjoint (CompositeR) == L3' * L2' * L1'
288- @test adjoint (adjoint ((CompositeR))) == CompositeR
286+ @test @inferred L1 * L2 * L3 == CompositeR
287+ @test @inferred transpose (CompositeR) == transpose (L3) * transpose (L2) * transpose (L1)
288+ @test @inferred adjoint (CompositeR) == L3' * L2' * L1'
289+ @test @inferred adjoint (adjoint ((CompositeR))) == CompositeR
289290 @test transpose (transpose ((CompositeR))) == CompositeR
290- Lt = transpose (LinearMap (CompositeR))
291+ Lt = @inferred transpose (LinearMap (CompositeR))
291292 @test Lt * v ≈ transpose (R3) * transpose (R2) * transpose (R1) * v
292- Lc = adjoint (LinearMap (CompositeR))
293+ Lc = @inferred adjoint (LinearMap (CompositeR))
293294 @test Lc * v ≈ R3' * R2' * R1' * v
294295
295296 # test inplace operations
@@ -360,9 +361,9 @@ A = rand(10, 20)
360361B = rand (ComplexF64, 10 , 20 )
361362SA = A' A + I
362363SB = B' B + I
363- L = LinearMap {Float64} (A)
364- MA = LinearMap (SA)
365- MB = LinearMap (SB)
364+ L = @inferred LinearMap {Float64} (A)
365+ MA = @inferred LinearMap (SA)
366+ MB = @inferred LinearMap (SB)
366367@testset " wrapped maps" begin
367368 @test size (L) == size (A)
368369 @test @inferred ! issymmetric (L)
@@ -375,12 +376,12 @@ end
375376A = 2 * rand (ComplexF64, (10 , 10 )) .- 1
376377B = rand (size (A)... )
377378M = @inferred 1 * LinearMap (A)
378- N = LinearMap (B)
379- LC = M + N
379+ N = @inferred LinearMap (B)
380+ LC = @inferred M + N
380381v = rand (ComplexF64, 10 )
381382w = similar (v)
382383@testset " identity/scaling map" begin
383- Id = LinearMaps. UniformScalingMap (1 , 10 )
384+ Id = @inferred LinearMaps. UniformScalingMap (1 , 10 )
384385 @test_throws ErrorException LinearMaps. UniformScalingMap (1 , 10 , 20 )
385386 @test_throws ErrorException LinearMaps. UniformScalingMap (1 , (10 , 20 ))
386387 @test size (Id) == (10 , 10 )
@@ -538,16 +539,16 @@ end
538539 @test size (L) == size (A)
539540 @test L * x ≈ A * x
540541 @test Matrix (L) ≈ A
541- Lt = transform (L)
542+ Lt = @inferred transform (L)
542543 @test Lt isa LinearMaps. LinearMap{elty}
543544 @test Lt * x ≈ transform (A) * x
544- Lt = transform (LinearMap (L))
545+ Lt = @inferred transform (LinearMap (L))
545546 @test Lt * x ≈ transform (A) * x
546547 @test Matrix (Lt) ≈ Matrix (transform (A))
547548 A21 = rand (elty, 10 , 10 )
548549 A = [I A12; A21 I]
549550 L = [I LinearMap (A12); LinearMap (A21) I]
550- Lt = transform (L)
551+ Lt = @inferred transform (L)
551552 @test Lt isa LinearMaps. LinearMap{elty}
552553 @test Lt * x ≈ transform (A) * x
553554 @test Matrix (Lt) ≈ Matrix (transform (A))
0 commit comments