@@ -92,12 +92,13 @@ using OffsetArrays, BenchmarkTools
92
92
@test_throws DimensionMismatch prefvec (Ref {Any} (1 : 5 ))
93
93
end
94
94
95
- @testset " LinearAlgebra: $adj " for adj in [transpose, adjoint]
95
+ @testset " LinearAlgebra: $adj vectors " for adj in [transpose, adjoint]
96
96
# adjoint vectors
97
97
padj = ProjectTo (adj ([1 ,2 ,3 ]))
98
98
adjT = typeof (adj ([1 ,2 ,3.0 ]))
99
99
@test padj (transpose (1 : 3 )) isa adjT
100
100
@test padj ([4 5 6 + 7im ]) isa adjT
101
+ @test_broken padj ([4.0 5.0 6.0 ]) isa adjT
101
102
102
103
@test_throws DimensionMismatch padj ([1 ,2 ,3 ])
103
104
@test_throws DimensionMismatch padj ([1 2 3 ]' )
@@ -109,22 +110,31 @@ using OffsetArrays, BenchmarkTools
109
110
@test padj_complex (adjoint ([4 , 5 , 6 + 7im ])) == [4 5 6 - 7im ]
110
111
111
112
# evil test case
112
- xs = adjoint (Any[Any[1 ,2 ,3 ], Any[4 + im,5 - im,6 + im,7 - im]])
113
+ xs = adj (Any[Any[1 ,2 ,3 ], Any[4 + im,5 - im,6 + im,7 - im]])
113
114
pvecvec3 = ProjectTo (xs)
114
115
@test pvecvec3 (xs)[1 ] == [1 2 3 ]
115
- @test pvecvec3 (xs)[2 ] isa Adjoint{ComplexF64, <: Vector }
116
- @test_broken pvecvec3 (collect (xs))[1 ] == [1 2 3 ]
117
- ys = permutedims ([[1 2 3 + im], [4 5 6 7 ]])
118
- @test_broken pvecvec3 (ys)[1 ] == [1 2 3 ]
116
+ @test pvecvec3 (xs)[2 ] == adj .([4 + im 5 - im 6 + im 7 - im])
117
+ @test pvecvec3 (xs)[2 ] isa LinearAlgebra. AdjOrTransAbsMat{ComplexF64, <: Vector }
118
+ @test pvecvec3 (collect (xs))[1 ] == [1 2 3 ]
119
+ ys = permutedims ([[1 2 3 + im], Any[4 5 6 7 + 8im ]])
120
+ @test pvecvec3 (ys)[1 ] == [1 2 3 ]
121
+ @test pvecvec3 (ys)[2 ] == [4 5 6 7 + 8im ]
122
+ @test pvecvec3 (xs)[2 ] isa LinearAlgebra. AdjOrTransAbsMat{ComplexF64, <: Vector }
123
+ @test pvecvec3 (ys) isa LinearAlgebra. AdjOrTransAbsVec
124
+
125
+ zs = adj ([[1 2 ; 3 4 ], [5 6 ; 7 8 + im]' ])
126
+ pvecmat = ProjectTo (zs)
127
+ @test pvecmat (zs) == zs
128
+ @test pvecmat (collect .(zs)) == zs
129
+ @test pvecmat (collect .(zs)) isa LinearAlgebra. AdjOrTransAbsVec
119
130
end
120
131
121
- @testset " LinearAlgebra: structured matrices" begin
122
- # structured matrices with a full parent
132
+ @testset " LinearAlgebra: dense structured matrices" begin
123
133
psymm = ProjectTo (Symmetric (rand (3 ,3 )))
124
134
@test psymm (reshape (1 : 9 ,3 ,3 )) == [1.0 3.0 5.0 ; 3.0 5.0 7.0 ; 5.0 7.0 9.0 ]
125
135
@test psymm (psymm (reshape (1 : 9 ,3 ,3 ))) == psymm (reshape (1 : 9 ,3 ,3 ))
126
136
@test psymm (rand (ComplexF32, 3 , 3 , 1 )) isa Symmetric{Float64}
127
- @test ProjectTo (Symmetric (randn (3 ,3 ) .> 0 ))(randn (3 ,3 )) == NoTangent ()
137
+ @test ProjectTo (Symmetric (randn (3 ,3 ) .> 0 ))(randn (3 ,3 )) == NoTangent () # Bool
128
138
129
139
pherm = ProjectTo (Hermitian (rand (3 ,3 ) .+ im, :L ))
130
140
# NB, projection onto Hermitian subspace, not application of Hermitian constructor
@@ -138,11 +148,12 @@ using OffsetArrays, BenchmarkTools
138
148
@test pupp (rand (ComplexF32, 3 , 3 , 1 )) isa UpperTriangular{Float64}
139
149
@test ProjectTo (UpperTriangular (randn (3 ,3 ) .> 0 ))(randn (3 ,3 )) == NoTangent ()
140
150
141
- # some subspaces which aren't subtypes
151
+ # an experiment with allowing subspaces which aren't subtypes
142
152
@test psymm (Diagonal ([1 ,2 ,3 ])) isa Diagonal{Float64}
143
153
@test pupp (Diagonal ([1 ,2 ,3 + 4im ])) isa Diagonal{Float64}
154
+ end
144
155
145
- # structured matrices with linear-size backing
156
+ @testset " LinearAlgebra: sparse structured matrices" begin
146
157
pdiag = ProjectTo (Diagonal (1 : 3 ))
147
158
@test pdiag (reshape (1 : 9 ,3 ,3 )) == Diagonal ([1 ,5 ,9 ])
148
159
@test pdiag (pdiag (reshape (1 : 9 ,3 ,3 ))) == pdiag (reshape (1 : 9 ,3 ,3 ))
@@ -174,9 +185,6 @@ using OffsetArrays, BenchmarkTools
174
185
@test ptri (ptri (reshape (1 : 9 ,3 ,3 ))) == ptri (reshape (1 : 9 ,3 ,3 ))
175
186
@test ptri (rand (ComplexF32, 3 , 3 )) isa Tridiagonal{Float64}
176
187
@test_throws DimensionMismatch ptri (rand (ComplexF32, 3 , 2 ))
177
-
178
- # an experiment with allowing subspaces which aren't subtypes
179
- @test psymm (pdiag (rand (ComplexF32, 3 , 3 ))) isa Diagonal{Float64}
180
188
end
181
189
182
190
@testset " SparseArrays" begin
@@ -250,7 +258,7 @@ using OffsetArrays, BenchmarkTools
250
258
@test repr (ProjectTo (1.1 )) == " ProjectTo{Float64}()"
251
259
@test occursin (" ProjectTo{AbstractArray}(element" , repr (ProjectTo ([1 ,2 ,3 ])))
252
260
str = repr (ProjectTo ([1 ,2 ,3 ]' ))
253
- @test eval (Meta. parse (str))(ones (1 ,3 )) isa Adjoint{Float64, Vector{Float64}}
261
+ @test_broken eval (Meta. parse (str))(ones (1 ,3 )) isa Adjoint{Float64, Vector{Float64}}
254
262
end
255
263
256
264
VERSION > v " 1.1" && @testset " allocation tests" begin
0 commit comments