From 633477485f597ffdf65c6777e411e04255208f36 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Wed, 2 Nov 2022 17:44:24 -0400 Subject: [PATCH] Use jldoctest in docstrings --- src/frobenius.jl | 2 +- src/hilbert.jl | 23 +++++++++++++---------- src/kahan.jl | 14 +++++++------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/frobenius.jl b/src/frobenius.jl index 026ce33..24f9f02 100644 --- a/src/frobenius.jl +++ b/src/frobenius.jl @@ -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 diff --git a/src/hilbert.jl b/src/hilbert.jl index f46b047..2582f62 100644 --- a/src/hilbert.jl +++ b/src/hilbert.jl @@ -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 diff --git a/src/kahan.jl b/src/kahan.jl index 6e4ec22..aac52fa 100644 --- a/src/kahan.jl +++ b/src/kahan.jl @@ -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