Skip to content

Commit 2f7da14

Browse files
committed
Add rowval index type to SparseMatrixCSC
1 parent 21762f2 commit 2f7da14

File tree

9 files changed

+227
-181
lines changed

9 files changed

+227
-181
lines changed

stdlib/LinearAlgebra/src/svd.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ Q factor:
318318
1.0 0.0
319319
0.0 1.0
320320
D1 factor:
321-
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:
321+
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64, Int64} with 2 stored entries:
322322
0.707107 ⋅
323323
⋅ 0.707107
324324
D2 factor:
325-
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:
325+
2×2 SparseArrays.SparseMatrixCSC{Float64, Int64, Int64} with 2 stored entries:
326326
0.707107 ⋅
327327
⋅ 0.707107
328328
R0 factor:

stdlib/SparseArrays/docs/src/index.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ compared to dense arrays.
1212
## [Compressed Sparse Column (CSC) Sparse Matrix Storage](@id man-csc)
1313

1414
In Julia, sparse matrices are stored in the [Compressed Sparse Column (CSC) format](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_.28CSC_or_CCS.29).
15-
Julia sparse matrices have the type [`SparseMatrixCSC{Tv,Ti}`](@ref), where `Tv` is the
16-
type of the stored values, and `Ti` is the integer type for storing column pointers and
17-
row indices. The internal representation of `SparseMatrixCSC` is as follows:
15+
Julia sparse matrices have the type [`SparseMatrixCSC{Tv,Ti,Tr}`](@ref), where `Tv` is the
16+
type of the stored values, `Ti` is the integer type for storing column pointers and `Tr`
17+
is the integer type for storing row indices. The internal representation of `SparseMatrixCSC`
18+
is as follows:
1819

1920
```julia
20-
struct SparseMatrixCSC{Tv,Ti<:Integer} <: AbstractSparseMatrixCSC{Tv,Ti}
21+
struct SparseMatrixCSC{Tv,Ti<:Integer,Tr<:Integer} <: AbstractSparseMatrixCSC{Tv,Ti}
2122
m::Int # Number of rows
2223
n::Int # Number of columns
2324
colptr::Vector{Ti} # Column j is in colptr[j]:(colptr[j+1]-1)
24-
rowval::Vector{Ti} # Row indices of stored values
25+
rowval::Vector{Tr} # Row indices of stored values
2526
nzval::Vector{Tv} # Stored values, typically nonzeros
2627
end
2728
```
@@ -51,13 +52,13 @@ remove stored zeros from the sparse matrix.
5152

5253
```jldoctest
5354
julia> A = sparse([1, 1, 2, 3], [1, 3, 2, 3], [0, 1, 2, 0])
54-
3×3 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
55+
3×3 SparseMatrixCSC{Int64, Int64, Int64} with 4 stored entries:
5556
0 ⋅ 1
5657
⋅ 2 ⋅
5758
⋅ ⋅ 0
5859
5960
julia> dropzeros(A)
60-
3×3 SparseMatrixCSC{Int64, Int64} with 2 stored entries:
61+
3×3 SparseMatrixCSC{Int64, Int64, Int64} with 2 stored entries:
6162
⋅ ⋅ 1
6263
⋅ 2 ⋅
6364
⋅ ⋅ ⋅
@@ -105,7 +106,7 @@ such that `R[I[k]] = V[k]`.
105106
julia> I = [1, 4, 3, 5]; J = [4, 7, 18, 9]; V = [1, 2, -5, 3];
106107
107108
julia> S = sparse(I,J,V)
108-
5×18 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
109+
5×18 SparseMatrixCSC{Int64, Int64, Int64} with 4 stored entries:
109110
⠀⠈⠀⡀⠀⠀⠀⠀⠠
110111
⠀⠀⠀⠀⠁⠀⠀⠀⠀
111112
@@ -149,7 +150,7 @@ the [`sparse`](@ref) function:
149150

150151
```jldoctest
151152
julia> sparse(Matrix(1.0I, 5, 5))
152-
5×5 SparseMatrixCSC{Float64, Int64} with 5 stored entries:
153+
5×5 SparseMatrixCSC{Float64, Int64, Int64} with 5 stored entries:
153154
1.0 ⋅ ⋅ ⋅ ⋅
154155
⋅ 1.0 ⋅ ⋅ ⋅
155156
⋅ ⋅ 1.0 ⋅ ⋅

stdlib/SparseArrays/src/abstractsparse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Return a tuple `(I, J, V)` where `I` and `J` are the row and column indices of t
111111
# Examples
112112
```jldoctest
113113
julia> A = sparse([1 2 0; 0 0 3; 0 4 0])
114-
3×3 SparseMatrixCSC{Int64, Int64} with 4 stored entries:
114+
3×3 SparseMatrixCSC{Int64, Int64, Int64} with 4 stored entries:
115115
1 2 ⋅
116116
⋅ ⋅ 3
117117
⋅ 4 ⋅

stdlib/SparseArrays/src/sparseconvert.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ for wr in (Symmetric, Hermitian, Transpose, Adjoint,
2222
@eval SparseMatrixCSC{Tv}(A::$wr{Tv}) where Tv = _sparsem(A)
2323
@eval SparseMatrixCSC{Tv}(A::$wr) where Tv = SparseMatrixCSC{Tv}(_sparsem(A))
2424
@eval SparseMatrixCSC{Tv,Ti}(A::$wr) where {Tv,Ti} = SparseMatrixCSC{Tv,Ti}(_sparsem(A))
25+
@eval SparseMatrixCSC{Tv,Ti,Tr}(A::$wr) where {Tv,Ti,Tr} = SparseMatrixCSC{Tv,Ti,Tr}(_sparsem(A))
2526
end
2627

2728
"""
@@ -89,7 +90,7 @@ function _sparsem(@nospecialize A::AbstractArray{Tv}) where Tv
8990
end
9091
else
9192
# explicitly call abstract matrix fallback using getindex(A,...)
92-
invoke(SparseMatrixCSC{Tv,Int}, Tuple{AbstractMatrix}, A)
93+
invoke(SparseMatrixCSC{Tv,Int,Int}, Tuple{AbstractMatrix}, A)
9394
end
9495
end
9596

stdlib/SparseArrays/src/sparsematrix.jl

Lines changed: 157 additions & 113 deletions
Large diffs are not rendered by default.

stdlib/SparseArrays/test/sparse.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,16 +1944,16 @@ end
19441944
B12118 = sparse([1,2,4,5], [1,2,3,5], [2,1,-1,-2])
19451945

19461946
@test A12118 + B12118 == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], [3,3,3,-1,4,3])
1947-
@test typeof(A12118 + B12118) == SparseMatrixCSC{Int,Int}
1947+
@test typeof(A12118 + B12118) == SparseMatrixCSC{Int,Int,Int}
19481948

19491949
@test A12118 - B12118 == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], [-1,1,3,1,4,7])
1950-
@test typeof(A12118 - B12118) == SparseMatrixCSC{Int,Int}
1950+
@test typeof(A12118 - B12118) == SparseMatrixCSC{Int,Int,Int}
19511951

19521952
@test max.(A12118, B12118) == sparse([1,2,3,4,5], [1,2,3,4,5], [2,2,3,4,5])
1953-
@test typeof(max.(A12118, B12118)) == SparseMatrixCSC{Int,Int}
1953+
@test typeof(max.(A12118, B12118)) == SparseMatrixCSC{Int,Int,Int}
19541954

19551955
@test min.(A12118, B12118) == sparse([1,2,4,5], [1,2,3,5], [1,1,-1,-2])
1956-
@test typeof(min.(A12118, B12118)) == SparseMatrixCSC{Int,Int}
1956+
@test typeof(min.(A12118, B12118)) == SparseMatrixCSC{Int,Int,Int}
19571957
end
19581958

19591959
@testset "unary minus for SparseMatrixCSC{Bool}" begin
@@ -2053,19 +2053,19 @@ end
20532053
B13024 = sparse([1,2,4,5], [1,2,3,5], fill(true,4))
20542054

20552055
@test broadcast(&, A13024, B13024) == sparse([1,2,5], [1,2,5], fill(true,3))
2056-
@test typeof(broadcast(&, A13024, B13024)) == SparseMatrixCSC{Bool,Int}
2056+
@test typeof(broadcast(&, A13024, B13024)) == SparseMatrixCSC{Bool,Int,Int}
20572057

20582058
@test broadcast(|, A13024, B13024) == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], fill(true,6))
2059-
@test typeof(broadcast(|, A13024, B13024)) == SparseMatrixCSC{Bool,Int}
2059+
@test typeof(broadcast(|, A13024, B13024)) == SparseMatrixCSC{Bool,Int,Int}
20602060

20612061
@test broadcast(, A13024, B13024) == sparse([3,4,4], [3,3,4], fill(true,3), 5, 5)
2062-
@test typeof(broadcast(, A13024, B13024)) == SparseMatrixCSC{Bool,Int}
2062+
@test typeof(broadcast(, A13024, B13024)) == SparseMatrixCSC{Bool,Int,Int}
20632063

20642064
@test broadcast(max, A13024, B13024) == sparse([1,2,3,4,4,5], [1,2,3,3,4,5], fill(true,6))
2065-
@test typeof(broadcast(max, A13024, B13024)) == SparseMatrixCSC{Bool,Int}
2065+
@test typeof(broadcast(max, A13024, B13024)) == SparseMatrixCSC{Bool,Int,Int}
20662066

20672067
@test broadcast(min, A13024, B13024) == sparse([1,2,5], [1,2,5], fill(true,3))
2068-
@test typeof(broadcast(min, A13024, B13024)) == SparseMatrixCSC{Bool,Int}
2068+
@test typeof(broadcast(min, A13024, B13024)) == SparseMatrixCSC{Bool,Int,Int}
20692069

20702070
for op in (+, -)
20712071
@test op(A13024, B13024) == op(Array(A13024), Array(B13024))
@@ -2095,9 +2095,9 @@ end
20952095
A = A*transpose(A)
20962096
@test !Base.USE_GPL_LIBS || abs(det(factorize(Symmetric(A)))) abs(det(factorize(Array(A))))
20972097
@test factorize(triu(A)) == triu(A)
2098-
@test isa(factorize(triu(A)), UpperTriangular{Float64, SparseMatrixCSC{Float64, Int}})
2098+
@test isa(factorize(triu(A)), UpperTriangular{Float64, SparseMatrixCSC{Float64,Int,Int}})
20992099
@test factorize(tril(A)) == tril(A)
2100-
@test isa(factorize(tril(A)), LowerTriangular{Float64, SparseMatrixCSC{Float64, Int}})
2100+
@test isa(factorize(tril(A)), LowerTriangular{Float64, SparseMatrixCSC{Float64,Int,Int}})
21012101
C, b = A[:, 1:4], fill(1., size(A, 1))
21022102
@test !Base.USE_GPL_LIBS || factorize(C)\b Array(C)\b
21032103
@test_throws ErrorException eigen(A)
@@ -2317,15 +2317,15 @@ end
23172317
@testset "show" begin
23182318
io = IOBuffer()
23192319
show(io, MIME"text/plain"(), spzeros(Float64, Int64, 0, 0))
2320-
@test String(take!(io)) == "0×0 SparseArrays.SparseMatrixCSC{Float64, Int64} with 0 stored entries"
2320+
@test String(take!(io)) == "0×0 SparseArrays.SparseMatrixCSC{Float64, Int64, Int64} with 0 stored entries"
23212321
show(io, MIME"text/plain"(), sparse(Int64[1], Int64[1], [1.0]))
2322-
@test String(take!(io)) == "1×1 SparseArrays.SparseMatrixCSC{Float64, Int64} with 1 stored entry:\n 1.0"
2322+
@test String(take!(io)) == "1×1 SparseArrays.SparseMatrixCSC{Float64, Int64, Int64} with 1 stored entry:\n 1.0"
23232323
show(io, MIME"text/plain"(), spzeros(Float32, Int64, 2, 2))
2324-
@test String(take!(io)) == "2×2 SparseArrays.SparseMatrixCSC{Float32, Int64} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ "
2324+
@test String(take!(io)) == "2×2 SparseArrays.SparseMatrixCSC{Float32, Int64, Int64} with 0 stored entries:\n ⋅ ⋅ \n ⋅ ⋅ "
23252325

23262326
A = sparse(Int64[1, 1], Int64[1, 2], [1.0, 2.0])
23272327
show(io, MIME"text/plain"(), A)
2328-
@test String(take!(io)) == "1×2 SparseArrays.SparseMatrixCSC{Float64, Int64} with 2 stored entries:\n 1.0 2.0"
2328+
@test String(take!(io)) == "1×2 SparseArrays.SparseMatrixCSC{Float64, Int64, Int64} with 2 stored entries:\n 1.0 2.0"
23292329
_show_with_braille_patterns(convert(IOContext, io), A)
23302330
@test String(take!(io)) == ""
23312331

@@ -2344,13 +2344,13 @@ end
23442344

23452345
A = sparse(Int64[1, 2, 4, 2, 3], Int64[1, 1, 1, 2, 2], Int64[1, 1, 1, 1, 1], 4, 2)
23462346
show(io, MIME"text/plain"(), A)
2347-
@test String(take!(io)) == "4×2 SparseArrays.SparseMatrixCSC{Int64, Int64} with 5 stored entries:\n 1 ⋅\n 1 1\n ⋅ 1\n 1 ⋅"
2347+
@test String(take!(io)) == "4×2 SparseArrays.SparseMatrixCSC{Int64, Int64, Int64} with 5 stored entries:\n 1 ⋅\n 1 1\n ⋅ 1\n 1 ⋅"
23482348
_show_with_braille_patterns(convert(IOContext, io), A)
23492349
@test String(take!(io)) == ""
23502350

23512351
A = sparse(Int64[1, 3, 2, 4], Int64[1, 1, 2, 2], Int64[1, 1, 1, 1], 7, 3)
23522352
show(io, MIME"text/plain"(), A)
2353-
@test String(take!(io)) == "7×3 SparseArrays.SparseMatrixCSC{Int64, Int64} with 4 stored entries:\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅"
2353+
@test String(take!(io)) == "7×3 SparseArrays.SparseMatrixCSC{Int64, Int64, Int64} with 4 stored entries:\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n 1 ⋅ ⋅\n ⋅ 1 ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅\n ⋅ ⋅ ⋅"
23542354
_show_with_braille_patterns(convert(IOContext, io), A)
23552355
@test String(take!(io)) == "" * Char(10240) * "\n" * Char(10240)^2
23562356

@@ -2360,7 +2360,7 @@ end
23602360
@test String(take!(io)) == brailleString
23612361

23622362
# Issue #30589
2363-
@test repr("text/plain", sparse([true true])) == "1×2 SparseArrays.SparseMatrixCSC{Bool, $Int} with 2 stored entries:\n 1 1"
2363+
@test repr("text/plain", sparse([true true])) == "1×2 SparseArrays.SparseMatrixCSC{Bool, $Int, $Int} with 2 stored entries:\n 1 1"
23642364

23652365
function _filled_sparse(m::Integer, n::Integer)
23662366
C = CartesianIndices((m, n))[:]
@@ -2422,9 +2422,9 @@ end
24222422
@testset "similar with type conversion" begin
24232423
local A = sparse(1.0I, 5, 5)
24242424
@test size(similar(A, ComplexF64, Int)) == (5, 5)
2425-
@test typeof(similar(A, ComplexF64, Int)) == SparseMatrixCSC{ComplexF64, Int}
2425+
@test typeof(similar(A, ComplexF64, Int)) == SparseMatrixCSC{ComplexF64,Int,Int}
24262426
@test size(similar(A, ComplexF64, Int8)) == (5, 5)
2427-
@test typeof(similar(A, ComplexF64, Int8)) == SparseMatrixCSC{ComplexF64, Int8}
2427+
@test typeof(similar(A, ComplexF64, Int8)) == SparseMatrixCSC{ComplexF64,Int8,Int8}
24282428
@test similar(A, ComplexF64,(6, 6)) == spzeros(ComplexF64, 6, 6)
24292429
@test convert(Matrix, A) == Array(A) # lolwut, are you lost, test?
24302430
end
@@ -2440,14 +2440,14 @@ end
24402440
@test length(nonzeros(simA)) == length(nonzeros(A))
24412441
# test similar with entry type specification (preserves stored-entry structure)
24422442
simA = similar(A, Float32)
2443-
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(getcolptr(A))}
2443+
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(getcolptr(A)),eltype(rowvals(A))}
24442444
@test size(simA) == size(A)
24452445
@test getcolptr(simA) == getcolptr(A)
24462446
@test rowvals(simA) == rowvals(A)
24472447
@test length(nonzeros(simA)) == length(nonzeros(A))
24482448
# test similar with entry and index type specification (preserves stored-entry structure)
24492449
simA = similar(A, Float32, Int8)
2450-
@test typeof(simA) == SparseMatrixCSC{Float32,Int8}
2450+
@test typeof(simA) == SparseMatrixCSC{Float32,Int8,Int8}
24512451
@test size(simA) == size(A)
24522452
@test getcolptr(simA) == getcolptr(A)
24532453
@test rowvals(simA) == rowvals(A)
@@ -2461,14 +2461,14 @@ end
24612461
@test length(nonzeros(simA)) == length(nonzeros(A))
24622462
# test similar with entry type and Dims{2} specification (preserves storage space only)
24632463
simA = similar(A, Float32, (6,6))
2464-
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(getcolptr(A))}
2464+
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(getcolptr(A)),eltype(rowvals(A))}
24652465
@test size(simA) == (6,6)
24662466
@test getcolptr(simA) == fill(1, 6+1)
24672467
@test length(rowvals(simA)) == length(rowvals(A))
24682468
@test length(nonzeros(simA)) == length(nonzeros(A))
24692469
# test similar with entry type, index type, and Dims{2} specification (preserves storage space only)
24702470
simA = similar(A, Float32, Int8, (6,6))
2471-
@test typeof(simA) == SparseMatrixCSC{Float32, Int8}
2471+
@test typeof(simA) == SparseMatrixCSC{Float32, Int8, Int8}
24722472
@test size(simA) == (6,6)
24732473
@test getcolptr(simA) == fill(1, 6+1)
24742474
@test length(rowvals(simA)) == length(rowvals(A))

stdlib/SparseArrays/test/sparsevector.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,21 +1385,21 @@ end
13851385
@test similar(A, Float32, Int8, 6) == similar(A, Float32, Int8, (6,))
13861386
# test similar with Dims{2} specification (preserves storage space only, not stored-entry structure)
13871387
simA = similar(A, (6,6))
1388-
@test typeof(simA) == SparseMatrixCSC{eltype(nonzeros(A)),eltype(nonzeroinds(A))}
1388+
@test typeof(simA) == SparseMatrixCSC{eltype(nonzeros(A)),eltype(nonzeroinds(A)),eltype(nonzeroinds(A))}
13891389
@test size(simA) == (6,6)
13901390
@test getcolptr(simA) == fill(1, 6+1)
13911391
@test length(rowvals(simA)) == length(nonzeroinds(A))
13921392
@test length(nonzeros(simA)) == length(nonzeros(A))
13931393
# test similar with entry type and Dims{2} specification (preserves storage space only)
13941394
simA = similar(A, Float32, (6,6))
1395-
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(nonzeroinds(A))}
1395+
@test typeof(simA) == SparseMatrixCSC{Float32,eltype(nonzeroinds(A)),eltype(nonzeroinds(A))}
13961396
@test size(simA) == (6,6)
13971397
@test getcolptr(simA) == fill(1, 6+1)
13981398
@test length(rowvals(simA)) == length(nonzeroinds(A))
13991399
@test length(nonzeros(simA)) == length(nonzeros(A))
14001400
# test similar with entry type, index type, and Dims{2} specification (preserves storage space only)
14011401
simA = similar(A, Float32, Int8, (6,6))
1402-
@test typeof(simA) == SparseMatrixCSC{Float32, Int8}
1402+
@test typeof(simA) == SparseMatrixCSC{Float32, Int8, Int8}
14031403
@test size(simA) == (6,6)
14041404
@test getcolptr(simA) == fill(1, 6+1)
14051405
@test length(rowvals(simA)) == length(nonzeroinds(A))

stdlib/SuiteSparse/src/cholmod.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -944,9 +944,9 @@ function Sparse(A::SparseMatrixCSC)
944944
o
945945
end
946946

947-
Sparse(A::Symmetric{Tv, SparseMatrixCSC{Tv,Ti}}) where {Tv<:Real, Ti} =
947+
Sparse(A::Symmetric{Tv,<:SparseMatrixCSC{Tv,Ti}}) where {Tv<:Real, Ti} =
948948
Sparse(A.data, A.uplo == 'L' ? -1 : 1)
949-
Sparse(A::Hermitian{Tv,SparseMatrixCSC{Tv,Ti}}) where {Tv, Ti} =
949+
Sparse(A::Hermitian{Tv,<:SparseMatrixCSC{Tv,Ti}}) where {Tv, Ti} =
950950
Sparse(A.data, A.uplo == 'L' ? -1 : 1)
951951

952952
Sparse(A::Dense) = dense_to_sparse(A, SuiteSparse_long)
@@ -1327,9 +1327,9 @@ See also [`cholesky`](@ref).
13271327
"""
13281328
cholesky!(F::Factor, A::Union{SparseMatrixCSC{T},
13291329
SparseMatrixCSC{Complex{T}},
1330-
Symmetric{T,SparseMatrixCSC{T,SuiteSparse_long}},
1331-
Hermitian{Complex{T},SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1332-
Hermitian{T,SparseMatrixCSC{T,SuiteSparse_long}}};
1330+
Symmetric{T,<:SparseMatrixCSC{T,SuiteSparse_long}},
1331+
Hermitian{Complex{T},<:SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1332+
Hermitian{T,<:SparseMatrixCSC{T,SuiteSparse_long}}};
13331333
shift = 0.0, check::Bool = true) where {T<:Real} =
13341334
cholesky!(F, Sparse(A); shift = shift, check = check)
13351335

@@ -1414,7 +1414,7 @@ julia> L * L' ≈ A[C.p, C.p]
14141414
true
14151415
14161416
julia> P = sparse(1:3, C.p, ones(3))
1417-
3×3 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
1417+
3×3 SparseMatrixCSC{Float64, Int64, Int64} with 3 stored entries:
14181418
⋅ ⋅ 1.0
14191419
⋅ 1.0 ⋅
14201420
1.0 ⋅ ⋅
@@ -1452,9 +1452,9 @@ true
14521452
`Base.SparseArrays.CHOLMOD` module.
14531453
"""
14541454
cholesky(A::Union{SparseMatrixCSC{T}, SparseMatrixCSC{Complex{T}},
1455-
Symmetric{T,SparseMatrixCSC{T,SuiteSparse_long}},
1456-
Hermitian{Complex{T},SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1457-
Hermitian{T,SparseMatrixCSC{T,SuiteSparse_long}}};
1455+
Symmetric{T,<:SparseMatrixCSC{T,SuiteSparse_long}},
1456+
Hermitian{Complex{T},<:SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1457+
Hermitian{T,<:SparseMatrixCSC{T,SuiteSparse_long}}};
14581458
kws...) where {T<:Real} = cholesky(Sparse(A); kws...)
14591459

14601460

@@ -1491,9 +1491,9 @@ See also [`ldlt`](@ref).
14911491
"""
14921492
ldlt!(F::Factor, A::Union{SparseMatrixCSC{T},
14931493
SparseMatrixCSC{Complex{T}},
1494-
Symmetric{T,SparseMatrixCSC{T,SuiteSparse_long}},
1495-
Hermitian{Complex{T},SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1496-
Hermitian{T,SparseMatrixCSC{T,SuiteSparse_long}}};
1494+
Symmetric{T,<:SparseMatrixCSC{T,SuiteSparse_long}},
1495+
Hermitian{Complex{T},<:SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1496+
Hermitian{T,<:SparseMatrixCSC{T,SuiteSparse_long}}};
14971497
shift = 0.0, check::Bool = true) where {T<:Real} =
14981498
ldlt!(F, Sparse(A), shift = shift, check = check)
14991499

@@ -1556,9 +1556,9 @@ it should be a permutation of `1:size(A,1)` giving the ordering to use
15561556
`Base.SparseArrays.CHOLMOD` module.
15571557
"""
15581558
ldlt(A::Union{SparseMatrixCSC{T},SparseMatrixCSC{Complex{T}},
1559-
Symmetric{T,SparseMatrixCSC{T,SuiteSparse_long}},
1560-
Hermitian{Complex{T},SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1561-
Hermitian{T,SparseMatrixCSC{T,SuiteSparse_long}}};
1559+
Symmetric{T,<:SparseMatrixCSC{T,SuiteSparse_long}},
1560+
Hermitian{Complex{T},<:SparseMatrixCSC{Complex{T},SuiteSparse_long}},
1561+
Hermitian{T,<:SparseMatrixCSC{T,SuiteSparse_long}}};
15621562
kws...) where {T<:Real} = ldlt(Sparse(A); kws...)
15631563

15641564
## Rank updates
@@ -1734,9 +1734,9 @@ function \(adjL::Adjoint{<:Any,<:Factor}, B::StridedMatrix)
17341734
end
17351735

17361736
const RealHermSymComplexHermF64SSL = Union{
1737-
Symmetric{Float64,SparseMatrixCSC{Float64,SuiteSparse_long}},
1738-
Hermitian{Float64,SparseMatrixCSC{Float64,SuiteSparse_long}},
1739-
Hermitian{ComplexF64,SparseMatrixCSC{ComplexF64,SuiteSparse_long}}}
1737+
Symmetric{Float64,SparseMatrixCSC{Float64,SuiteSparse_long,SuiteSparse_long}},
1738+
Hermitian{Float64,SparseMatrixCSC{Float64,SuiteSparse_long,SuiteSparse_long}},
1739+
Hermitian{ComplexF64,SparseMatrixCSC{ComplexF64,SuiteSparse_long,SuiteSparse_long}}}
17401740
const StridedVecOrMatInclAdjAndTrans = Union{StridedVecOrMat, Adjoint{<:Any, <:StridedVecOrMat}, Transpose{<:Any, <:StridedVecOrMat}}
17411741
function \(A::RealHermSymComplexHermF64SSL, B::StridedVecOrMatInclAdjAndTrans)
17421742
F = cholesky(A; check = false)
@@ -1858,18 +1858,18 @@ function ishermitian(A::Sparse{ComplexF64})
18581858
end
18591859
end
18601860

1861-
(*)(A::Symmetric{Float64,SparseMatrixCSC{Float64,Ti}},
1861+
(*)(A::Symmetric{Float64,<:SparseMatrixCSC{Float64,Ti}},
18621862
B::SparseVecOrMat{Float64,Ti}) where {Ti} = sparse(Sparse(A)*Sparse(B))
1863-
(*)(A::Hermitian{ComplexF64,SparseMatrixCSC{ComplexF64,Ti}},
1863+
(*)(A::Hermitian{ComplexF64,<:SparseMatrixCSC{ComplexF64,Ti}},
18641864
B::SparseVecOrMat{ComplexF64,Ti}) where {Ti} = sparse(Sparse(A)*Sparse(B))
1865-
(*)(A::Hermitian{Float64,SparseMatrixCSC{Float64,Ti}},
1865+
(*)(A::Hermitian{Float64,<:SparseMatrixCSC{Float64,Ti}},
18661866
B::SparseVecOrMat{Float64,Ti}) where {Ti} = sparse(Sparse(A)*Sparse(B))
18671867

18681868
(*)(A::SparseVecOrMat{Float64,Ti},
1869-
B::Symmetric{Float64,SparseMatrixCSC{Float64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
1869+
B::Symmetric{Float64,<:SparseMatrixCSC{Float64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
18701870
(*)(A::SparseVecOrMat{ComplexF64,Ti},
1871-
B::Hermitian{ComplexF64,SparseMatrixCSC{ComplexF64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
1871+
B::Hermitian{ComplexF64,<:SparseMatrixCSC{ComplexF64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
18721872
(*)(A::SparseVecOrMat{Float64,Ti},
1873-
B::Hermitian{Float64,SparseMatrixCSC{Float64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
1873+
B::Hermitian{Float64,<:SparseMatrixCSC{Float64,Ti}}) where {Ti} = sparse(Sparse(A)*Sparse(B))
18741874

18751875
end #module

0 commit comments

Comments
 (0)