Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
document Upper/LowerTriangular
Browse files Browse the repository at this point in the history
and clarify that Symmetric/Hermitian are views as well

add references to Upper/LowerTriangular in the manual
  • Loading branch information
fredrikekre authored and DrTodd13 committed Jun 26, 2017
1 parent 0ea9bfd commit 2c448ec
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 32 deletions.
2 changes: 1 addition & 1 deletion base/linalg/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ end
chol(A) -> U
Compute the Cholesky factorization of a positive definite matrix `A`
and return the UpperTriangular matrix `U` such that `A = U'U`.
and return the [`UpperTriangular`](@ref) matrix `U` such that `A = U'U`.
# Example
Expand Down
6 changes: 4 additions & 2 deletions base/linalg/symmetric.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ end
"""
Symmetric(A, uplo=:U)
Construct a `Symmetric` matrix from the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of `A`.
Construct a `Symmetric` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`)
triangle of the matrix `A`.
# Example
Expand Down Expand Up @@ -49,7 +50,8 @@ end
"""
Hermitian(A, uplo=:U)
Construct a `Hermitian` matrix from the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of `A`.
Construct a `Hermitian` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`)
triangle of the matrix `A`.
# Example
Expand Down
45 changes: 45 additions & 0 deletions base/linalg/triangular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,51 @@ LowerTriangular(U::UpperTriangular) = throw(ArgumentError(
UpperTriangular(U::LowerTriangular) = throw(ArgumentError(
"cannot create an UpperTriangular matrix from a LowerTriangular input"))

"""
LowerTriangular(A::AbstractMatrix)
Construct a `LowerTriangular` view of the the matrix `A`.
# Example
```jldoctest
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Array{Float64,2}:
1.0 2.0 3.0
4.0 5.0 6.0
7.0 8.0 9.0
julia> LowerTriangular(A)
3×3 LowerTriangular{Float64,Array{Float64,2}}:
1.0 ⋅ ⋅
4.0 5.0 ⋅
7.0 8.0 9.0
```
"""
LowerTriangular
"""
UpperTriangular(A::AbstractMatrix)
Construct an `UpperTriangular` view of the the matrix `A`.
# Example
```jldoctest
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 9.0]
3×3 Array{Float64,2}:
1.0 2.0 3.0
4.0 5.0 6.0
7.0 8.0 9.0
julia> UpperTriangular(A)
3×3 UpperTriangular{Float64,Array{Float64,2}}:
1.0 2.0 3.0
⋅ 5.0 6.0
⋅ ⋅ 9.0
```
"""
UpperTriangular

imag(A::UpperTriangular) = UpperTriangular(imag(A.data))
imag(A::LowerTriangular) = LowerTriangular(imag(A.data))
imag(A::UnitLowerTriangular) = LowerTriangular(tril!(imag(A.data),-1))
Expand Down
58 changes: 29 additions & 29 deletions doc/src/manual/linear-algebra.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,29 @@ specialized routines that are specially developed for particular matrix types.
The following tables summarize the types of special matrices that have been implemented in Julia,
as well as whether hooks to various optimized methods for them in LAPACK are available.

| Type | Description |
|:------------------------ |:-------------------------------------------------------------------------------- |
| [`Hermitian`](@ref) | [Hermitian matrix](https://en.wikipedia.org/wiki/Hermitian_matrix) |
| `UpperTriangular` | Upper [triangular matrix](https://en.wikipedia.org/wiki/Triangular_matrix) |
| `LowerTriangular` | Lower [triangular matrix](https://en.wikipedia.org/wiki/Triangular_matrix) |
| [`Tridiagonal`](@ref) | [Tridiagonal matrix](https://en.wikipedia.org/wiki/Tridiagonal_matrix) |
| [`SymTridiagonal`](@ref) | Symmetric tridiagonal matrix |
| [`Bidiagonal`](@ref) | Upper/lower [bidiagonal matrix](https://en.wikipedia.org/wiki/Bidiagonal_matrix) |
| [`Diagonal`](@ref) | [Diagonal matrix](https://en.wikipedia.org/wiki/Diagonal_matrix) |
| `UniformScaling` | [Uniform scaling operator](https://en.wikipedia.org/wiki/Uniform_scaling) |
| Type | Description |
|:------------------------- |:-------------------------------------------------------------------------------- |
| [`Hermitian`](@ref) | [Hermitian matrix](https://en.wikipedia.org/wiki/Hermitian_matrix) |
| [`UpperTriangular`](@ref) | Upper [triangular matrix](https://en.wikipedia.org/wiki/Triangular_matrix) |
| [`LowerTriangular`](@ref) | Lower [triangular matrix](https://en.wikipedia.org/wiki/Triangular_matrix) |
| [`Tridiagonal`](@ref) | [Tridiagonal matrix](https://en.wikipedia.org/wiki/Tridiagonal_matrix) |
| [`SymTridiagonal`](@ref) | Symmetric tridiagonal matrix |
| [`Bidiagonal`](@ref) | Upper/lower [bidiagonal matrix](https://en.wikipedia.org/wiki/Bidiagonal_matrix) |
| [`Diagonal`](@ref) | [Diagonal matrix](https://en.wikipedia.org/wiki/Diagonal_matrix) |
| `UniformScaling` | [Uniform scaling operator](https://en.wikipedia.org/wiki/Uniform_scaling) |

### Elementary operations

| Matrix type | `+` | `-` | `*` | `\` | Other functions with optimized methods |
|:------------------------ |:--- |:--- |:--- |:--- |:------------------------------------------------------------------- |
| [`Hermitian`](@ref) |   |   |   | MV | [`inv()`](@ref), [`sqrtm()`](@ref), [`expm()`](@ref) |
| `UpperTriangular` |   |   | MV | MV | [`inv()`](@ref), [`det()`](@ref) |
| `LowerTriangular` |   |   | MV | MV | [`inv()`](@ref), [`det()`](@ref) |
| [`SymTridiagonal`](@ref) | M | M | MS | MV | [`eigmax()`](@ref), [`eigmin()`](@ref) |
| [`Tridiagonal`](@ref) | M | M | MS | MV |   |
| [`Bidiagonal`](@ref) | M | M | MS | MV |   |
| [`Diagonal`](@ref) | M | M | MV | MV | [`inv()`](@ref), [`det()`](@ref), [`logdet()`](@ref), [`/()`](@ref) |
| `UniformScaling` | M | M | MVS | MVS | [`/()`](@ref) |
| Matrix type | `+` | `-` | `*` | `\` | Other functions with optimized methods |
|:------------------------- |:--- |:--- |:--- |:--- |:------------------------------------------------------------------- |
| [`Hermitian`](@ref) |   |   |   | MV | [`inv()`](@ref), [`sqrtm()`](@ref), [`expm()`](@ref) |
| [`UpperTriangular`](@ref) |   |   | MV | MV | [`inv()`](@ref), [`det()`](@ref) |
| [`LowerTriangular`](@ref) |   |   | MV | MV | [`inv()`](@ref), [`det()`](@ref) |
| [`SymTridiagonal`](@ref) | M | M | MS | MV | [`eigmax()`](@ref), [`eigmin()`](@ref) |
| [`Tridiagonal`](@ref) | M | M | MS | MV |   |
| [`Bidiagonal`](@ref) | M | M | MS | MV |   |
| [`Diagonal`](@ref) | M | M | MV | MV | [`inv()`](@ref), [`det()`](@ref), [`logdet()`](@ref), [`/()`](@ref) |
| `UniformScaling` | M | M | MVS | MVS | [`/()`](@ref) |

Legend:

Expand All @@ -178,15 +178,15 @@ Legend:

### Matrix factorizations

| Matrix type | LAPACK | [`eig()`](@ref) | [`eigvals()`](@ref) | [`eigvecs()`](@ref) | [`svd()`](@ref) | [`svdvals()`](@ref) |
|:------------------------ |:------ |:--------------- |:------------------- |:------------------- |:--------------- |:------------------- |
| [`Hermitian`](@ref) | HE |   | ARI |   |   |   |
| `UpperTriangular` | TR | A | A | A |   |   |
| `LowerTriangular` | TR | A | A | A |   |   |
| [`SymTridiagonal`](@ref) | ST | A | ARI | AV |   |   |
| [`Tridiagonal`](@ref) | GT |   |   |   |   |   |
| [`Bidiagonal`](@ref) | BD |   |   |   | A | A |
| [`Diagonal`](@ref) | DI |   | A |   |   |   |
| Matrix type | LAPACK | [`eig()`](@ref) | [`eigvals()`](@ref) | [`eigvecs()`](@ref) | [`svd()`](@ref) | [`svdvals()`](@ref) |
|:------------------------- |:------ |:--------------- |:------------------- |:------------------- |:--------------- |:------------------- |
| [`Hermitian`](@ref) | HE |   | ARI |   |   |   |
| [`UpperTriangular`](@ref) | TR | A | A | A |   |   |
| [`LowerTriangular`](@ref) | TR | A | A | A |   |   |
| [`SymTridiagonal`](@ref) | ST | A | ARI | AV |   |   |
| [`Tridiagonal`](@ref) | GT |   |   |   |   |   |
| [`Bidiagonal`](@ref) | BD |   |   |   | A | A |
| [`Diagonal`](@ref) | DI |   | A |   |   |   |

Legend:

Expand Down
2 changes: 2 additions & 0 deletions doc/src/stdlib/linalg.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Base.LinAlg.SymTridiagonal
Base.LinAlg.Tridiagonal
Base.LinAlg.Symmetric
Base.LinAlg.Hermitian
Base.LinAlg.LowerTriangular
Base.LinAlg.UpperTriangular
Base.LinAlg.lu
Base.LinAlg.lufact
Base.LinAlg.lufact!
Expand Down

0 comments on commit 2c448ec

Please sign in to comment.