@@ -50,6 +50,19 @@ The following keyword arguments are supported:
50
50
iterations `niter` and the number of matrix vector multiplications `nmult`, as well as the
51
51
final residual vector `resid`.
52
52
53
+ # Example
54
+
55
+ ```jldoctest
56
+ julia> A = spdiagm(1:4);
57
+
58
+ julia> λ, ϕ = eigs(A, nev = 2);
59
+
60
+ julia> λ
61
+ 2-element Array{Float64,1}:
62
+ 4.0
63
+ 3.0
64
+ ```
65
+
53
66
!!! note
54
67
The `sigma` and `which` keywords interact: the description of eigenvalues
55
68
searched for by `which` do *not* necessarily refer to the eigenvalues of
@@ -133,13 +146,18 @@ final residual vector `resid`.
133
146
134
147
# Example
135
148
136
- ```julia
137
- X = sprand(10, 5, 0.2)
138
- eigs(X, nsv = 2, tol = 1e-3)
149
+ ```jldoctest
150
+ julia> A = speye(4, 4); B = spdiagm(1:4);
151
+
152
+ julia> λ, ϕ = eigs(A, B, nev = 2);
153
+
154
+ julia> λ
155
+ 2-element Array{Float64,1}:
156
+ 1.0
157
+ 0.5
139
158
```
140
159
141
160
!!! note
142
-
143
161
The `sigma` and `which` keywords interact: the description of eigenvalues searched for by
144
162
`which` do *not* necessarily refer to the eigenvalue problem ``Av = Bv\\ lambda``, but rather
145
163
the linear operator constructed by the specification of the iteration mode implied by `sigma`.
@@ -344,17 +362,22 @@ iterations derived from [`eigs`](@ref).
344
362
345
363
# Example
346
364
347
- ```julia
348
- X = sprand(10, 5, 0.2)
349
- svds(X, nsv = 2)
365
+ ```jldoctest
366
+ julia> A = spdiagm(1:4);
367
+
368
+ julia> s = svds(A, nsv = 2)[1];
369
+
370
+ julia> s[:S]
371
+ 2-element Array{Float64,1}:
372
+ 4.0
373
+ 3.0
350
374
```
351
375
352
376
!!! note "Implementation"
353
-
354
- `svds(A)` is formally equivalent to calling [`eigs`](@ref) to perform implicitly restarted
355
- Lanczos tridiagonalization on the Hermitian matrix
356
- ``\\ begin{pmatrix} 0 & A^\\ prime \\\\ A & 0 \\ end{pmatrix}``, whose eigenvalues are
357
- plus and minus the singular values of ``A``.
377
+ `svds(A)` is formally equivalent to calling [`eigs`](@ref) to perform implicitly restarted
378
+ Lanczos tridiagonalization on the Hermitian matrix
379
+ ``\\ begin{pmatrix} 0 & A^\\ prime \\\\ A & 0 \\ end{pmatrix}``, whose eigenvalues are
380
+ plus and minus the singular values of ``A``.
358
381
"""
359
382
svds (A; kwargs... ) = _svds (A; kwargs... )
360
383
function _svds (X; nsv:: Int = 6 , ritzvec:: Bool = true , tol:: Float64 = 0.0 , maxiter:: Int = 1000 , ncv:: Int = 2 * nsv, u0:: Vector = zeros (eltype (X),(0 ,)), v0:: Vector = zeros (eltype (X),(0 ,)))
0 commit comments