Skip to content

Commit

Permalink
Merge pull request #8 from jagot/gha
Browse files Browse the repository at this point in the history
Move to Github Actions, added some simple tests
  • Loading branch information
haampie authored Apr 16, 2021
2 parents 3cd8666 + cbb0cf3 commit 7321c17
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 38 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.3'
- '1'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
doctests:
name: Doctests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- name: Run Doctests
# See https://github.com/actions/toolkit/issues/399
continue-on-error: true
run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using JacobiDavidson
DocMeta.setdocmeta!(JacobiDavidson, :DocTestSetup, :(using JacobiDavidson); recursive=true)
doctest(JacobiDavidson)'
16 changes: 16 additions & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
15 changes: 15 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
IterativeSolvers = "^0.8"
LinearMaps = "^2.6"
IterativeSolvers = "^0.9"
LinearMaps = "3.3"
julia = "^1.3"
ProgressMeter = "^1.0"
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.25"
35 changes: 18 additions & 17 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using Documenter, JacobiDavidson
using JacobiDavidson
using Documenter

makedocs(
modules = [JacobiDavidson],
clean = true,
format = :html,
sitename = "JacobiDavidson.jl",
authors = "Harmen Stoppels",
pages = [
makedocs(;
modules=[JacobiDavidson],
authors="Harmen Stoppels",
repo="https://github.com/haampie/JacobiDavidson.jl/blob/{commit}{path}#{line}",
sitename="JacobiDavidson.jl",
format=Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://haampie.github.io/JacobiDavidson.jl",
assets=String[],
),
pages=[
"Home" => "index.md",
"Correction equation" => "solvers.md"
]
],
doctest = false
)

deploydocs(
repo = "github.com/haampie/JacobiDavidson.jl.git",
target = "build",
osname = "linux",
julia = "0.6",
deps = nothing,
make = nothing
)
deploydocs(;
repo="github.com/haampie/JacobiDavidson.jl",
)
5 changes: 4 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Jacobi-Davidson

[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://haampie.github.io/JacobiDavidson.jl/latest)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://haampie.github.io/JacobiDavidson.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://haampie.github.io/JacobiDavidson.jl/dev)
[![Build Status](https://github.com/haampie/JacobiDavidson.jl/workflows/CI/badge.svg)](https://github.com/haampie/JacobiDavidson.jl/actions)
[![Coverage](https://codecov.io/gh/haampie/JacobiDavidson.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/haampie/JacobiDavidson.jl)

An implementation of Jacobi-Davidson in Julia. This method can be used as an alternative to Julia's `eigs` to find a few eigenvalues and eigenvectors of a large sparse matrix.

Expand Down
2 changes: 1 addition & 1 deletion src/correction_eqn_solvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function solve_generalized_correction_equation!(solver::GMRES, A, B, preconditio
# Start with a zero guess
fill!(x, zero(T))

iterable = IterativeSolvers.gmres_iterable!(x, Ax_minus_Bx, r, Pl=Pl, tol=tol,
iterable = IterativeSolvers.gmres_iterable!(x, Ax_minus_Bx, r, Pl=Pl, reltol=tol,
restart=solver.iterations,
initially_zero=true)

Expand Down
82 changes: 80 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Test

using JacobiDavidson, LinearAlgebra
using JacobiDavidson, LinearAlgebra, LinearMaps

@testset "Schur permutations" begin
@testset "Schur permutations" begin
A = rand(ComplexF64, 10, 10)
B = rand(ComplexF64, 10, 10)
F = schur(A, B)
Expand Down Expand Up @@ -44,3 +44,81 @@ using JacobiDavidson, LinearAlgebra
@test all(abs(sorted[1]) .≤ abs.(sorted[2 : end]))
end

@testset "Jacobi–Davidson" begin
function myA!(y, x)
for i = 1 : length(x)
@inbounds y[i] = sqrt(i) * x[i]
end
end

function myB!(y, x)
for i = 1 : length(x)
@inbounds y[i] = x[i] / sqrt(i)
end
end

struct SuperPreconditioner{numT <: Number}
target::numT
end

function LinearAlgebra.ldiv!(p::SuperPreconditioner{T}, x::AbstractVector{T}) where {T<:Number}
for i = 1 : length(x)
@inbounds x[i] = x[i] * sqrt(i) / (i - p.target)
end
return x
end

function LinearAlgebra.ldiv!(y::AbstractVector{T}, p::SuperPreconditioner{T}, x::AbstractVector{T}) where {T<:Number}
for i = 1 : length(x)
@inbounds y[i] = x[i] * sqrt(i) / (i - p.target)
end
return y
end

n = 10_000
target = Near(5_000.1 + 0.0im)
A = LinearMap{Float64}(myA!, n; ismutating = true)
B = LinearMap{Float64}(myB!, n; ismutating = true)
P = SuperPreconditioner(target.τ)

@testset "JDQR" begin
@testset "Verbosity = $(verbosity)" for verbosity = 1:2
pschur, residuals = jdqr(A,
solver = BiCGStabl(n, max_mv_products = 10, l = 2),
target = target,
pairs = 5,
tolerance = 1e-9,
subspace_dimensions = 10:20,
max_iter = 1000,
verbosity = verbosity
)
verbosity == 1 && println("\n\n\n")
λ = sort(real(pschur.values))

@test λ sqrt.(2*(4998:0.5:5000)) rtol=1e-10
end
end

@testset "JDQZ" begin
@testset "Correction solver = $(label)" for (label,solver) in [("BiCGStabl", BiCGStabl(n, max_mv_products = 10, l = 2)),
("GMRES", GMRES(n))]
@testset "Verbosity = $(verbosity)" for verbosity = 1:2
pschur, residuals = jdqz(A, B,
solver = solver,
preconditioner = P,
testspace = Harmonic,
target = target,
pairs = 5,
tolerance = 1e-9,
subspace_dimensions = 10:20,
max_iter = 100,
verbosity = verbosity
)
verbosity == 1 && println("\n\n\n")
λ = sort(real(pschur.alphas ./ pschur.betas))

@test λ 4998:5002 rtol=1e-10
end
end
end
end

0 comments on commit 7321c17

Please sign in to comment.