@@ -7,7 +7,7 @@ either in cscmatrix, or in lnkmatrix, never in both.
77
88$(TYPEDFIELDS)
99"""
10- mutable struct ExtendableSparseMatrix{Tv, Ti <: Integer } <: AbstractSparseMatrix {Tv, Ti}
10+ mutable struct ExtendableSparseMatrix{Tv, Ti <: Integer } <: AbstractSparseMatrixCSC {Tv, Ti}
1111 """
1212 Final matrix data
1313 """
@@ -34,6 +34,7 @@ Create empty ExtendableSparseMatrix. This is equivalent to `spzeros(m,n)` for
3434`SparseMartrixCSC`.
3535
3636"""
37+
3738function ExtendableSparseMatrix {Tv, Ti} (m, n) where {Tv, Ti <: Integer }
3839 ExtendableSparseMatrix {Tv, Ti} (spzeros (Tv, Ti, m, n), nothing , 0 )
3940end
@@ -56,6 +57,7 @@ $(SIGNATURES)
5657
5758 Create ExtendableSparseMatrix from SparseMatrixCSC
5859"""
60+
5961function ExtendableSparseMatrix (csc:: SparseMatrixCSC{Tv, Ti} ) where {Tv, Ti <: Integer }
6062 return ExtendableSparseMatrix {Tv, Ti} (csc, nothing , phash (csc))
6163end
154156
155157If `v` is zero, no new entry is created.
156158"""
159+
157160function updateindex! (ext:: ExtendableSparseMatrix{Tv, Ti} ,
158161 op,
159162 v,
@@ -199,7 +202,10 @@ $(SIGNATURES)
199202Find index in CSC matrix and set value if it exists. Otherwise,
200203set index in extension if `v` is nonzero.
201204"""
202- function Base. setindex! (ext:: ExtendableSparseMatrix{Tv, Ti} , v, i, j) where {Tv, Ti}
205+ function Base. setindex! (ext:: ExtendableSparseMatrix{Tv, Ti} ,
206+ v,
207+ i:: Integer ,
208+ j:: Integer ) where {Tv, Ti}
203209 k = findindex (ext. cscmatrix, i, j)
204210 if k > 0
205211 ext. cscmatrix. nzval[k] = v
@@ -217,7 +223,9 @@ $(SIGNATURES)
217223Find index in CSC matrix and return value, if it exists.
218224Otherwise, return value from extension.
219225"""
220- function Base. getindex (ext:: ExtendableSparseMatrix{Tv, Ti} , i, j) where {Tv, Ti <: Integer }
226+ function Base. getindex (ext:: ExtendableSparseMatrix{Tv, Ti} ,
227+ i:: Integer ,
228+ j:: Integer ) where {Tv, Ti <: Integer }
221229 k = findindex (ext. cscmatrix, i, j)
222230 if k > 0
223231 return ext. cscmatrix. nzval[k]
@@ -303,26 +311,28 @@ end
303311"""
304312$(SIGNATURES)
305313
314+ Return element type.
315+ """
316+ Base. eltype (:: ExtendableSparseMatrix{Tv, Ti} ) where {Tv, Ti} = Tv
317+
318+ """
319+ $(SIGNATURES)
320+
306321[`flush!`](@ref) and return rowvals in ext.cscmatrix.
307322"""
308323function SparseArrays. rowvals (ext:: ExtendableSparseMatrix )
309324 flush! (ext)
310325 rowvals (ext. cscmatrix)
311326end
312327
313- function SparseArrays. getrowval (S:: ExtendableSparseMatrix )
314- flush! (S)
315- getfield (S. cscmatrix, :rowval )
316- end
317-
318328"""
319329$(SIGNATURES)
320330
321331[`flush!`](@ref) and return colptr of in ext.cscmatrix.
322332"""
323333function SparseArrays. getcolptr (ext:: ExtendableSparseMatrix )
324334 flush! (ext)
325- return ext. cscmatrix. colptr
335+ return getcolptr ( ext. cscmatrix)
326336end
327337
328338"""
@@ -335,15 +345,12 @@ function SparseArrays.findnz(ext::ExtendableSparseMatrix)
335345 return findnz (ext. cscmatrix)
336346end
337347
338- if USE_GPL_LIBS
339- for (Tv) in (:Float64 , :ComplexF64 )
340- @eval begin function LinearAlgebra.:\ (ext:: ExtendableSparseMatrix{$Tv, Ti} ,
341- B:: AbstractVecOrMat{$Tv} ) where {Ti}
342- flush! (ext)
343- ext. cscmatrix \ B
344- end end
348+ @static if VERSION >= v " 1.7"
349+ function SparseArrays. _checkbuffers (ext:: ExtendableSparseMatrix )
350+ flush! (ext)
351+ SparseArrays. _checkbuffers (ext. cscmatrix)
345352 end
346- end # USE_GPL_LIBS
353+ end
347354
348355"""
349356 A\b
@@ -353,7 +360,7 @@ are allowed in the Julia sysimage and the floating point type of the matrix is
353360In that case, Julias standard `\` is called, which is realized via UMFPACK.
354361"""
355362function LinearAlgebra.:\ (ext:: ExtendableSparseMatrix{Tv, Ti} ,
356- b:: AbstractVector{Tv} ) where {Tv, Ti}
363+ b:: AbstractVector ) where {Tv, Ti}
357364 flush! (ext)
358365 SparspakLU (ext) \ b
359366end
@@ -364,16 +371,8 @@ $(SIGNATURES)
364371[`\\ `](@ref) for Symmetric{ExtendableSparse}
365372"""
366373function LinearAlgebra.:\ (symm_ext:: Symmetric{Tm, ExtendableSparseMatrix{Tm, Ti}} ,
367- B:: AbstractVector{T} where {T}) where {Tm, Ti}
368- flush! (symm_ext. data)
369- symm_csc = Symmetric (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
370- symm_csc \ B
371- end
372- function LinearAlgebra.:\ (symm_ext:: Symmetric{Tm, ExtendableSparseMatrix{Tm, Ti}} ,
373- B:: AbstractMatrix{T} where {T}) where {Tm, Ti}
374- flush! (symm_ext. data)
375- symm_csc = Symmetric (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
376- symm_csc \ B
374+ b:: AbstractVector ) where {Tm, Ti}
375+ symm_ext. data \ b # no ldlt yet ...
377376end
378377
379378"""
@@ -382,18 +381,42 @@ $(SIGNATURES)
382381[`\\ `](@ref) for Hermitian{ExtendableSparse}
383382"""
384383function LinearAlgebra.:\ (symm_ext:: Hermitian{Tm, ExtendableSparseMatrix{Tm, Ti}} ,
385- B:: AbstractVector{T} where {T}) where {Tm, Ti}
386- flush! (symm_ext. data)
387- symm_csc = Hermitian (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
388- symm_csc \ B
389- end
390- function LinearAlgebra.:\ (symm_ext:: Hermitian{Tm, ExtendableSparseMatrix{Tm, Ti}} ,
391- B:: AbstractMatrix{T} where {T}) where {Tm, Ti}
392- flush! (symm_ext. data)
393- symm_csc = Hermitian (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
394- symm_csc \ B
384+ b:: AbstractVector ) where {Tm, Ti}
385+ symm_ext. data \ B # no ldlt yet ...
395386end
396387
388+ if USE_GPL_LIBS
389+ for (Tv) in (:Float64 , :ComplexF64 )
390+ @eval begin function LinearAlgebra.:\ (ext:: ExtendableSparseMatrix{$Tv, Ti} ,
391+ B:: AbstractVector ) where {Ti}
392+ flush! (ext)
393+ ext. cscmatrix \ B
394+ end end
395+
396+ @eval begin function LinearAlgebra.:\ (symm_ext:: Symmetric {$ Tv,
397+ ExtendableSparseMatrix{
398+ $ Tv,
399+ Ti
400+ }},
401+ B:: AbstractVector ) where {Ti}
402+ flush! (symm_ext. data)
403+ symm_csc = Symmetric (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
404+ symm_csc \ B
405+ end end
406+
407+ @eval begin function LinearAlgebra.:\ (symm_ext:: Hermitian {$ Tv,
408+ ExtendableSparseMatrix{
409+ $ Tv,
410+ Ti
411+ }},
412+ B:: AbstractVector ) where {Ti}
413+ flush! (symm_ext. data)
414+ symm_csc = Hermitian (symm_ext. data. cscmatrix, Symbol (symm_ext. uplo))
415+ symm_csc \ B
416+ end end
417+ end
418+ end # USE_GPL_LIBS
419+
397420"""
398421$(SIGNATURES)
399422
0 commit comments