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


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