@@ -4,8 +4,6 @@ using Requires
44using LinearAlgebra
55using SparseArrays
66
7- export findstructralnz,has_sparsestruct
8-
97function ismutable end
108
119"""
@@ -20,6 +18,28 @@ ismutable(x) = ismutable(typeof(x))
2018ismutable (:: Type{<:Array} ) = true
2119ismutable (:: Type{<:Number} ) = false
2220
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+
2343"""
2444 has_sparsestruct(x::AbstractArray)
2545
@@ -37,7 +57,7 @@ has_sparsestruct(x::SymTridiagonal)=true
3757 findstructralnz(x::AbstractArray)
3858
3959Return: (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)
4161"""
4262function findstructralnz (x:: Diagonal )
4363 n= size (x,1 )
@@ -107,15 +127,26 @@ function __init__()
107127
108128 @require StaticArrays= " 90137ffa-7385-5640-81b9-e52037218182" begin
109129 ismutable (:: Type{<:StaticArrays.StaticArray} ) = false
130+ can_setindex (:: Type{<:StaticArrays.StaticArray} ) = false
110131 ismutable (:: Type{<:StaticArrays.MArray} ) = true
111132 end
112133
113134 @require LabelledArrays= " 2ee39098-c373-598a-b85f-a56591580800" begin
114135 ismutable (:: Type{<:LabelledArrays.LArray{T,N,Syms}} ) where {T,N,Syms} = ismutable (T)
115136 end
116-
137+
117138 @require Flux= " 587475ba-b771-5e3f-ad9e-33799f191a9c" begin
118139 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
119150 end
120151end
121152
0 commit comments