Skip to content

Commit 55e82cf

Browse files
Merge pull request #16 from avik-pal/ap/gmres
Add Krylov.jl wrapper
2 parents 4579213 + 12be621 commit 55e82cf

File tree

11 files changed

+200
-236
lines changed

11 files changed

+200
-236
lines changed

.github/workflows/CI.yml

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22
on:
3-
# - push
3+
- push
44
- pull_request
55
jobs:
66
test:
@@ -42,21 +42,13 @@ jobs:
4242
runs-on: ubuntu-latest
4343
steps:
4444
- uses: actions/checkout@v2
45-
- uses: julia-actions/setup-julia@v1
45+
- uses: julia-actions/setup-julia@latest
4646
with:
4747
version: '1'
48-
- run: |
49-
julia --project=docs -e '
50-
using Pkg
51-
Pkg.develop(PackageSpec(path=pwd()))
52-
Pkg.instantiate()'
53-
- run: |
54-
julia --project=docs -e '
55-
using Documenter: DocMeta, doctest
56-
using LinearSolvers
57-
DocMeta.setdocmeta!(LinearSolvers, :DocTestSetup, :(using LinearSolvers); recursive=true)
58-
doctest(LinearSolvers)'
59-
- run: julia --project=docs docs/make.jl
48+
- name: Install dependencies
49+
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
50+
- name: Build and deploy
6051
env:
61-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62-
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
53+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
54+
run: julia --project=docs/ docs/make.jl

Project.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version = "0.1.0"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
8-
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
8+
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1111
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
@@ -14,7 +14,6 @@ UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed"
1414

1515
[compat]
1616
ArrayInterface = "3"
17-
IterativeSolvers = "0.9"
1817
Reexport = "1"
1918
SciMLBase = "1.18.6"
2019
Setfield = "0.7, 0.8"

docs/Manifest.toml

-92
This file was deleted.

docs/Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
LinearSolvers = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
3+
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"

docs/make.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using LinearSolvers
1+
using LinearSolve
22
using Documenter
33

4-
DocMeta.setdocmeta!(LinearSolvers, :DocTestSetup, :(using LinearSolvers); recursive=true)
4+
DocMeta.setdocmeta!(LinearSolve, :DocTestSetup, :(using LinearSolve); recursive=true)
55

66
makedocs(;
7-
modules=[LinearSolvers],
7+
modules=[LinearSolve],
88
authors="Jonathan <[email protected]> and contributors",
9-
repo="https://github.com/EdelmanJonathan/LinearSolvers.jl/blob/{commit}{path}#{line}",
9+
repo="https://github.com/SciML/LinearSolve.jl/blob/{commit}{path}#{line}",
1010
sitename="LinearSolvers.jl",
1111
format=Documenter.HTML(;
1212
prettyurls=get(ENV, "CI", "false") == "true",
13-
canonical="https://EdelmanJonathan.github.io/LinearSolvers.jl",
13+
canonical="https://linearsolve.sciml.ai/",
1414
assets=String[],
1515
),
1616
pages=[
@@ -19,5 +19,5 @@ makedocs(;
1919
)
2020

2121
deploydocs(;
22-
repo="github.com/EdelmanJonathan/LinearSolvers.jl",
22+
repo="github.com/SciML/LinearSolve.jl",
2323
)

docs/src/index.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
```@meta
2-
CurrentModule = LinearSolvers
2+
CurrentModule = LinearSolve
33
```
44

5-
# LinearSolvers
5+
# LinearSolve
66

7-
Documentation for [LinearSolvers](https://github.com/EdelmanJonathan/LinearSolvers.jl).
7+
Documentation for [LinearSolve](https://github.com/SciML/LinearSolve.jl).
88

99
```@index
1010
```
1111

1212
```@autodocs
13-
Modules = [LinearSolvers]
13+
Modules = [LinearSolve]
1414
```

src/LinearSolve.jl

+12-112
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,23 @@
11
module LinearSolve
22

3-
using Base: cache_dependencies, Bool
4-
using SciMLBase: AbstractLinearAlgorithm, AbstractDiffEqOperator
53
using ArrayInterface: lu_instance
6-
using UnPack
7-
using Reexport
4+
using Base: cache_dependencies, Bool
5+
using Krylov
86
using LinearAlgebra
7+
using Reexport
8+
using SciMLBase: AbstractDiffEqOperator, AbstractLinearAlgorithm
99
using Setfield
10-
@reexport using SciMLBase
11-
12-
export LUFactorization, QRFactorization, SVDFactorization
13-
14-
#mutable?#
15-
struct LinearCache{TA,Tb,Tp,Talg,Tc,Tr,Tl}
16-
A::TA
17-
b::Tb
18-
p::Tp
19-
alg::Talg
20-
cacheval::Tc
21-
isfresh::Bool
22-
Pr::Tr
23-
Pl::Tl
24-
end
25-
26-
function set_A(cache, A)
27-
@set! cache.A = A
28-
@set! cache.isfresh = true
29-
end
30-
31-
function set_b(cache, b)
32-
@set! cache.b = b
33-
end
34-
35-
function set_p(cache, p)
36-
@set! cache.p = p
37-
# @set! cache.isfresh = true
38-
end
39-
40-
function set_cacheval(cache::LinearCache,alg)
41-
if cache.isfresh
42-
@set! cache.cacheval = alg
43-
@set! cache.isfresh = false
44-
end
45-
return cache
46-
end
47-
48-
function SciMLBase.init(prob::LinearProblem, alg;
49-
alias_A = false, alias_b = false,
50-
kwargs...)
51-
@unpack A, b, p = prob
52-
if alg isa LUFactorization
53-
fact = lu_instance(A)
54-
Tfact = typeof(fact)
55-
else
56-
fact = nothing
57-
Tfact = Any
58-
end
59-
Pr = nothing
60-
Pl = nothing
61-
62-
A = alias_A ? A : copy(A)
63-
b = alias_b ? b : copy(b)
64-
65-
cache = LinearCache{typeof(A),typeof(b),typeof(p),typeof(alg),Tfact,typeof(Pr),typeof(Pl)}(
66-
A, b, p, alg, fact, true, Pr, Pl
67-
)
68-
return cache
69-
end
70-
71-
SciMLBase.solve(prob::LinearProblem, alg; kwargs...) = solve(init(prob, alg; kwargs...))
72-
SciMLBase.solve(cache) = solve(cache, cache.alg)
73-
74-
struct LUFactorization{P} <: AbstractLinearAlgorithm
75-
pivot::P
76-
end
77-
function LUFactorization()
78-
pivot = @static if VERSION < v"1.7beta"
79-
Val(true)
80-
else
81-
RowMaximum()
82-
end
83-
LUFactorization(pivot)
84-
end
85-
86-
function SciMLBase.solve(cache::LinearCache, alg::LUFactorization)
87-
cache.A isa Union{AbstractMatrix, AbstractDiffEqOperator} || error("LU is not defined for $(typeof(prob.A))")
88-
cache = set_cacheval(cache,lu!(cache.A, alg.pivot))
89-
ldiv!(cache.cacheval, cache.b)
90-
end
10+
using UnPack
9111

92-
struct QRFactorization{P} <: AbstractLinearAlgorithm
93-
pivot::P
94-
blocksize::Int
95-
end
96-
function QRFactorization()
97-
pivot = @static if VERSION < v"1.7beta"
98-
Val(false)
99-
else
100-
NoPivot()
101-
end
102-
QRFactorization(pivot, 16)
103-
end
12+
@reexport using SciMLBase
10413

105-
function SciMLBase.solve(cache::LinearCache, alg::QRFactorization)
106-
cache.A isa Union{AbstractMatrix, AbstractDiffEqOperator} || error("QR is not defined for $(typeof(prob.A))")
107-
cache = set_cacheval(cache,qr!(cache.A.A, alg.pivot; blocksize=alg.blocksize))
108-
ldiv!(cache.cacheval, cache.b)
109-
end
14+
abstract type SciMLLinearSolveAlgorithm end
11015

111-
struct SVDFactorization{A} <: AbstractLinearAlgorithm
112-
full::Bool
113-
alg::A
114-
end
115-
SVDFactorization() = SVDFactorization(false, LinearAlgebra.DivideAndConquer())
16+
include("common.jl")
17+
include("factorization.jl")
18+
include("krylov.jl")
11619

117-
function SciMLBase.solve(cache::LinearCache, alg::SVDFactorization)
118-
cache.A isa Union{AbstractMatrix, AbstractDiffEqOperator} || error("SVD is not defined for $(typeof(prob.A))")
119-
cache = set_cacheval(cache,svd!(cache.A; full=alg.full, alg=alg.alg))
120-
ldiv!(cache.cacheval, cache.b)
121-
end
20+
export LUFactorization, SVDFactorization, QRFactorization
21+
export KrylovJL
12222

12323
end

0 commit comments

Comments
 (0)