Skip to content

Commit 8fc4145

Browse files
authored
Merge pull request #17020 from JuliaLang/ksh/bidiagdoc
Added type info to function sigs in Bidiagonal
2 parents dc61772 + 15366ec commit 8fc4145

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

base/linalg/bidiag.jl

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,41 @@ type Bidiagonal{T} <: AbstractMatrix{T}
1313
end
1414
end
1515
"""
16-
Bidiagonal(dv, ev, isupper)
16+
Bidiagonal(dv, ev, isupper::Bool)
1717
1818
Constructs an upper (`isupper=true`) or lower (`isupper=false`) bidiagonal matrix using the
1919
given diagonal (`dv`) and off-diagonal (`ev`) vectors. The result is of type `Bidiagonal`
2020
and provides efficient specialized linear solvers, but may be converted into a regular
2121
matrix with [`full`](:func:`full`). `ev`'s length must be one less than the length of `dv`.
22+
23+
**Example**
24+
25+
```julia
26+
dv = rand(5)
27+
ev = rand(4)
28+
Bu = Bidiagonal(dv, ev, true) #e is on the first superdiagonal
29+
Bl = Bidiagonal(dv, ev, false) #e is on the first subdiagonal
30+
```
2231
"""
2332
Bidiagonal{T}(dv::AbstractVector{T}, ev::AbstractVector{T}, isupper::Bool) = Bidiagonal{T}(collect(dv), collect(ev), isupper)
2433
Bidiagonal(dv::AbstractVector, ev::AbstractVector) = throw(ArgumentError("did you want an upper or lower Bidiagonal? Try again with an additional true (upper) or false (lower) argument."))
2534

2635
"""
27-
Bidiagonal(dv, ev, uplo)
36+
Bidiagonal(dv, ev, uplo::Char)
2837
2938
Constructs an upper (`uplo='U'`) or lower (`uplo='L'`) bidiagonal matrix using the
3039
given diagonal (`dv`) and off-diagonal (`ev`) vectors. The result is of type `Bidiagonal`
3140
and provides efficient specialized linear solvers, but may be converted into a regular
3241
matrix with [`full`](:func:`full`). `ev`'s length must be one less than the length of `dv`.
42+
43+
**Example**
44+
45+
```julia
46+
dv = rand(5)
47+
ev = rand(4)
48+
Bu = Bidiagonal(dv, ev, 'U') #e is on the first superdiagonal
49+
Bl = Bidiagonal(dv, ev, 'L') #e is on the first subdiagonal
50+
```
3351
"""
3452
#Convert from BLAS uplo flag to boolean internal
3553
Bidiagonal(dv::AbstractVector, ev::AbstractVector, uplo::Char) = begin
@@ -48,10 +66,18 @@ function Bidiagonal{Td,Te}(dv::AbstractVector{Td}, ev::AbstractVector{Te}, isupp
4866
end
4967

5068
"""
51-
Bidiagonal(A, uplo)
69+
Bidiagonal(A, isupper::Bool)
5270
5371
Construct a `Bidiagonal` matrix from the main diagonal of `A` and
5472
its first super- (if `isupper=true`) or sub-diagonal (if `isupper=false`).
73+
74+
**Example**
75+
76+
```julia
77+
A = rand(5,5)
78+
Bu = Bidiagonal(A, true) #contains the main diagonal and first superdiagonal of A
79+
Bl = Bidiagonal(A, false) #contains the main diagonal and first subdiagonal of A
80+
```
5581
"""
5682
Bidiagonal(A::AbstractMatrix, isupper::Bool)=Bidiagonal(diag(A), diag(A, isupper?1:-1), isupper)
5783

doc/stdlib/linalg.rst

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,50 @@ Linear algebra functions in Julia are largely implemented by calling functions f
7171
7272
Constructs a matrix with ``V`` as its diagonal.
7373

74-
.. function:: Bidiagonal(dv, ev, isupper)
74+
.. function:: Bidiagonal(dv, ev, isupper::Bool)
7575

7676
.. Docstring generated from Julia source
7777
7878
Constructs an upper (``isupper=true``\ ) or lower (``isupper=false``\ ) bidiagonal matrix using the given diagonal (``dv``\ ) and off-diagonal (``ev``\ ) vectors. The result is of type ``Bidiagonal`` and provides efficient specialized linear solvers, but may be converted into a regular matrix with :func:`full`\ . ``ev``\ 's length must be one less than the length of ``dv``\ .
7979

80-
.. function:: Bidiagonal(dv, ev, uplo)
80+
**Example**
81+
82+
.. code-block:: julia
83+
84+
dv = rand(5)
85+
ev = rand(4)
86+
Bu = Bidiagonal(dv, ev, true) #e is on the first superdiagonal
87+
Bl = Bidiagonal(dv, ev, false) #e is on the first subdiagonal
88+
89+
.. function:: Bidiagonal(dv, ev, uplo::Char)
8190

8291
.. Docstring generated from Julia source
8392
8493
Constructs an upper (``uplo='U'``\ ) or lower (``uplo='L'``\ ) bidiagonal matrix using the given diagonal (``dv``\ ) and off-diagonal (``ev``\ ) vectors. The result is of type ``Bidiagonal`` and provides efficient specialized linear solvers, but may be converted into a regular matrix with :func:`full`\ . ``ev``\ 's length must be one less than the length of ``dv``\ .
8594

86-
.. function:: Bidiagonal(A, uplo)
95+
**Example**
96+
97+
.. code-block:: julia
98+
99+
dv = rand(5)
100+
ev = rand(4)
101+
Bu = Bidiagonal(dv, ev, 'U') #e is on the first superdiagonal
102+
Bl = Bidiagonal(dv, ev, 'L') #e is on the first subdiagonal
103+
104+
.. function:: Bidiagonal(A, isupper::Bool)
87105

88106
.. Docstring generated from Julia source
89107
90108
Construct a ``Bidiagonal`` matrix from the main diagonal of ``A`` and its first super- (if ``isupper=true``\ ) or sub-diagonal (if ``isupper=false``\ ).
91109

110+
**Example**
111+
112+
.. code-block:: julia
113+
114+
A = rand(5,5)
115+
Bu = Bidiagonal(A, true) #contains the main diagonal and first superdiagonal of A
116+
Bl = Bidiagonal(A, false) #contains the main diagonal and first subdiagonal of A
117+
92118
.. function:: SymTridiagonal(dv, ev)
93119

94120
.. Docstring generated from Julia source
@@ -918,12 +944,6 @@ Linear algebra functions in Julia are largely implemented by calling functions f
918944
919945
Construct a tridiagonal matrix from the first subdiagonal, diagonal, and first superdiagonal, respectively. The result is of type ``Tridiagonal`` and provides efficient specialized linear solvers, but may be converted into a regular matrix with :func:`full`\ . The lengths of ``dl`` and ``du`` must be one less than the length of ``d``\ .
920946

921-
.. function:: Bidiagonal(dv, ev, isupper)
922-
923-
.. Docstring generated from Julia source
924-
925-
Constructs an upper (``isupper=true``\ ) or lower (``isupper=false``\ ) bidiagonal matrix using the given diagonal (``dv``\ ) and off-diagonal (``ev``\ ) vectors. The result is of type ``Bidiagonal`` and provides efficient specialized linear solvers, but may be converted into a regular matrix with :func:`full`\ . ``ev``\ 's length must be one less than the length of ``dv``\ .
926-
927947
.. function:: rank(M)
928948

929949
.. Docstring generated from Julia source

0 commit comments

Comments
 (0)