@@ -146,20 +146,23 @@ test_params = Iterators.product(blockszs, eltypes)
146
146
@test test_svd (a, usv_empty)
147
147
148
148
# test blockdiagonal
149
+ rng = StableRNG (123 )
149
150
for i in LinearAlgebra. diagind (blocks (a))
150
151
I = CartesianIndices (blocks (a))[i]
151
- a[Block (I. I... )] = rand (T, size (blocks (a)[i]))
152
+ a[Block (I. I... )] = rand (rng, T, size (blocks (a)[i]))
152
153
end
153
154
usv = svd_compact (a)
154
155
@test test_svd (a, usv)
155
156
156
- perm = Random. randperm (length (m))
157
+ rng = StableRNG (123 )
158
+ perm = Random. randperm (rng, length (m))
157
159
b = a[Block .(perm), Block .(1 : length (n))]
158
160
usv = svd_compact (b)
159
161
@test test_svd (b, usv)
160
162
161
163
# test permuted blockdiagonal with missing row/col
162
- I_removed = rand (eachblockstoredindex (b))
164
+ rng = StableRNG (123 )
165
+ I_removed = rand (rng, eachblockstoredindex (b))
163
166
c = copy (b)
164
167
delete! (blocks (c). storage, CartesianIndex (Int .(Tuple (I_removed))))
165
168
usv = svd_compact (c)
@@ -176,20 +179,23 @@ end
176
179
@test test_svd (a, usv_empty; full= true )
177
180
178
181
# test blockdiagonal
182
+ rng = StableRNG (123 )
179
183
for i in LinearAlgebra. diagind (blocks (a))
180
184
I = CartesianIndices (blocks (a))[i]
181
- a[Block (I. I... )] = rand (T, size (blocks (a)[i]))
185
+ a[Block (I. I... )] = rand (rng, T, size (blocks (a)[i]))
182
186
end
183
187
usv = svd_full (a)
184
188
@test test_svd (a, usv; full= true )
185
189
186
- perm = Random. randperm (length (m))
190
+ rng = StableRNG (123 )
191
+ perm = Random. randperm (rng, length (m))
187
192
b = a[Block .(perm), Block .(1 : length (n))]
188
193
usv = svd_full (b)
189
194
@test test_svd (b, usv; full= true )
190
195
191
196
# test permuted blockdiagonal with missing row/col
192
- I_removed = rand (eachblockstoredindex (b))
197
+ rng = StableRNG (123 )
198
+ I_removed = rand (rng, eachblockstoredindex (b))
193
199
c = copy (b)
194
200
delete! (blocks (c). storage, CartesianIndex (Int .(Tuple (I_removed))))
195
201
usv = svd_full (c)
203
209
a = BlockSparseArray {T} (undef, m, n)
204
210
205
211
# test blockdiagonal
212
+ rng = StableRNG (123 )
206
213
for i in LinearAlgebra. diagind (blocks (a))
207
214
I = CartesianIndices (blocks (a))[i]
208
- a[Block (I. I... )] = rand (T, size (blocks (a)[i]))
215
+ a[Block (I. I... )] = rand (rng, T, size (blocks (a)[i]))
209
216
end
210
217
211
218
minmn = min (size (a)... )
236
243
@test (V1ᴴ * V1ᴴ' ≈ LinearAlgebra. I)
237
244
238
245
# test permuted blockdiagonal
239
- perm = Random. randperm (length (m))
246
+ rng = StableRNG (123 )
247
+ perm = Random. randperm (rng, length (m))
240
248
b = a[Block .(perm), Block .(1 : length (n))]
241
249
for trunc in (truncrank (r), trunctol (atol))
242
250
U1, S1, V1ᴴ = svd_trunc (b; trunc)
270
278
@testset " qr_compact (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
271
279
for i in [2 , 3 ], j in [2 , 3 ], k in [2 , 3 ], l in [2 , 3 ]
272
280
A = BlockSparseArray {T} (undef, ([i, j], [k, l]))
273
- A[Block (1 , 1 )] = randn (T, i, k)
274
- A[Block (2 , 2 )] = randn (T, j, l)
281
+ rng = StableRNG (123 )
282
+ A[Block (1 , 1 )] = randn (rng, T, i, k)
283
+ A[Block (2 , 2 )] = randn (rng, T, j, l)
275
284
Q, R = qr_compact (A)
276
285
@test Matrix (Q' Q) ≈ LinearAlgebra. I
277
286
@test A ≈ Q * R
281
290
@testset " qr_full (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
282
291
for i in [2 , 3 ], j in [2 , 3 ], k in [2 , 3 ], l in [2 , 3 ]
283
292
A = BlockSparseArray {T} (undef, ([i, j], [k, l]))
284
- A[Block (1 , 1 )] = randn (T, i, k)
285
- A[Block (2 , 2 )] = randn (T, j, l)
293
+ rng = StableRNG (123 )
294
+ A[Block (1 , 1 )] = randn (rng, T, i, k)
295
+ A[Block (2 , 2 )] = randn (rng, T, j, l)
286
296
Q, R = qr_full (A)
287
297
Q′, R′ = qr_full (Matrix (A))
288
298
@test size (Q) == size (Q′)
296
306
@testset " lq_compact" for T in (Float32, Float64, ComplexF32, ComplexF64)
297
307
for i in [2 , 3 ], j in [2 , 3 ], k in [2 , 3 ], l in [2 , 3 ]
298
308
A = BlockSparseArray {T} (undef, ([i, j], [k, l]))
299
- A[Block (1 , 1 )] = randn (T, i, k)
300
- A[Block (2 , 2 )] = randn (T, j, l)
309
+ rng = StableRNG (123 )
310
+ A[Block (1 , 1 )] = randn (rng, T, i, k)
311
+ A[Block (2 , 2 )] = randn (rng, T, j, l)
301
312
L, Q = lq_compact (A)
302
313
@test Matrix (Q * Q' ) ≈ LinearAlgebra. I
303
314
@test A ≈ L * Q
307
318
@testset " lq_full" for T in (Float32, Float64, ComplexF32, ComplexF64)
308
319
for i in [2 , 3 ], j in [2 , 3 ], k in [2 , 3 ], l in [2 , 3 ]
309
320
A = BlockSparseArray {T} (undef, ([i, j], [k, l]))
310
- A[Block (1 , 1 )] = randn (T, i, k)
311
- A[Block (2 , 2 )] = randn (T, j, l)
321
+ rng = StableRNG (123 )
322
+ A[Block (1 , 1 )] = randn (rng, T, i, k)
323
+ A[Block (2 , 2 )] = randn (rng, T, j, l)
312
324
L, Q = lq_full (A)
313
325
L′, Q′ = lq_full (Matrix (A))
314
326
@test size (L) == size (L′)
321
333
322
334
@testset " left_polar (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
323
335
A = BlockSparseArray {T} (undef, ([3 , 4 ], [2 , 3 ]))
324
- A[Block (1 , 1 )] = randn (T, 3 , 2 )
325
- A[Block (2 , 2 )] = randn (T, 4 , 3 )
336
+ rng = StableRNG (123 )
337
+ A[Block (1 , 1 )] = randn (rng, T, 3 , 2 )
338
+ A[Block (2 , 2 )] = randn (rng, T, 4 , 3 )
326
339
327
340
U, C = left_polar (A)
328
341
@test U * C ≈ A
331
344
332
345
@testset " right_polar (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
333
346
A = BlockSparseArray {T} (undef, ([2 , 3 ], [3 , 4 ]))
334
- A[Block (1 , 1 )] = randn (T, 2 , 3 )
335
- A[Block (2 , 2 )] = randn (T, 3 , 4 )
347
+ rng = StableRNG (123 )
348
+ A[Block (1 , 1 )] = randn (rng, T, 2 , 3 )
349
+ A[Block (2 , 2 )] = randn (rng, T, 3 , 4 )
336
350
337
351
C, U = right_polar (A)
338
352
@test C * U ≈ A
341
355
342
356
@testset " left_orth (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
343
357
A = BlockSparseArray {T} (undef, ([3 , 4 ], [2 , 3 ]))
344
- A[Block (1 , 1 )] = randn (T, 3 , 2 )
345
- A[Block (2 , 2 )] = randn (T, 4 , 3 )
358
+ rng = StableRNG (123 )
359
+ A[Block (1 , 1 )] = randn (rng, T, 3 , 2 )
360
+ A[Block (2 , 2 )] = randn (rng, T, 4 , 3 )
346
361
347
362
for kind in (:polar , :qr , :svd )
348
363
U, C = left_orth (A; kind)
358
373
359
374
@testset " right_orth (T=$T )" for T in (Float32, Float64, ComplexF32, ComplexF64)
360
375
A = BlockSparseArray {T} (undef, ([2 , 3 ], [3 , 4 ]))
361
- A[Block (1 , 1 )] = randn (T, 2 , 3 )
362
- A[Block (2 , 2 )] = randn (T, 3 , 4 )
376
+ rng = StableRNG (123 )
377
+ A[Block (1 , 1 )] = randn (rng, T, 2 , 3 )
378
+ A[Block (2 , 2 )] = randn (rng, T, 3 , 4 )
363
379
364
380
for kind in (:lq , :polar , :svd )
365
381
C, U = right_orth (A; kind)
0 commit comments