@@ -4,8 +4,6 @@ using Requires
4
4
using LinearAlgebra
5
5
using SparseArrays
6
6
7
- export findstructralnz,has_sparsestruct
8
-
9
7
function ismutable end
10
8
11
9
"""
@@ -20,6 +18,28 @@ ismutable(x) = ismutable(typeof(x))
20
18
ismutable (:: Type{<:Array} ) = true
21
19
ismutable (:: Type{<:Number} ) = false
22
20
21
+ """
22
+ can_setindex(x::DataType)
23
+
24
+ Query whether a type can use `setindex!`
25
+ """
26
+ can_setindex (x) = true
27
+
28
+ """
29
+ isstructured(x::DataType)
30
+
31
+ Query whether a type is a representation of a structured matrix
32
+ """
33
+ isstructured (x) = false
34
+ isstructured (:: Symmetric ) = true
35
+ isstructured (:: Hermitian ) = true
36
+ isstructured (:: UpperTriangular ) = true
37
+ isstructured (:: LowerTriangular ) = true
38
+ isstructured (:: Tridiagonal ) = true
39
+ isstructured (:: SymTridiagonal ) = true
40
+ isstructured (:: Bidiagonal ) = true
41
+ isstructured (:: Diagonal ) = true
42
+
23
43
"""
24
44
has_sparsestruct(x::AbstractArray)
25
45
@@ -37,7 +57,7 @@ has_sparsestruct(x::SymTridiagonal)=true
37
57
findstructralnz(x::AbstractArray)
38
58
39
59
Return: (I,J) #indexable objects
40
- Find sparsity pattern of special matrices, similar to first two elements of findnz(::SparseMatrixCSC)
60
+ Find sparsity pattern of special matrices, the same as the first two elements of findnz(::SparseMatrixCSC)
41
61
"""
42
62
function findstructralnz (x:: Diagonal )
43
63
n= size (x,1 )
@@ -107,15 +127,26 @@ function __init__()
107
127
108
128
@require StaticArrays= " 90137ffa-7385-5640-81b9-e52037218182" begin
109
129
ismutable (:: Type{<:StaticArrays.StaticArray} ) = false
130
+ can_setindex (:: Type{<:StaticArrays.StaticArray} ) = false
110
131
ismutable (:: Type{<:StaticArrays.MArray} ) = true
111
132
end
112
133
113
134
@require LabelledArrays= " 2ee39098-c373-598a-b85f-a56591580800" begin
114
135
ismutable (:: Type{<:LabelledArrays.LArray{T,N,Syms}} ) where {T,N,Syms} = ismutable (T)
115
136
end
116
-
137
+
117
138
@require Flux= " 587475ba-b771-5e3f-ad9e-33799f191a9c" begin
118
139
ismutable (:: Type{<:Flux.Tracker.TrackedArray} ) = false
140
+ can_setindex (:: Type{<:Flux.Tracker.TrackedArray} ) = false
141
+ end
142
+
143
+ @require BandedMatrices= " aae01518-5342-5314-be14-df237901396f" begin
144
+ is_structured (:: BandedMatrices.BandedMatrix ) = true
145
+ end
146
+
147
+ @require BlockBandedMatrices= " aae01518-5342-5314-be14-df237901396f" begin
148
+ is_structured (:: BandedMatrices.BlockBandedMatrix ) = true
149
+ is_structured (:: BandedMatrices.BandedBlockBandedMatrix ) = true
119
150
end
120
151
end
121
152
0 commit comments