Skip to content

Commit

Permalink
Merge pull request #285 from ranocha/hr/test_project
Browse files Browse the repository at this point in the history
  • Loading branch information
haampie authored Dec 25, 2020
2 parents b4b501d + 5560ed9 commit 1824c69
Show file tree
Hide file tree
Showing 24 changed files with 130 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: CompatHelper

on:
schedule:
- cron: '00 00 * * *'

workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- uses: julia-actions/setup-julia@latest
with:
version: 1.3
version: 1.5
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }} # optional
run: julia -e 'using CompatHelper; CompatHelper.main(; subdirs=["", "docs", "test"])'
9 changes: 1 addition & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "IterativeSolvers"
uuid = "42fd0dbc-a981-5370-80f2-aaf504508153"
version = "0.8.4"
version = "0.8.5"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand All @@ -12,10 +12,3 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
[compat]
RecipesBase = "0.6, 0.7, 0.8, 1.0"
julia = "1"

[extras]
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "LinearMaps"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

## Installing

To install the package, open the package manager in the REPL via ] and run
To install the package, open the package manager in the REPL via `]` and run

```julia
pkg> add IterativeSolvers
Expand Down
55 changes: 29 additions & 26 deletions docs/src/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,48 @@ jacobi_iterable(x, A::SparseMatrixCSC, b; maxiter::Int = 10) =

Now if you apply Jacobi iteration multiple times with the same matrix for just a few iterations, it makes sense to initialize the iterable only once and reuse it afterwards:

```julia
A = sprand(10_000, 10_000, 10 / 10_000) + 20I
b1 = rand(10_000)
b2 = rand(10_000)
x = rand(10_000)

my_iterable = IterativeSolvers.jacobi_iterable(x, A, b1, maxiter = 4)
```jldoctest
julia> using LinearAlgebra, SparseArrays, IterativeSolvers
for item in my_iterable
println("Iteration for rhs 1")
end
julia> A = spdiagm(-1 => -ones(3), 0 => 2*ones(4), 1 => -ones(3));
@show norm(b1 - A * x) / norm(b1)
julia> b1 = [1.0, 2, 3, 4];
# Copy the next right-hand side into the iterable
copyto!(my_iterable.b, b2)
julia> b2 = [-1.0, 1, -1, 1];
for item in my_iterable
println("Iteration for rhs 2")
end
julia> x = [0.0, -1, 1, 0];
@show norm(b2 - A * x) / norm(b2)
```
julia> my_iterable = IterativeSolvers.jacobi_iterable(x, A, b1, maxiter = 2);
This would output:
julia> norm(b1 - A * x) / norm(b1)
1.2909944487358056
```
Iteration for rhs 1
Iteration for rhs 1
julia> for item in my_iterable
println("Iteration for rhs 1")
end
Iteration for rhs 1
Iteration for rhs 1
norm(b1 - A * x) / norm(b1) = 0.08388528015119746
Iteration for rhs 2
Iteration for rhs 2
julia> norm(b1 - A * x) / norm(b1)
0.8228507357554791
julia> # Copy the next right-hand side into the iterable
copyto!(my_iterable.b, b2);
julia> norm(b2 - A * x) / norm(b2)
2.6368778887161235
julia> for item in my_iterable
println("Iteration for rhs 2")
end
Iteration for rhs 2
Iteration for rhs 2
norm(b2 - A * x) / norm(b2) = 0.0003681972775644809
julia> norm(b2 - A * x) / norm(b2)
1.610815496107484
```


## Other use cases
Other use cases include:
- computing the (harmonic) Ritz values from the Hessenberg matrix in GMRES;
Expand Down
13 changes: 13 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
Documenter = "0.26"
LinearMaps = "3"
RecipesBase = "1"
4 changes: 4 additions & 0 deletions test/bicgstabl.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestBiCGStabl

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -66,3 +68,5 @@ end
end
end
end

end # module
4 changes: 4 additions & 0 deletions test/cg.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestCG

using IterativeSolvers
using LinearMaps
using Test
Expand Down Expand Up @@ -120,3 +122,5 @@ end
end

end

end # module
4 changes: 4 additions & 0 deletions test/chebyshev.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestChebyshev

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -91,3 +93,5 @@ end
end
end
end

end # module
8 changes: 8 additions & 0 deletions test/common.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module TestCommon

using Documenter
using LinearAlgebra
using IterativeSolvers
using Test
Expand Down Expand Up @@ -25,3 +28,8 @@ end
end

end

DocMeta.setdocmeta!(IterativeSolvers, :DocTestSetup, :(using IterativeSolvers); recursive=true)
doctest(IterativeSolvers, manual=true)

end # module
6 changes: 5 additions & 1 deletion test/deprecations.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestDeprecations

using IterativeSolvers
using Test

Expand All @@ -12,4 +14,6 @@ using Test
@test_deprecated idrs(A, b, tol=1.0, maxiter=1)
@test_deprecated minres(A, b, tol=1.0, maxiter=1)
@test_deprecated qmr(A, b, tol=1.0, maxiter=1)
end
end

end # module
4 changes: 4 additions & 0 deletions test/gmres.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestGMRES

using IterativeSolvers
using Test
using LinearMaps
Expand Down Expand Up @@ -96,3 +98,5 @@ end
end
end
end

end # module
5 changes: 5 additions & 0 deletions test/hessenberg.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module TestHessenberg

using LinearAlgebra
using IterativeSolvers
using Test

Expand Down Expand Up @@ -40,3 +43,5 @@ using Test
@test abs(last(solution_with_residual)) norm(H * solution - rhs)
end
end

end # module
4 changes: 4 additions & 0 deletions test/history.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestHistory

using IterativeSolvers
using RecipesBase
using Test
Expand Down Expand Up @@ -75,3 +77,5 @@ using Test
end
end
end

end # module
4 changes: 4 additions & 0 deletions test/idrs.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestIDRs

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -85,3 +87,5 @@ end
end

end

end # module
11 changes: 7 additions & 4 deletions test/lobpcg.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
module TestLOBPCG

using IterativeSolvers
using LinearMaps
using LinearAlgebra
using Test
using Random
using SparseArrays


# Already defined in another file
#=
include("laplace_matrix.jl")

struct JacobiPrec{TD}
diagonal::TD
end

Base.ldiv!(y, P::JacobiPrec, x) = y .= x ./ P.diagonal
=#
LinearAlgebra.ldiv!(y, P::JacobiPrec, x) = y .= x ./ P.diagonal

function max_err(R)
r = zeros(real(eltype(R)), size(R, 2))
Expand Down Expand Up @@ -358,3 +359,5 @@ end
end
end
end

end # module
4 changes: 4 additions & 0 deletions test/lsmr.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestLSMR

using IterativeSolvers
using Test
using LinearAlgebra
Expand Down Expand Up @@ -97,3 +99,5 @@ end
@test norm((A'A + Matrix(Diagonal(v)) .^ 2)x - A'b) 1e-3
end
end

end # module
4 changes: 4 additions & 0 deletions test/lsqr.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestLSQR

using IterativeSolvers
using Test
using LinearMaps
Expand Down Expand Up @@ -38,3 +40,5 @@ end
@test norm(b - A * x_lsqr) 1e-4
end
end

end # module
4 changes: 4 additions & 0 deletions test/minres.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestMINRES

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -94,3 +96,5 @@ end
end

end

end # module
5 changes: 5 additions & 0 deletions test/orthogonalize.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module TestOrthogonalize

using LinearAlgebra
using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -58,3 +61,5 @@ m = 3
end
end
end

end # module
4 changes: 4 additions & 0 deletions test/qmr.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestQMR

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -64,3 +66,5 @@ end
end

end

end # module
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using IterativeSolvers

#Common functions and data structures
include("common.jl")
Expand Down
4 changes: 4 additions & 0 deletions test/simple_eigensolvers.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestSimpleEigensolver

using IterativeSolvers
using Test
using LinearMaps
Expand Down Expand Up @@ -46,3 +48,5 @@ n = 10
end
end
end

end # module
4 changes: 4 additions & 0 deletions test/stationary.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestStationary

import LinearAlgebra.SingularException
import IterativeSolvers: DiagonalIndices, FastLowerTriangular,
FastUpperTriangular, forward_sub!, backward_sub!, OffDiagonal,
Expand Down Expand Up @@ -211,3 +213,5 @@ end
@test x b - tril(A, -1) * y
end
end

end # module
4 changes: 4 additions & 0 deletions test/svdl.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestSVDL

using IterativeSolvers
using Test
using Random
Expand Down Expand Up @@ -77,3 +79,5 @@ end #svdl
@test_throws ArgumentError size(B,3)
@test_throws BoundsError B[1,5]
end

end # module

4 comments on commit 1824c69

@haampie
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error while trying to register: Changing package repo URL not allowed, please submit a pull request with the URL change to the target registry and retry.

@haampie
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/26892

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.5 -m "<description of version>" 1824c696fea54ec7226e59447946c72be8d2580f
git push origin v0.8.5

Please sign in to comment.