1
1
@testset " norm functions" begin
2
+
3
+ # First test the un-exported functions which norm(A,p) calls
4
+ # ==========================================================
5
+
2
6
@testset " $fnorm (x::Array{$T ,$(length (sz)) })" for
3
7
fnorm in (
4
8
LinearAlgebra. norm1,
@@ -61,6 +65,10 @@ println("... integer")
61
65
@test unthunk (int_back (1.0 )[2 ]) ≈ unthunk (float_back (1.0 )[2 ])
62
66
end
63
67
end
68
+
69
+ # Next test norm(x, p=2) -- two methods
70
+ # =====================================
71
+
64
72
@testset " norm(x::Array{$T ,$(length (sz)) })" for
65
73
T in (Float64, ComplexF64),
66
74
sz in [(0 ,), (3 ,), (3 , 3 ), (3 , 2 , 1 )]
@@ -142,7 +150,8 @@ println("starting p-norm p=$p, T=$T, sz=$sz")
142
150
@test unthunk (int_back (1.0 )[2 ]) ≈ unthunk (float_back (1.0 )[2 ])
143
151
end
144
152
end
145
- @testset " norm($fdual (::Vector{$T }), p)" for
153
+ # Extra test for norm(adjoint vector, p)
154
+ @testset " norm($fdual (::Vector{$T }), 2.5)" for
146
155
T in (Float64, ComplexF64),
147
156
fdual in (adjoint, transpose)
148
157
println (" starting $fdual norm T=$T " )
@@ -154,6 +163,10 @@ println("starting $fdual norm T=$T")
154
163
ȳ = rand_tangent (norm (x, p))
155
164
@test extern (rrule (norm, x, p)[2 ](ȳ)[2 ]) isa typeof (x)
156
165
end
166
+
167
+ # Scalar norm(x, p)
168
+ # =================
169
+
157
170
@testset " norm(x::$T , p)" for T in (Float64, ComplexF64)
158
171
@testset " p = $p " for p in (- 1.0 , 2.0 , 2.5 )
159
172
println (" starting scalar p-norm tests, p=$p , T=$T " )
@@ -181,6 +194,9 @@ println("starting 0-norm tests, T=$T")
181
194
end
182
195
end
183
196
197
+ # normalise(x, p) and normalise(A, p)
198
+ # ===================================
199
+
184
200
@testset " normalize" begin
185
201
@testset " x::Vector{$T }" for T in (Float64, ComplexF64)
186
202
x = randn (T, 3 )
0 commit comments