# \[ANN\] KrylovKit:

**URL:** https://discourse.julialang.org/t/ann-krylovkit/14654
**Category:** Community
**Tags:** announcement
**Created:** [September 7, 2018, 7:41am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654 "2018-09-07T07:41:54Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [September 7, 2018, 7:41am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/1 "2018-09-07T07:41:54Z")

</div>

I am pleased to announce [**KrylovKit.jl**](https://github.com/Jutho/KrylovKit.jl), a registered Julia package collecting a number of Krylov-based algorithms for linear problems, singular value and eigenvalue problems and the application of functions of linear maps or operators to vectors.

KrylovKit.jl accepts general functions or callable objects as linear maps, and general Julia objects with vector like behavior as vectors.

From the [documentation](http://jutho.github.io/KrylovKit.jl/stable/) overview:

There are already a fair number of packages with Krylov-based or other iterative methods, such as

- [IterativeSolvers.jl](https://github.com/JuliaMath/IterativeSolvers.jl): part of the  
[JuliaMath](https://github.com/JuliaMath) organisation, solves linear systems and least  
square problems, eigenvalue and singular value problems
- [Krylov.jl](https://github.com/JuliaSmoothOptimizers/Krylov.jl): part of the  
[JuliaSmoothOptimizers](https://github.com/JuliaSmoothOptimizers) organisation, solves  
linear systems and least square problems, specific for linear operators from  
[LinearOperators.jl](https://github.com/JuliaSmoothOptimizers/LinearOperators.jl).
- [KrylovMethods.jl](https://github.com/lruthotto/KrylovMethods.jl): specific for sparse matrices
- [Expokit.jl](https://github.com/acroy/Expokit.jl): application of the matrix exponential to a vector

KrylovKit.jl distinguishes itself from the previous packages in the following ways

1. KrylovKit accepts general functions to represent the linear map or operator that defines  
the problem, without having to wrap them in a [`LinearMap`](https://github.com/Jutho/LinearMaps.jl)  
or [`LinearOperator`](https://github.com/JuliaSmoothOptimizers/LinearOperators.jl) type.  
Of course, subtypes of `AbstractMatrix` are also supported. If the linear map (always the first  
argument) is a subtype of `AbstractMatrix`, matrix vector multiplication is used, otherwise  
is applied as a function call.

2. KrylovKit does not assume that the vectors involved in the problem are actual subtypes of  
`AbstractVector`. Any Julia object that behaves as a vector is supported, so in particular  
higher-dimensional arrays or any custom user type that supports the following functions  
(with `v` and `w` two instances of this type and `α` a scalar (`Number`)):

3. To the best of my knowledge, KrylovKit.jl is the only package that provides a native Julia  
implementation of a Krylov method for eigenvalues of general matrices (in particular the  
Krylov-Schur algorithm). As such, is the only pure Julia alternative to [`Arpack.jl`](https://github.com/JuliaLinearAlgebra/Arpack.jl).

---

<div class="post-metadata">

### Author: ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)
#### Post date: [September 7, 2018, 8:07am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/2 "2018-09-07T08:07:26Z")

</div>

There is also [GitHub - JuliaLinearAlgebra/ArnoldiMethod.jl: Implicitly Restarted Arnoldi Method, natively in Julia](https://github.com/haampie/ArnoldiMethod.jl) but it doesn’t use the Krylov-Schur algorithm.

---

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [September 7, 2018, 8:15am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/3 "2018-09-07T08:15:20Z")

</div>

Great, thanks for the link. I see there is also a JacobiDavidson implementation on [https://github.com/haampie/](https://github.com/haampie/); I’ll add those links to the readme (and hope that forces can be combined in the future).

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [September 7, 2018, 8:19am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/4 "2018-09-07T08:19:16Z")

</div>

> [@juthohaegeman](#):
>
> any custom user type that supports the following functions

Is it possible to make it work with types that are not mutable containers, so that they cannot support `mul!` etc?

---

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [September 7, 2018, 8:22am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/5 "2018-09-07T08:22:35Z")

</div>

I have not tested this, but in principle I always use the right hand side, so I tried to never write  
`rmul!(v, α)` but rather always `v = rmul!(v, α)`. This means that, if `rmul!(v, α)` is defined to just output `v/α` without actually working in place, everything _might_ still work.

I will try to add some tests for that.

---

<div class="post-metadata">

### Author: ![stabbles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stabbles/32/946_2.png) [@stabbles](https://discourse.julialang.org/u/stabbles)
#### Post date: [September 7, 2018, 8:27am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/6 "2018-09-07T08:27:21Z")

</div>

Nice @juthohaegeman :)! I’ll take a look at the source.

In [GitHub - JuliaLinearAlgebra/ArnoldiMethod.jl: Implicitly Restarted Arnoldi Method, natively in Julia](https://github.com/haampie/ArnoldiMethod.jl) the goal is to have a version that does not depend on LAPACK (only BLAS right now), I’ll let you know when that is done.

I only realized a few days ago that Krylov-Schur is just another way to implement implicitly restarted Arnoldi, so I’m embracing that and moving away from exact shift ideas of ARPACK (also Lehoucq told me he considered that best!). This means I’m implementing the LAPACK functions to reorder the Schur form in real and complex arithmetic. Maybe in the end this should go to GenericLinearAlgebra.jl so that you could use it as well :).

---

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [September 7, 2018, 8:36am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/7 "2018-09-07T08:36:08Z")

</div>

I also have a Julia implementation of the schur factorization of a Hessenberg matrix lying around (and related routines for reordering etc), but did not use it in KrylovKit.jl because for some matrices there were still convergence issues. I’d be happy to share what I have.

MATLAB actually also shifted away from ARPACK to Krylov-Schur, but I only learned that after I implemented it (not that it would have mattered). The book of Stewart (Matrix Algorithms Volume II) is a great reference.

---

<div class="post-metadata">

### Author: ![stabbles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stabbles/32/946_2.png) [@stabbles](https://discourse.julialang.org/u/stabbles)
#### Post date: [September 7, 2018, 8:48am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/8 "2018-09-07T08:48:55Z")

</div>

Awesome! 🙂 I think the QR-algorithm I have is pretty much optimized and I’m still planning to make a PR to GenericLinearAlgebra.jl, but after the Arnoldi stuff is done. I know there is some literature on obscure cases where the QR-algorithm does not converge, but I’m not interested in every edge case at the moment. And w.r.t. reordering, I’m currently doing some tricks with StaticArrays.jl to solve tiny Sylvester equations with LU + complete pivoting that arise when swapping 2x2 blocks with 1x1 or 2x2 in the quasi upper triangular matrix – did you implement that already?

---

<div class="post-metadata">

### Author: ![juthohaegeman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juthohaegeman/32/8620_2.png) [@juthohaegeman](https://discourse.julialang.org/u/juthohaegeman)
#### Post date: [September 7, 2018, 8:56am UTC](https://discourse.julialang.org/t/ann-krylovkit/14654/9 "2018-09-07T08:56:45Z")

</div>

Yes but I just used tuples, because I did not want dependencies, and also, I think I started on this before `StaticArrays` were out and popular. Here is the code, but this dates back to Julia 0.6 (or even older):

> <https://gist.github.com/Jutho/8077a86a65330c572fcef707a7af617f>
