@@ -44,6 +44,7 @@ function ExtendableSparseMatrix(valuetype::Type{Tv},indextype::Type{Ti},m, n) wh
4444end
4545
4646ExtendableSparseMatrix (valuetype:: Type{Tv} ,m, n) where {Tv}= ExtendableSparseMatrix {Tv,Int} (m,n)
47+
4748ExtendableSparseMatrix (m, n)= ExtendableSparseMatrix {Float64,Int} (m,n)
4849
4950"""
@@ -55,6 +56,59 @@ function ExtendableSparseMatrix(csc::SparseMatrixCSC{Tv,Ti}) where{Tv,Ti<:Intege
5556 return ExtendableSparseMatrix {Tv,Ti} (csc, nothing , phash (csc))
5657end
5758
59+
60+ """
61+ $(SIGNATURES)
62+
63+ Create ExtendableSparseMatrix from Diagonal
64+ """
65+ ExtendableSparseMatrix (D:: Diagonal )= ExtendableSparseMatrix (sparse (D))
66+
67+ """
68+ $(SIGNATURES)
69+
70+ Create ExtendableSparseMatrix from AbstractMatrix, dropping all zero entries.
71+ This is the equivalent to `sparse(A)`.
72+ """
73+ ExtendableSparseMatrix (A:: AbstractMatrix )= ExtendableSparseMatrix (sparse (A))
74+
75+ """
76+ ExtendableSparseMatrix(I,J,V)
77+ ExtendableSparseMatrix(I,J,V,m,n)
78+ ExtendableSparseMatrix(I,J,V,combine::Function)
79+ ExtendableSparseMatrix(I,J,V,m,n,combine::Function)
80+
81+ Create ExtendableSparseMatrix from triplet (COO) data.
82+ """
83+ ExtendableSparseMatrix (I,J,V:: AbstractVector )= ExtendableSparseMatrix (sparse (I,J,V))
84+ ExtendableSparseMatrix (I,J,V:: AbstractVector ,m,n)= ExtendableSparseMatrix (sparse (I,J,V,m,n))
85+ ExtendableSparseMatrix (I,J,V:: AbstractVector ,combine:: Function )= ExtendableSparseMatrix (sparse (I,J,V,combine))
86+ ExtendableSparseMatrix (I,J,V:: AbstractVector ,m,n,combine:: Function )= ExtendableSparseMatrix (sparse (I,J,V,m,n,combine))
87+
88+
89+ # THese are probably too much...
90+ # function Base.transpose(A::ExtendableSparseMatrix)
91+ # flush!(A)
92+ # ExtendableSparseMatrix(Base.transpose(sparse(A)))
93+ # end
94+ # function Base.adjoint(A::ExtendableSparseMatrix)
95+ # flush!(A)
96+ # ExtendableSparseMatrix(Base.adjoint(sparse(A)))
97+ # end
98+ # function SparseArrays.sparse(text::LinearAlgebra.Transpose{Tv,ExtendableSparseMatrix{Tv,Ti}}) where {Tv,Ti}
99+ # transpose(sparse(parent(text)))
100+ # end
101+
102+ """
103+ $(SIGNATURES)
104+
105+ Create SparseMatrixCSC from ExtendableSparseMatrix
106+ """
107+ function SparseArrays. sparse (A:: ExtendableSparseMatrix )
108+ flush! (A)
109+ A. cscmatrix
110+ end
111+
58112"""
59113$(SIGNATURES)
60114
@@ -211,7 +265,7 @@ $(SIGNATURES)
211265[`flush!`](@ref) and return number of nonzeros in ext.cscmatrix.
212266"""
213267function SparseArrays. nnz (ext:: ExtendableSparseMatrix )
214- @inbounds flush! (ext)
268+ flush! (ext)
215269 return nnz (ext. cscmatrix)
216270end
217271
@@ -222,7 +276,7 @@ $(SIGNATURES)
222276[`flush!`](@ref) and return nonzeros in ext.cscmatrix.
223277"""
224278function SparseArrays. nonzeros (ext:: ExtendableSparseMatrix )
225- @inbounds flush! (ext)
279+ flush! (ext)
226280 return nonzeros (ext. cscmatrix)
227281end
228282
@@ -234,7 +288,7 @@ $(SIGNATURES)
234288[`flush!`](@ref) and return rowvals in ext.cscmatrix.
235289"""
236290function SparseArrays. rowvals (ext:: ExtendableSparseMatrix )
237- @inbounds flush! (ext)
291+ flush! (ext)
238292 rowvals (ext. cscmatrix)
239293end
240294
@@ -244,13 +298,16 @@ function SparseArrays.getrowval(S::ExtendableSparseMatrix)
244298end
245299
246300
301+
302+
303+
247304"""
248305$(SIGNATURES)
249306
250307[`flush!`](@ref) and return colptr of in ext.cscmatrix.
251308"""
252309function SparseArrays. getcolptr (ext:: ExtendableSparseMatrix )
253- @inbounds flush! (ext)
310+ flush! (ext)
254311 return ext. cscmatrix. colptr
255312end
256313
@@ -261,7 +318,7 @@ $(SIGNATURES)
261318[`flush!`](@ref) and return findnz(ext.cscmatrix).
262319"""
263320function SparseArrays. findnz (ext:: ExtendableSparseMatrix )
264- @inbounds flush! (ext)
321+ flush! (ext)
265322 return findnz (ext. cscmatrix)
266323end
267324
@@ -334,7 +391,7 @@ $(SIGNATURES)
334391[`flush!`](@ref) and ldiv with ext.cscmatrix
335392"""
336393function LinearAlgebra. ldiv! (r, ext:: ExtendableSparse.ExtendableSparseMatrix , x)
337- @inbounds flush! (ext)
394+ flush! (ext)
338395 return LinearAlgebra. ldiv! (r,ext. cscmatrix,x)
339396end
340397
@@ -344,7 +401,7 @@ $(SIGNATURES)
344401[`flush!`](@ref) and multiply with ext.cscmatrix
345402"""
346403function LinearAlgebra. mul! (r,ext:: ExtendableSparse.ExtendableSparseMatrix , x)
347- @inbounds flush! (ext)
404+ flush! (ext)
348405 return LinearAlgebra. mul! (r,ext. cscmatrix,x)
349406end
350407
@@ -355,7 +412,7 @@ $(SIGNATURES)
355412[`flush!`](@ref) and calculate norm from cscmatrix
356413"""
357414function LinearAlgebra. norm (A:: ExtendableSparseMatrix , p:: Real = 2 )
358- @inbounds flush! (A)
415+ flush! (A)
359416 return LinearAlgebra. norm (A. cscmatrix,p)
360417end
361418
@@ -365,7 +422,7 @@ $(SIGNATURES)
365422[`flush!`](@ref) and calculate opnorm from cscmatrix
366423"""
367424function LinearAlgebra. opnorm (A:: ExtendableSparseMatrix , p:: Real = 2 )
368- @inbounds flush! (A)
425+ flush! (A)
369426 return LinearAlgebra. opnorm (A. cscmatrix,p)
370427end
371428
@@ -375,7 +432,7 @@ $(SIGNATURES)
375432[`flush!`](@ref) and calculate cond from cscmatrix
376433"""
377434function LinearAlgebra. cond (A:: ExtendableSparseMatrix , p:: Real = 2 )
378- @inbounds flush! (A)
435+ flush! (A)
379436 return LinearAlgebra. cond (A. cscmatrix,p)
380437end
381438
@@ -385,7 +442,7 @@ $(SIGNATURES)
385442[`flush!`](@ref) and check for symmetry of cscmatrix
386443"""
387444function LinearAlgebra. issymmetric (A:: ExtendableSparseMatrix )
388- @inbounds flush! (A)
445+ flush! (A)
389446 return LinearAlgebra. issymmetric (A. cscmatrix)
390447end
391448
@@ -397,17 +454,53 @@ $(SIGNATURES)
397454Add SparseMatrixCSC matrix and [`ExtendableSparseMatrix`](@ref) ext.
398455"""
399456function Base.:+ (ext:: ExtendableSparseMatrix ,csc:: SparseMatrixCSC )
400- @inbounds flush! (ext)
457+ flush! (ext)
401458 return ext. cscmatrix+ csc
402459end
403460
461+ function Base.:+ (A:: ExtendableSparseMatrix ,B:: ExtendableSparseMatrix )
462+ flush! (A)
463+ flush! (B)
464+ return ExtendableSparseMatrix (A. cscmatrix+ B. cscmatrix)
465+ end
466+
467+ function Base.:- (A:: ExtendableSparseMatrix ,B:: ExtendableSparseMatrix )
468+ flush! (A)
469+ flush! (B)
470+ return ExtendableSparseMatrix (A. cscmatrix- B. cscmatrix)
471+ end
472+
473+
474+ function Base.:* (A:: ExtendableSparseMatrix ,B:: ExtendableSparseMatrix )
475+ flush! (A)
476+ flush! (B)
477+ return ExtendableSparseMatrix (A. cscmatrix* B. cscmatrix)
478+ end
479+
480+ """
481+ $(SIGNATURES)
482+ """
483+ function Base.:* (d:: Diagonal ,ext:: ExtendableSparseMatrix )
484+ flush! (ext)
485+ return ExtendableSparseMatrix (d* ext. cscmatrix)
486+ end
487+
488+ """
489+ $(SIGNATURES)
490+ """
491+ function Base.:* (ext:: ExtendableSparseMatrix ,d:: Diagonal )
492+ flush! (ext)
493+ return ExtendableSparseMatrix (ext. cscmatrix* d)
494+ end
495+
496+
404497"""
405498$(SIGNATURES)
406499
407500Subtract SparseMatrixCSC matrix from [`ExtendableSparseMatrix`](@ref) ext.
408501"""
409502function Base.:- (ext:: ExtendableSparseMatrix ,csc:: SparseMatrixCSC )
410- @inbounds flush! (ext)
503+ flush! (ext)
411504 return ext. cscmatrix- csc
412505end
413506
@@ -417,7 +510,7 @@ $(SIGNATURES)
417510Subtract [`ExtendableSparseMatrix`](@ref) ext from SparseMatrixCSC.
418511"""
419512function Base.:- (csc:: SparseMatrixCSC ,ext:: ExtendableSparseMatrix )
420- @inbounds flush! (ext)
513+ flush! (ext)
421514 return csc - ext. cscmatrix
422515end
423516
@@ -426,17 +519,10 @@ end
426519$(SIGNATURES)
427520"""
428521function SparseArrays. dropzeros! (ext:: ExtendableSparseMatrix )
429- @inbounds flush! (ext)
522+ flush! (ext)
430523 dropzeros! (ext. cscmatrix)
431524end
432525
433- """
434- $(SIGNATURES)
435- """
436- function Base.:* (d:: Diagonal ,ext:: ExtendableSparseMatrix )
437- @inbounds flush! (ext)
438- return ExtendableSparseMatrix (d* ext. cscmatrix)
439- end
440526
441527"""
442528$(SIGNATURES)
0 commit comments