@@ -555,6 +555,14 @@ copy(S::AbstractSparseMatrixCSC) =
555555 SparseMatrixCSC (size (S, 1 ), size (S, 2 ), copy (getcolptr (S)), copy (rowvals (S)), copy (nonzeros (S)))
556556copy (S:: FixedSparseCSC ) =
557557 FixedSparseCSC (size (S, 1 ), size (S, 2 ), getcolptr (S), rowvals (S), copy (nonzeros (S)))
558+ function copyto! (A:: FixedSparseCSC , B:: FixedSparseCSC )
559+ size (A) == size (B) || throw (DimensionMismatch (" cannot copy sparse matrix with different dimensions into FixedSparseCSC" ))
560+ nnz (A) == nnz (B) || throw (ArgumentError (" cannot change fixed sparse structure via copyto!" ))
561+ copyto! (parent (getcolptr (A)), getcolptr (B))
562+ copyto! (parent (rowvals (A)), rowvals (B))
563+ copyto! (nonzeros (A), nonzeros (B))
564+ return A
565+ end
558566function copyto! (A:: AbstractSparseMatrixCSC , B:: AbstractSparseMatrixCSC )
559567 # If the two matrices have the same length then all the
560568 # elements in A will be overwritten.
@@ -712,6 +720,10 @@ uninitialized values for the nonzero locations.
712720similar (S:: AbstractSparseMatrixCSC{<:Any,Ti} , :: Type{TvNew} ) where {Ti,TvNew} =
713721 @if_move_fixed S _sparsesimilar (S, TvNew, Ti)
714722
723+ similar (S:: FixedSparseCSC{<:Any,Ti} , :: Type{TvNew} , dims:: Dims{2} ) where {Ti,TvNew} =
724+ dims == size (S) ? move_fixed (_sparsesimilar (S, TvNew, Ti)) :
725+ move_fixed (_sparsesimilar (S, TvNew, Ti, dims))
726+
715727similar (S:: AbstractSparseMatrixCSC{<:Any,Ti} , :: Type{TvNew} , dims:: Union{Dims{1},Dims{2}} ) where {Ti,TvNew} =
716728 @if_move_fixed S _sparsesimilar (S, TvNew, Ti, dims)
717729
@@ -1008,6 +1020,7 @@ julia> sparse(A)
10081020sparse (A:: AbstractMatrix{Tv} ) where {Tv} = convert (SparseMatrixCSC{Tv}, A)
10091021
10101022sparse (S:: AbstractSparseMatrixCSC ) = copy (S)
1023+ sparse (S:: FixedSparseCSC ) = SparseMatrixCSC (S)
10111024
10121025sparse (Q:: AbstractQ ) = SparseMatrixCSC (Q)
10131026
0 commit comments