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


Julia SparseArrays.permute用法及代码示例


用法:

permute(A::AbstractSparseMatrixCSC{Tv,Ti}, p::AbstractVector{<:Integer},
        q::AbstractVector{<:Integer}) where {Tv,Ti}

双边置换 A ,返回 PAQ ( A[p,q] )。 Column-permutation q 的长度必须与 A 的列数 ( length(q) == size(A, 2) ) 匹配。 Row-permutation p 的长度必须与 A 的行数 ( length(p) == size(A, 1) ) 匹配。

有关专家驱动程序和其他信息,请参阅 permute!

例子

julia> A = spdiagm(0 => [1, 2, 3, 4], 1 => [5, 6, 7])
4×4 SparseMatrixCSC{Int64, Int64} with 7 stored entries:
 1  5  ⋅  ⋅
 ⋅  2  6  ⋅
 ⋅  ⋅  3  7
 ⋅  ⋅  ⋅  4

julia> permute(A, [4, 3, 2, 1], [1, 2, 3, 4])
4×4 SparseMatrixCSC{Int64, Int64} with 7 stored entries:
 ⋅  ⋅  ⋅  4
 ⋅  ⋅  3  7
 ⋅  2  6  ⋅
 1  5  ⋅  ⋅

julia> permute(A, [1, 2, 3, 4], [4, 3, 2, 1])
4×4 SparseMatrixCSC{Int64, Int64} with 7 stored entries:
 ⋅  ⋅  5  1
 ⋅  6  2  ⋅
 7  3  ⋅  ⋅
 4  ⋅  ⋅  ⋅

相关用法


注:本文由纯净天空筛选整理自julialang.org 大神的英文原创作品 SparseArrays.permute — Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。