@@ -7,7 +7,7 @@ either in cscmatrix, or in lnkmatrix, never in both.
7
7
8
8
$(TYPEDFIELDS)
9
9
"""
10
- mutable struct ExtendableSparseMatrix{Tv, Ti <: Integer } <: AbstractSparseMatrix {Tv, Ti}
10
+ mutable struct ExtendableSparseMatrix{Tv, Ti <: Integer } <: AbstractSparseMatrixCSC {Tv, Ti}
11
11
"""
12
12
Final matrix data
13
13
"""
@@ -34,6 +34,7 @@ Create empty ExtendableSparseMatrix. This is equivalent to `spzeros(m,n)` for
34
34
`SparseMartrixCSC`.
35
35
36
36
"""
37
+
37
38
function ExtendableSparseMatrix {Tv, Ti} (m, n) where {Tv, Ti <: Integer }
38
39
ExtendableSparseMatrix {Tv, Ti} (spzeros (Tv, Ti, m, n), nothing , 0 )
39
40
end
@@ -56,6 +57,7 @@ $(SIGNATURES)
56
57
57
58
Create ExtendableSparseMatrix from SparseMatrixCSC
58
59
"""
60
+
59
61
function ExtendableSparseMatrix (csc:: SparseMatrixCSC{Tv, Ti} ) where {Tv, Ti <: Integer }
60
62
return ExtendableSparseMatrix {Tv, Ti} (csc, nothing , phash (csc))
61
63
end
154
156
155
157
If `v` is zero, no new entry is created.
156
158
"""
159
+
157
160
function updateindex! (ext:: ExtendableSparseMatrix{Tv, Ti} ,
158
161
op,
159
162
v,
@@ -199,7 +202,10 @@ $(SIGNATURES)
199
202
Find index in CSC matrix and set value if it exists. Otherwise,
200
203
set index in extension if `v` is nonzero.
201
204
"""
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}
203
209
k = findindex (ext. cscmatrix, i, j)
204
210
if k > 0
205
211
ext. cscmatrix. nzval[k] = v
@@ -217,7 +223,9 @@ $(SIGNATURES)
217
223
Find index in CSC matrix and return value, if it exists.
218
224
Otherwise, return value from extension.
219
225
"""
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 }
221
229
k = findindex (ext. cscmatrix, i, j)
222
230
if k > 0
223
231
return ext. cscmatrix. nzval[k]
@@ -303,26 +311,28 @@ end
303
311
"""
304
312
$(SIGNATURES)
305
313
314
+ Return element type.
315
+ """
316
+ Base. eltype (:: ExtendableSparseMatrix{Tv, Ti} ) where {Tv, Ti} = Tv
317
+
318
+ """
319
+ $(SIGNATURES)
320
+
306
321
[`flush!`](@ref) and return rowvals in ext.cscmatrix.
307
322
"""
308
323
function SparseArrays. rowvals (ext:: ExtendableSparseMatrix )
309
324
flush! (ext)
310
325
rowvals (ext. cscmatrix)
311
326
end
312
327
313
- function SparseArrays. getrowval (S:: ExtendableSparseMatrix )
314
- flush! (S)
315
- getfield (S. cscmatrix, :rowval )
316
- end
317
-
318
328
"""
319
329
$(SIGNATURES)
320
330
321
331
[`flush!`](@ref) and return colptr of in ext.cscmatrix.
322
332
"""
323
333
function SparseArrays. getcolptr (ext:: ExtendableSparseMatrix )
324
334
flush! (ext)
325
- return ext. cscmatrix. colptr
335
+ return getcolptr ( ext. cscmatrix)
326
336
end
327
337
328
338
"""
@@ -335,15 +345,12 @@ function SparseArrays.findnz(ext::ExtendableSparseMatrix)
335
345
return findnz (ext. cscmatrix)
336
346
end
337
347
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)
345
352
end
346
- end # USE_GPL_LIBS
353
+ end
347
354
348
355
"""
349
356
A\b
@@ -353,7 +360,7 @@ are allowed in the Julia sysimage and the floating point type of the matrix is
353
360
In that case, Julias standard `\` is called, which is realized via UMFPACK.
354
361
"""
355
362
function LinearAlgebra.:\ (ext:: ExtendableSparseMatrix{Tv, Ti} ,
356
- b:: AbstractVector{Tv} ) where {Tv, Ti}
363
+ b:: AbstractVector ) where {Tv, Ti}
357
364
flush! (ext)
358
365
SparspakLU (ext) \ b
359
366
end
@@ -364,16 +371,8 @@ $(SIGNATURES)
364
371
[`\\ `](@ref) for Symmetric{ExtendableSparse}
365
372
"""
366
373
function 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 ...
377
376
end
378
377
379
378
"""
@@ -382,18 +381,42 @@ $(SIGNATURES)
382
381
[`\\ `](@ref) for Hermitian{ExtendableSparse}
383
382
"""
384
383
function 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 ...
395
386
end
396
387
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
+
397
420
"""
398
421
$(SIGNATURES)
399
422
0 commit comments