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


Julia LinearAlgebra.Bidiagonal用法及代碼示例


用法一

Bidiagonal(dv::V, ev::V, uplo::Symbol) where V <: AbstractVector

使用給定的對角線 (dv) 和 off-diagonal (ev) 向量構造一個上 (uplo=:U) 或下 (uplo=:L) 雙對角矩陣。結果是類型Bidiagonal 並提供高效的專用線性求解器,但可以使用 convert(Array, _) (或簡稱Array(_))轉換為規則矩陣。 ev 的長度必須比 dv 的長度小一。

例子

julia> dv = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4

julia> ev = [7, 8, 9]
3-element Vector{Int64}:
 7
 8
 9

julia> Bu = Bidiagonal(dv, ev, :U) # ev is on the first superdiagonal
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  7  ⋅  ⋅
 ⋅  2  8  ⋅
 ⋅  ⋅  3  9
 ⋅  ⋅  ⋅  4

julia> Bl = Bidiagonal(dv, ev, :L) # ev is on the first subdiagonal
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  ⋅  ⋅  ⋅
 7  2  ⋅  ⋅
 ⋅  8  3  ⋅
 ⋅  ⋅  9  4

用法二

Bidiagonal(A, uplo::Symbol)

A 的主對角線及其第一個超(如果是uplo=:U)或sub-diagonal(如果是uplo=:L)構造一個Bidiagonal 矩陣。

例子

julia> A = [1 1 1 1; 2 2 2 2; 3 3 3 3; 4 4 4 4]
4×4 Matrix{Int64}:
 1  1  1  1
 2  2  2  2
 3  3  3  3
 4  4  4  4

julia> Bidiagonal(A, :U) # contains the main diagonal and first superdiagonal of A
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  1  ⋅  ⋅
 ⋅  2  2  ⋅
 ⋅  ⋅  3  3
 ⋅  ⋅  ⋅  4

julia> Bidiagonal(A, :L) # contains the main diagonal and first subdiagonal of A
4×4 Bidiagonal{Int64, Vector{Int64}}:
 1  ⋅  ⋅  ⋅
 2  2  ⋅  ⋅
 ⋅  3  3  ⋅
 ⋅  ⋅  4  4

相關用法


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