當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Julia SparseArrays.dropzeros用法及代碼示例


用法一

dropzeros(A::AbstractSparseMatrixCSC;)

生成A 的副本並從該副本中刪除存儲的數字零。

有關就地版本和算法信息,請參閱 dropzeros!

例子

julia> A = sparse([1, 2, 3], [1, 2, 3], [1.0, 0.0, 1.0])
3×3 SparseMatrixCSC{Float64, Int64} with 3 stored entries:
 1.0   ⋅    ⋅
  ⋅   0.0   ⋅
  ⋅    ⋅   1.0

julia> dropzeros(A)
3×3 SparseMatrixCSC{Float64, Int64} with 2 stored entries:
 1.0   ⋅    ⋅
  ⋅    ⋅    ⋅
  ⋅    ⋅   1.0

用法二

dropzeros(x::SparseVector)

生成x 的副本並從該副本中刪除數字零。

有關就地版本和算法信息,請參閱 dropzeros!

例子

julia> A = sparsevec([1, 2, 3], [1.0, 0.0, 1.0])
3-element SparseVector{Float64, Int64} with 3 stored entries:
  [1]  =  1.0
  [2]  =  0.0
  [3]  =  1.0

julia> dropzeros(A)
3-element SparseVector{Float64, Int64} with 2 stored entries:
  [1]  =  1.0
  [3]  =  1.0

相關用法


注:本文由純淨天空篩選整理自julialang.org 大神的英文原創作品 SparseArrays.dropzeros — Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。