Skip to content

Commit 710a3d8

Browse files
kshyattfredrikekre
authored andcommitted
More examples for linalg (#24824)
* Examples for RowVector * Update example and add which example for eigs
1 parent 0be3960 commit 710a3d8

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

base/linalg/rowvector.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,48 @@ By convention, a vector can be multiplied by a matrix on its left (`A * v`) wher
1212
vector can be multiplied by a matrix on its right (such that `v.' * A = (A.' * v).'`). It
1313
differs from a `1×n`-sized matrix by the facts that its transpose returns a vector and the
1414
inner product `v1.' * v2` returns a scalar, but will otherwise behave similarly.
15+
16+
# Examples
17+
```jldoctest
18+
julia> a = [1; 2; 3; 4]
19+
4-element Array{Int64,1}:
20+
1
21+
2
22+
3
23+
4
24+
25+
julia> RowVector(a)
26+
1×4 RowVector{Int64,Array{Int64,1}}:
27+
1 2 3 4
28+
29+
julia> a.'
30+
1×4 RowVector{Int64,Array{Int64,1}}:
31+
1 2 3 4
32+
33+
julia> a.'[3]
34+
3
35+
36+
julia> a.'[1,3]
37+
3
38+
39+
julia> a.'[3,1]
40+
ERROR: BoundsError: attempt to access 1×4 RowVector{Int64,Array{Int64,1}} at index [3, 1]
41+
[...]
42+
43+
julia> a.'*a
44+
30
45+
46+
julia> B = [1 2; 3 4; 5 6; 7 8]
47+
4×2 Array{Int64,2}:
48+
1 2
49+
3 4
50+
5 6
51+
7 8
52+
53+
julia> a.'*B
54+
1×2 RowVector{Int64,Array{Int64,1}}:
55+
50 60
56+
```
1557
"""
1658
struct RowVector{T,V<:AbstractVector} <: AbstractMatrix{T}
1759
vec::V

stdlib/IterativeEigenSolvers/src/IterativeEigenSolvers.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ final residual vector `resid`.
6565
6666
# Examples
6767
```jldoctest
68+
julia> using IterativeEigenSolvers
69+
6870
julia> A = Diagonal(1:4);
6971
7072
julia> λ, ϕ = eigs(A, nev = 2);
@@ -73,6 +75,13 @@ julia> λ
7375
2-element Array{Float64,1}:
7476
4.0
7577
3.0
78+
79+
julia> λ, ϕ = eigs(A, nev = 2, which=:SM);
80+
81+
julia> λ
82+
2-element Array{Float64,1}:
83+
1.0000000000000002
84+
2.0
7685
```
7786
7887
!!! note

0 commit comments

Comments
 (0)