Skip to content

Commit

Permalink
More examples for linalg (#24824)
Browse files Browse the repository at this point in the history
* Examples for RowVector

* Update example and add which example for eigs
  • Loading branch information
kshyatt authored and fredrikekre committed Nov 29, 2017
1 parent 0be3960 commit 710a3d8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
42 changes: 42 additions & 0 deletions base/linalg/rowvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ By convention, a vector can be multiplied by a matrix on its left (`A * v`) wher
vector can be multiplied by a matrix on its right (such that `v.' * A = (A.' * v).'`). It
differs from a `1×n`-sized matrix by the facts that its transpose returns a vector and the
inner product `v1.' * v2` returns a scalar, but will otherwise behave similarly.
# Examples
```jldoctest
julia> a = [1; 2; 3; 4]
4-element Array{Int64,1}:
1
2
3
4
julia> RowVector(a)
1×4 RowVector{Int64,Array{Int64,1}}:
1 2 3 4
julia> a.'
1×4 RowVector{Int64,Array{Int64,1}}:
1 2 3 4
julia> a.'[3]
3
julia> a.'[1,3]
3
julia> a.'[3,1]
ERROR: BoundsError: attempt to access 1×4 RowVector{Int64,Array{Int64,1}} at index [3, 1]
[...]
julia> a.'*a
30
julia> B = [1 2; 3 4; 5 6; 7 8]
4×2 Array{Int64,2}:
1 2
3 4
5 6
7 8
julia> a.'*B
1×2 RowVector{Int64,Array{Int64,1}}:
50 60
```
"""
struct RowVector{T,V<:AbstractVector} <: AbstractMatrix{T}
vec::V
Expand Down
9 changes: 9 additions & 0 deletions stdlib/IterativeEigenSolvers/src/IterativeEigenSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ final residual vector `resid`.
# Examples
```jldoctest
julia> using IterativeEigenSolvers
julia> A = Diagonal(1:4);
julia> λ, ϕ = eigs(A, nev = 2);
Expand All @@ -73,6 +75,13 @@ julia> λ
2-element Array{Float64,1}:
4.0
3.0
julia> λ, ϕ = eigs(A, nev = 2, which=:SM);
julia> λ
2-element Array{Float64,1}:
1.0000000000000002
2.0
```
!!! note
Expand Down

0 comments on commit 710a3d8

Please sign in to comment.