|
39 | 39 | @test SparseArrays.indtype(sparse(Int8[1,1],Int8[1,1],[1,1])) == Int8 |
40 | 40 | end |
41 | 41 |
|
| 42 | +@testset "conversion to AbstractMatrix/SparseMatrix of same eltype" begin |
| 43 | + a = sprand(5, 5, 0.2) |
| 44 | + @test AbstractMatrix{eltype(a)}(a) == a |
| 45 | + @test SparseMatrixCSC{eltype(a)}(a) == a |
| 46 | + @test SparseMatrixCSC{eltype(a), Int}(a) == a |
| 47 | +end |
| 48 | + |
42 | 49 | @testset "sparse matrix construction" begin |
43 | 50 | @test (A = fill(1.0+im,5,5); isequal(Array(sparse(A)), A)) |
44 | 51 | @test_throws ArgumentError sparse([1,2,3], [1,2], [1,2,3], 3, 3) |
@@ -2350,6 +2357,15 @@ end |
2350 | 2357 | @test SparseMatrixCSC(A') isa SparseMatrixCSC |
2351 | 2358 | @test transpose(A) == SparseMatrixCSC(transpose(A)) |
2352 | 2359 | @test SparseMatrixCSC(transpose(A)) isa SparseMatrixCSC |
| 2360 | + @test SparseMatrixCSC{eltype(A)}(transpose(A)) == transpose(A) |
| 2361 | + @test SparseMatrixCSC{eltype(A), Int}(transpose(A)) == transpose(A) |
| 2362 | + @test SparseMatrixCSC{Float16}(transpose(A)) == transpose(SparseMatrixCSC{Float16}(A)) |
| 2363 | + @test SparseMatrixCSC{Float16, Int}(transpose(A)) == transpose(SparseMatrixCSC{Float16}(A)) |
| 2364 | + B = sprand(ComplexF64, 10, 10, 0.75) |
| 2365 | + @test SparseMatrixCSC{eltype(B)}(adjoint(B)) == adjoint(B) |
| 2366 | + @test SparseMatrixCSC{eltype(B), Int}(adjoint(B)) == adjoint(B) |
| 2367 | + @test SparseMatrixCSC{ComplexF16}(adjoint(B)) == adjoint(SparseMatrixCSC{ComplexF16}(B)) |
| 2368 | + @test SparseMatrixCSC{ComplexF16, Int8}(adjoint(B)) == adjoint(SparseMatrixCSC{ComplexF16, Int8}(B)) |
2353 | 2369 | end |
2354 | 2370 |
|
2355 | 2371 | # PR 28242 |
|
0 commit comments