当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。