Skip to content

Commit 4ec3d99

Browse files
committed
Public function to access the uplo for Symmetric/Hermitian
1 parent 98723df commit 4ec3d99

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/LinearAlgebra.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public AbstractTriangular,
181181
zeroslike,
182182
matprod_dest,
183183
fillstored!,
184-
fillband!
184+
fillband!,
185+
uplo
185186

186187
const BlasFloat = Union{Float64,Float32,ComplexF64,ComplexF32}
187188
const BlasReal = Union{Float64,Float32}

src/symmetric.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,33 @@ nonhermitianwrappertype(::SymSymTri{<:Real}) = Symmetric
237237
nonhermitianwrappertype(::Hermitian{<:Real}) = Symmetric
238238
nonhermitianwrappertype(::Hermitian) = identity
239239

240+
"""
241+
LinearAlgebra.uplo(S::Union{Symmetric, Hermitian})::Char
242+
243+
Return a `Char` corresponding to the stored triangular half in the matrix `S`,
244+
that is, the elements are common between `S` and `parent(S)` for that triangular half.
245+
246+
# Example
247+
```jldoctest
248+
julia> S = Symmetric([1 2; 3 4])
249+
2×2 Symmetric{Int64, Matrix{Int64}}:
250+
1 2
251+
2 4
252+
253+
julia> LinearAlgebra.uplo(S)
254+
'U': ASCII/Unicode U+0055 (category Lu: Letter, uppercase)
255+
256+
julia> H = Hermitian([1 2; 3 4], :L)
257+
2×2 Hermitian{Int64, Matrix{Int64}}:
258+
1 3
259+
3 4
260+
261+
julia> LinearAlgebra.uplo(H)
262+
'L': ASCII/Unicode U+004C (category Lu: Letter, uppercase)
263+
```
264+
"""
265+
uplo(S::HermOrSym) = S.uplo
266+
240267
size(A::HermOrSym) = size(A.data)
241268
axes(A::HermOrSym) = axes(A.data)
242269
@inline function Base.isassigned(A::HermOrSym, i::Int, j::Int)

0 commit comments

Comments
 (0)