@@ -34,7 +34,7 @@ $(SIGNATURES)
3434
3535Create empty ExtendableSparseMatrix.
3636"""
37- function ExtendableSparseMatrix (:: Type{Tv} ,:: Type{Ti} ,m:: Integer , n:: Integer ) where {Tv,Ti<: Integer }
37+ function ExtendableSparseMatrix (valuetype :: Type{Tv} ,indextype :: Type{Ti} ,m:: Integer , n:: Integer ) where {Tv,Ti<: Integer }
3838 ExtendableSparseMatrix {Tv,Ti} (m,n)
3939end
4040
@@ -44,7 +44,7 @@ $(SIGNATURES)
4444Create empty ExtendablSparseMatrix.
4545This is a pendant to spzeros.
4646"""
47- ExtendableSparseMatrix (:: Type{Tv} ,m:: Integer , n:: Integer ) where {Tv}= ExtendableSparseMatrix {Tv,Int} (m,n)
47+ ExtendableSparseMatrix (valuetype :: Type{Tv} ,m:: Integer , n:: Integer ) where {Tv}= ExtendableSparseMatrix {Tv,Int} (m,n)
4848
4949
5050"""
@@ -59,10 +59,10 @@ ExtendableSparseMatrix(m::Integer, n::Integer)=ExtendableSparseMatrix{Float64,In
5959"""
6060$(SIGNATURES)
6161
62- Create ExtendableSparseMatrix from sparse matrix
62+ Create ExtendableSparseMatrix from SparseMatrixCSC
6363"""
64- function ExtendableSparseMatrix (M :: SparseMatrixCSC{Tv,Ti} ) where {Tv,Ti<: Integer }
65- return ExtendableSparseMatrix {Tv,Ti} (M , nothing )
64+ function ExtendableSparseMatrix (csc :: SparseMatrixCSC{Tv,Ti} ) where {Tv,Ti<: Integer }
65+ return ExtendableSparseMatrix {Tv,Ti} (csc , nothing )
6666end
6767
6868
@@ -73,17 +73,17 @@ $(SIGNATURES)
7373Return index corresponding to entry [i,j] in the array of nonzeros,
7474if the entry exists, otherwise, return 0.
7575"""
76- function findindex (S :: SparseMatrixCSC{T} , i:: Integer , j:: Integer ) where T
77- if ! (1 <= i <= S . m && 1 <= j <= S . n); throw (BoundsError ()); end
78- r1 = Int (S . colptr[j])
79- r2 = Int (S . colptr[j+ 1 ]- 1 )
76+ function findindex (csc :: SparseMatrixCSC{T} , i:: Integer , j:: Integer ) where T
77+ if ! (1 <= i <= csc . m && 1 <= j <= csc . n); throw (BoundsError ()); end
78+ r1 = Int (csc . colptr[j])
79+ r2 = Int (csc . colptr[j+ 1 ]- 1 )
8080 if r1> r2
8181 return 0
8282 end
8383
8484 # See sparsematrix.jl
85- r1 = searchsortedfirst (S . rowval, i, r1, r2, Base. Forward)
86- if (r1> r2 || S . rowval[r1] != i)
85+ r1 = searchsortedfirst (csc . rowval, i, r1, r2, Base. Forward)
86+ if (r1> r2 || csc . rowval[r1] != i)
8787 return 0
8888 end
8989 return r1
@@ -97,15 +97,15 @@ $(SIGNATURES)
9797Find index in CSC matrix and set value if it exists. Otherwise,
9898set index in extension.
9999"""
100- function Base. setindex! (M :: ExtendableSparseMatrix{Tv,Ti} , v, i:: Integer , j:: Integer ) where {Tv,Ti<: Integer }
101- k= findindex (M . cscmatrix,i,j)
100+ function Base. setindex! (ext :: ExtendableSparseMatrix{Tv,Ti} , v, i:: Integer , j:: Integer ) where {Tv,Ti<: Integer }
101+ k= findindex (ext . cscmatrix,i,j)
102102 if k> 0
103- M . cscmatrix. nzval[k]= v
103+ ext . cscmatrix. nzval[k]= v
104104 else
105- if M . lnkmatrix== nothing
106- M . lnkmatrix= SparseMatrixLNK {Tv, Ti} (M . cscmatrix. m, M . cscmatrix. n)
105+ if ext . lnkmatrix== nothing
106+ ext . lnkmatrix= SparseMatrixLNK {Tv, Ti} (ext . cscmatrix. m, ext . cscmatrix. n)
107107 end
108- M . lnkmatrix[i,j]= v
108+ ext . lnkmatrix[i,j]= v
109109 end
110110end
111111
@@ -119,14 +119,14 @@ $(SIGNATURES)
119119Find index in CSC matrix and return value, if it exists.
120120Otherwise, return value from extension.
121121"""
122- function Base. getindex (M :: ExtendableSparseMatrix{Tv,Ti} ,i:: Integer , j:: Integer ) where {Tv,Ti<: Integer }
123- k= findindex (M . cscmatrix,i,j)
122+ function Base. getindex (ext :: ExtendableSparseMatrix{Tv,Ti} ,i:: Integer , j:: Integer ) where {Tv,Ti<: Integer }
123+ k= findindex (ext . cscmatrix,i,j)
124124 if k> 0
125- return M . cscmatrix. nzval[k]
126- elseif M . lnkmatrix== nothing
125+ return ext . cscmatrix. nzval[k]
126+ elseif ext . lnkmatrix== nothing
127127 return zero (Tv)
128128 else
129- return M . lnkmatrix[i,j]
129+ return ext . lnkmatrix[i,j]
130130 end
131131end
132132
@@ -135,20 +135,20 @@ $(SIGNATURES)
135135
136136Size of ExtendableSparseMatrix.
137137"""
138- Base. size (E :: ExtendableSparseMatrix ) = (E . cscmatrix. m, E . cscmatrix. n)
138+ Base. size (ext :: ExtendableSparseMatrix ) = (ext . cscmatrix. m, ext . cscmatrix. n)
139139
140140
141141"""
142142$(SIGNATURES)
143143
144144Number of nonzeros of ExtendableSparseMatrix.
145145"""
146- function SparseArrays. nnz (E :: ExtendableSparseMatrix )
146+ function SparseArrays. nnz (ext :: ExtendableSparseMatrix )
147147 ennz= 0
148- if E . lnkmatrix!= nothing
149- ennz= nnz (E . lnkmatrix)
148+ if ext . lnkmatrix!= nothing
149+ ennz= nnz (ext . lnkmatrix)
150150 end
151- return nnz (E . cscmatrix)+ ennz
151+ return nnz (ext . cscmatrix)+ ennz
152152end
153153
154154
@@ -254,111 +254,111 @@ end
254254$(SIGNATURES)
255255
256256If there are new entries in extension, create new CSC matrix using [`_splice`](@ref)
257- and reset extension.
257+ and reset linked list based extension.
258258"""
259- function flush! (M :: ExtendableSparseMatrix{Tv,Ti} ) where {Tv, Ti<: Integer }
260- if M . lnkmatrix!= nothing && nnz (M . lnkmatrix)> 0
261- M . cscmatrix= _splice (M . lnkmatrix,M . cscmatrix)
262- M . lnkmatrix= nothing
259+ function flush! (ext :: ExtendableSparseMatrix{Tv,Ti} ) where {Tv, Ti<: Integer }
260+ if ext . lnkmatrix!= nothing && nnz (ext . lnkmatrix)> 0
261+ ext . cscmatrix= _splice (ext . lnkmatrix,ext . cscmatrix)
262+ ext . lnkmatrix= nothing
263263 end
264- return M
264+ return ext
265265end
266266
267267
268268
269269"""
270270$(SIGNATURES)
271271
272- Flush and delegate to cscmatrix.
272+ [`flush!`](@ref) and return nonzeros in ext. cscmatrix.
273273"""
274- function SparseArrays. nonzeros (E :: ExtendableSparseMatrix )
275- @inbounds flush! (E )
276- return nonzeros (E . cscmatrix)
274+ function SparseArrays. nonzeros (ext :: ExtendableSparseMatrix )
275+ @inbounds flush! (ext )
276+ return nonzeros (ext . cscmatrix)
277277end
278278
279279
280280
281281"""
282282$(SIGNATURES)
283283
284- Flush and delegate to cscmatrix.
284+ [`flush!`](@ref) and return rowvals in ext. cscmatrix.
285285"""
286- function SparseArrays. rowvals (E :: ExtendableSparseMatrix )
287- @inbounds flush! (E )
288- return rowvals (E . cscmatrix)
286+ function SparseArrays. rowvals (ext :: ExtendableSparseMatrix )
287+ @inbounds flush! (ext )
288+ return rowvals (ext . cscmatrix)
289289end
290290
291291
292292"""
293293$(SIGNATURES)
294294
295- Flush and delegate to cscmatrix.
295+ [`flush!`](@ref) and return colptr of in ext. cscmatrix.
296296"""
297- function colptrs (E :: ExtendableSparseMatrix )
298- @inbounds flush! (E )
299- return E . cscmatrix. colptr
297+ function colptrs (ext :: ExtendableSparseMatrix )
298+ @inbounds flush! (ext )
299+ return ext . cscmatrix. colptr
300300end
301301
302302
303303"""
304304$(SIGNATURES)
305305
306- Flush and delegate to cscmatrix.
306+ [`flush!`](@ref) and return findnz(ext. cscmatrix) .
307307"""
308- function SparseArrays. findnz (E :: ExtendableSparseMatrix )
309- @inbounds flush! (E )
310- return findnz (E . cscmatrix)
308+ function SparseArrays. findnz (ext :: ExtendableSparseMatrix )
309+ @inbounds flush! (ext )
310+ return findnz (ext . cscmatrix)
311311end
312312
313313
314314"""
315315$(SIGNATURES)
316316
317- Delegating LU factorization.
317+ [`flush!`](@ref) and return LU factorization of ext.cscmatrix
318318"""
319- function LinearAlgebra. lu (E :: ExtendableSparseMatrix )
320- @inbounds flush! (E )
321- return LinearAlgebra. lu (E . cscmatrix)
319+ function LinearAlgebra. lu (ext :: ExtendableSparseMatrix )
320+ @inbounds flush! (ext )
321+ return LinearAlgebra. lu (ext . cscmatrix)
322322end
323323
324324"""
325325$(SIGNATURES)
326326
327- Delegating Matrix multiplication
327+ [`flush!`](@ref) and multiply with ext.cscmatrix
328328"""
329- function LinearAlgebra. mul! (r:: AbstractArray{T,1} where T, E :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,1} where T)
330- @inbounds flush! (E )
331- return LinearAlgebra. mul! (r,E . cscmatrix,x)
329+ function LinearAlgebra. mul! (r:: AbstractArray{T,1} where T, ext :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,1} where T)
330+ @inbounds flush! (ext )
331+ return LinearAlgebra. mul! (r,ext . cscmatrix,x)
332332end
333333
334334
335335"""
336336$(SIGNATURES)
337337
338- Delegating Matrix ldiv
338+ [`flush!`](@ref) and ldiv with ext.cscmatrix
339339"""
340- function LinearAlgebra. ldiv! (r:: AbstractArray{T,1} where T, E :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,1} where T)
341- @inbounds flush! (E )
342- return LinearAlgebra. ldiv! (r,E . cscmatrix,x)
340+ function LinearAlgebra. ldiv! (r:: AbstractArray{T,1} where T, ext :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,1} where T)
341+ @inbounds flush! (ext )
342+ return LinearAlgebra. ldiv! (r,ext . cscmatrix,x)
343343end
344344
345345"""
346346$(SIGNATURES)
347347
348- Delegating Matrix multiplication
348+ [`flush!`](@ref) and multiply with ext.cscmatrix
349349"""
350- function LinearAlgebra. mul! (r:: AbstractArray{T,2} where T, E :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,2} where T)
351- @inbounds flush! (E )
352- return LinearAlgebra. mul! (r,E . cscmatrix,x)
350+ function LinearAlgebra. mul! (r:: AbstractArray{T,2} where T, ext :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,2} where T)
351+ @inbounds flush! (ext )
352+ return LinearAlgebra. mul! (r,ext . cscmatrix,x)
353353end
354354
355355
356356"""
357357$(SIGNATURES)
358358
359- Delegating Matrix ldiv
359+ [`flush!`](@ref) and ldiv with ext.cscmatrix
360360"""
361- function LinearAlgebra. ldiv! (r:: AbstractArray{T,2} where T, E :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,2} where T)
362- @inbounds flush! (E )
363- return LinearAlgebra. ldiv! (r,E . cscmatrix,x)
361+ function LinearAlgebra. ldiv! (r:: AbstractArray{T,2} where T, ext :: ExtendableSparse.ExtendableSparseMatrix , x:: AbstractArray{T,2} where T)
362+ @inbounds flush! (ext )
363+ return LinearAlgebra. ldiv! (r,ext . cscmatrix,x)
364364end
0 commit comments