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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。