Skip to content

Commit

Permalink
Use jldoctest in docstrings (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffFessler committed Nov 2, 2022
1 parent 2c38ee1 commit bb6fd74
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/frobenius.jl
Expand Up @@ -55,7 +55,7 @@ julia> F*F # Special form preserved if the same column has the subdiagonals
0 0 12 0 0 1
julia> F*Frobenius(2, 2:5) # Promotes to Matrix
6×6 Matrix{Float64}:
6×6 Matrix{Int64}:
1 0 0 0 0 0
0 1 0 0 0 0
0 2 1 0 0 0
Expand Down
23 changes: 13 additions & 10 deletions src/hilbert.jl
Expand Up @@ -4,33 +4,36 @@
export Hilbert, InverseHilbert

"""
[`Hilbert` matrix](http://en.wikipedia.org/wiki/Hilbert_matrix)
Hilbert(m [,n])
```julia
julia> A=Hilbert(5)
Hilbert{Rational{Int64}}(5,5)
Construct `m × m` or `m × n`
[`Hilbert` matrix](http://en.wikipedia.org/wiki/Hilbert_matrix)
from its specified dimensions,
where element `i,j` equal to `1 / (i+j-1)`.
julia> Matrix(A)
5x5 Array{Rational{Int64},2}:
```jldoctest hilbert1
julia> A = Hilbert(5)
5×5 Hilbert{Rational{Int64}}:
1//1 1//2 1//3 1//4 1//5
1//2 1//3 1//4 1//5 1//6
1//3 1//4 1//5 1//6 1//7
1//4 1//5 1//6 1//7 1//8
1//5 1//6 1//7 1//8 1//9
julia> Matrix(Hilbert(5))
5x5 Array{Rational{Int64},2}:
julia> Matrix(A)
5×5 Matrix{Rational{Int64}}:
1//1 1//2 1//3 1//4 1//5
1//2 1//3 1//4 1//5 1//6
1//3 1//4 1//5 1//6 1//7
1//4 1//5 1//6 1//7 1//8
1//5 1//6 1//7 1//8 1//9
```
Inverses are also integer matrices:
```julia
```jldoctest hilbert1
julia> inv(A)
5x5 Array{Rational{Int64},2}:
5×5 InverseHilbert{Rational{Int64}}:
25//1 -300//1 1050//1 -1400//1 630//1
-300//1 4800//1 -18900//1 26880//1 -12600//1
1050//1 -18900//1 79380//1 -117600//1 56700//1
Expand Down
14 changes: 7 additions & 7 deletions src/kahan.jl
Expand Up @@ -5,25 +5,25 @@ export Kahan
"""
[`Kahan` matrix](http://math.nist.gov/MatrixMarket/data/MMDELI/kahan/kahan.html)
```julia
julia> A=Kahan(5,5,1,35)
5×5 Kahan{Int64,Int64}:
```jldoctest
julia> A = Kahan(5,5,1,35)
5×5 Kahan{Int64, Int64}:
1.0 -0.540302 -0.540302 -0.540302 -0.540302
0.0 0.841471 -0.454649 -0.454649 -0.454649
0.0 0.0 0.708073 -0.382574 -0.382574
0.0 0.0 0.0 0.595823 -0.321925
0.0 0.0 0.0 0.0 0.501368
julia> A=Kahan(5,3,0.5,0)
5×3 Kahan{Float64,Int64}:
julia> A = Kahan(5,3,0.5,0)
5×3 Kahan{Float64, Int64}:
1.0 -0.877583 -0.877583
0.0 0.479426 -0.420735
0.0 0.0 0.229849
0.0 0.0 0.0
0.0 0.0 0.0
julia> A=Kahan(3,5,0.5,1e-3)
3×5 Kahan{Float64,Float64}:
julia> A = Kahan(3,5,0.5,1e-3)
3×5 Kahan{Float64, Float64}:
1.0 -0.877583 -0.877583 -0.877583 -0.877583
0.0 0.479426 -0.420735 -0.420735 -0.420735
0.0 0.0 0.229849 -0.201711 -0.201711
Expand Down

0 comments on commit bb6fd74

Please sign in to comment.