@@ -262,19 +262,27 @@ end
262
262
# Test concatenating pairwise combinations of special matrices with sparse matrices,
263
263
# dense matrices, or dense vectors
264
264
spmat = spdiagm (0 => fill (1. , N))
265
+ dmat = Array (spmat)
265
266
spvec = sparse (fill (1. , N))
267
+ dvec = Array (spvec)
266
268
for specialmat in specialmats
267
269
# --> Tests applicable only to pairs of matrices
268
270
@test issparse (vcat (specialmat, spmat))
269
271
@test issparse (vcat (spmat, specialmat))
272
+ @test sparse_vcat (specialmat, dmat):: SparseMatrixCSC == vcat (specialmat, spmat)
273
+ @test sparse_vcat (dmat, specialmat):: SparseMatrixCSC == vcat (spmat, specialmat)
270
274
# --> Tests applicable also to pairs including vectors
271
- for specialmat in specialmats, othermatorvec in (spmat, spvec)
272
- @test issparse (hcat (specialmat, othermatorvec))
273
- @test issparse (hcat (othermatorvec, specialmat))
274
- @test issparse (hvcat ((2 ,), specialmat, othermatorvec))
275
- @test issparse (hvcat ((2 ,), othermatorvec, specialmat))
276
- @test issparse (cat (specialmat, othermatorvec; dims= (1 ,2 )))
277
- @test issparse (cat (othermatorvec, specialmat; dims= (1 ,2 )))
275
+ for specialmat in specialmats, (smatorvec, dmatorvec) in ((spmat, dmat), (spvec, dvec))
276
+ @test issparse (hcat (specialmat, smatorvec))
277
+ @test sparse_hcat (specialmat, dmatorvec):: SparseMatrixCSC == hcat (specialmat, smatorvec)
278
+ @test issparse (hcat (smatorvec, specialmat))
279
+ @test sparse_hcat (dmatorvec, specialmat):: SparseMatrixCSC == hcat (smatorvec, specialmat)
280
+ @test issparse (hvcat ((2 ,), specialmat, smatorvec))
281
+ @test sparse_hvcat ((2 ,), specialmat, dmatorvec):: SparseMatrixCSC == hvcat ((2 ,), specialmat, smatorvec)
282
+ @test issparse (hvcat ((2 ,), smatorvec, specialmat))
283
+ @test sparse_hvcat ((2 ,), dmatorvec, specialmat):: SparseMatrixCSC == hvcat ((2 ,), smatorvec, specialmat)
284
+ @test issparse (cat (specialmat, smatorvec; dims= (1 ,2 )))
285
+ @test issparse (cat (smatorvec, specialmat; dims= (1 ,2 )))
278
286
end
279
287
end
280
288
end
300
308
symtridiagmat = SymTridiagonal (1 : N, 1 : (N- 1 ))
301
309
sparseconcatmats = testfull ? (spmat, diagmat, bidiagmat, tridiagmat, symtridiagmat) : (spmat, diagmat)
302
310
# Concatenations involving strictly these types, un/annotated, should yield dense arrays
303
- densevec = fill ( 1. , N )
304
- densemat = fill ( 1. , N, N )
311
+ densevec = Array (spvec )
312
+ densemat = Array (spmat )
305
313
# Annotated collections
306
314
annodmats = [annot (densemat) for annot in annotations]
307
315
annospcmats = [annot (spmat) for annot in annotations]
321
329
@test issparse (vcat (annospcmat, othermat))
322
330
@test issparse (vcat (othermat, annospcmat))
323
331
end
332
+ for (smat, dmat) in zip (annospcmats, annodmats), specialmat in sparseconcatmats
333
+ @test sparse_hcat (dmat, specialmat):: SparseMatrixCSC == hcat (smat, specialmat)
334
+ @test sparse_hcat (specialmat, dmat):: SparseMatrixCSC == hcat (specialmat, smat)
335
+ @test sparse_vcat (dmat, specialmat):: SparseMatrixCSC == vcat (smat, specialmat)
336
+ @test sparse_vcat (specialmat, dmat):: SparseMatrixCSC == vcat (specialmat, smat)
337
+ @test sparse_hvcat ((2 ,), dmat, specialmat):: SparseMatrixCSC == hvcat ((2 ,), smat, specialmat)
338
+ @test sparse_hvcat ((2 ,), specialmat, dmat):: SparseMatrixCSC == hvcat ((2 ,), specialmat, smat)
339
+ end
324
340
# --> Tests applicable to pairs including other vectors or matrices
325
341
for other in (spvec, densevec, densemat, annodmats... , sparseconcatmats... )
326
342
@test issparse (hcat (annospcmat, other))
@@ -357,30 +373,30 @@ end
357
373
E = SparseMatrixCSC (rand (1 ,3 ))
358
374
F = SparseMatrixCSC (rand (3 ,1 ))
359
375
α = rand ()
360
- @test (hcat (A, 2 I)) :: SparseMatrixCSC == hcat (A, Matrix (2 I, 3 , 3 ))
376
+ @test (hcat (A, 2 I, I ( 3 ))) :: SparseMatrixCSC == hcat (A, Matrix (2 I, 3 , 3 ), Matrix (I , 3 , 3 ))
361
377
@test (hcat (E, α)):: SparseMatrixCSC == hcat (E, [α])
362
378
@test (hcat (E, α, 2 I)):: SparseMatrixCSC == hcat (E, [α], fill (2 , 1 , 1 ))
363
- @test (vcat (A, 2 I)):: SparseMatrixCSC == vcat (A, Matrix (2 I, 4 , 4 ))
379
+ @test (vcat (A, 2 I)):: SparseMatrixCSC == ( vcat (A, 2 I ( 4 ))) :: SparseMatrixCSC == vcat (A, Matrix (2 I, 4 , 4 ))
364
380
@test (vcat (F, α)):: SparseMatrixCSC == vcat (F, [α])
365
- @test (vcat (F, α, 2 I)):: SparseMatrixCSC == vcat (F, [α], fill (2 , 1 , 1 ))
381
+ @test (vcat (F, α, 2 I)):: SparseMatrixCSC == ( vcat (F, α, 2 I ( 1 ))) :: SparseMatrixCSC == vcat (F, [α], fill (2 , 1 , 1 ))
366
382
@test (hcat (C, 2 I)):: SparseMatrixCSC == C
367
383
@test_throws DimensionMismatch hcat (C, α)
368
384
@test (vcat (D, 2 I)):: SparseMatrixCSC == D
369
385
@test_throws DimensionMismatch vcat (D, α)
370
386
@test (hcat (I, 3 I, A, 2 I)):: SparseMatrixCSC == hcat (Matrix (I, 3 , 3 ), Matrix (3 I, 3 , 3 ), A, Matrix (2 I, 3 , 3 ))
371
387
@test (vcat (I, 3 I, A, 2 I)):: SparseMatrixCSC == vcat (Matrix (I, 4 , 4 ), Matrix (3 I, 4 , 4 ), A, Matrix (2 I, 4 , 4 ))
372
- @test (hvcat ((2 ,1 ,2 ), B, 2 I, I, 3 I, 4 I)):: SparseMatrixCSC ==
388
+ @test (hvcat ((2 ,1 ,2 ), B, 2 I, I ( 6 ) , 3 I, 4 I)):: SparseMatrixCSC ==
373
389
hvcat ((2 ,1 ,2 ), B, Matrix (2 I, 3 , 3 ), Matrix (I, 6 , 6 ), Matrix (3 I, 3 , 3 ), Matrix (4 I, 3 , 3 ))
374
- @test hvcat ((3 ,1 ), C, C, I, 3 I):: SparseMatrixCSC == hvcat ((2 ,1 ), C, C, Matrix (3 I, 6 ,6 ))
390
+ @test hvcat ((3 ,1 ), C, C, I, 3 I):: SparseMatrixCSC == hvcat ((2 ,1 ), C, C, Matrix (3 I, 6 , 6 ))
375
391
@test hvcat ((2 ,2 ,2 ), I, 2 I, 3 I, 4 I, C, C):: SparseMatrixCSC ==
376
- hvcat ((2 ,2 ,2 ), Matrix (I, 3 , 3 ), Matrix (2 I, 3 ,3 ), Matrix (3 I, 3 ,3 ), Matrix (4 I, 3 ,3 ), C, C)
377
- @test hvcat ((2 ,2 ,4 ), C, C, I, 2 I, 3 I, 4 I, 5 I, D):: SparseMatrixCSC ==
378
- hvcat ((2 ,2 ,4 ), C, C, Matrix (I, 3 , 3 ), Matrix (2 I,3 , 3 ),
379
- Matrix (3 I, 2 , 2 ), Matrix (4 I, 2 , 2 ), Matrix (5 I,2 , 2 ), D)
380
- @test (hvcat ((2 ,3 ,2 ), B, 2 I, C, C, I, 3 I, 4 I)):: SparseMatrixCSC ==
392
+ hvcat ((2 ,2 ,2 ), Matrix (I, 3 , 3 ), Matrix (2 I, 3 , 3 ), Matrix (3 I, 3 , 3 ), Matrix (4 I, 3 , 3 ), C, C)
393
+ @test hvcat ((2 ,2 ,4 ), C, C, I ( 3 ) , 2 I, 3 I, 4 I, 5 I, D):: SparseMatrixCSC ==
394
+ hvcat ((2 ,2 ,4 ), C, C, Matrix (I, 3 , 3 ), Matrix (2 I, 3 , 3 ),
395
+ Matrix (3 I, 2 , 2 ), Matrix (4 I, 2 , 2 ), Matrix (5 I, 2 , 2 ), D)
396
+ @test (hvcat ((2 ,3 ,2 ), B, 2 I ( 3 ) , C, C, I, 3 I, 4 I)):: SparseMatrixCSC ==
381
397
hvcat ((2 ,2 ,2 ), B, Matrix (2 I, 3 , 3 ), C, C, Matrix (3 I, 3 , 3 ), Matrix (4 I, 3 , 3 ))
382
- @test hvcat ((3 ,2 ,1 ), C, C, I, B , 3 I , 2 I):: SparseMatrixCSC ==
383
- hvcat ((2 ,2 ,1 ), C, C, B, Matrix (3 I,3 , 3 ), Matrix (2 I,6 , 6 ))
398
+ @test hvcat ((3 ,2 ,1 ), C, C, I, B, 3 I ( 3 ) , 2 I):: SparseMatrixCSC ==
399
+ hvcat ((2 ,2 ,1 ), C, C, B, Matrix (3 I, 3 , 3 ), Matrix (2 I, 6 , 6 ))
384
400
@test (hvcat ((1 ,2 ), A, E, α)):: SparseMatrixCSC == hvcat ((1 ,2 ), A, E, [α]) == hvcat ((1 ,2 ), A, E, α* I)
385
401
@test (hvcat ((2 ,2 ), α, E, F, 3 I)):: SparseMatrixCSC == hvcat ((2 ,2 ), [α], E, F, Matrix (3 I, 3 , 3 ))
386
402
@test (hvcat ((2 ,2 ), 3 I, F, E, α)):: SparseMatrixCSC == hvcat ((2 ,2 ), Matrix (3 I, 3 , 3 ), F, E, [α])
0 commit comments