Skip to content

Commit

Permalink
Merge pull request #189 from haampie/fix-hessenberg-name
Browse files Browse the repository at this point in the history
Resolve conflicting name 'Hessenberg'
  • Loading branch information
haampie committed Jan 24, 2018
2 parents b8056b2 + 231424c commit 756edef
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/gmres.jl
Expand Up @@ -242,7 +242,7 @@ function solve_least_squares!(arnoldi::ArnoldiDecomp{T}, β, k::Int) where {T}
rhs = zeros(T, k)
rhs[1] = β

H = Hessenberg(view(arnoldi.H, 1 : k, 1 : k - 1))
H = FastHessenberg(view(arnoldi.H, 1 : k, 1 : k - 1))
A_ldiv_B!(H, rhs)

rhs
Expand Down
6 changes: 3 additions & 3 deletions src/hessenberg.jl
@@ -1,18 +1,18 @@
import Base.LinAlg: Givens, givensAlgorithm
import Base.A_ldiv_B!

struct Hessenberg{T<:AbstractMatrix}
struct FastHessenberg{T<:AbstractMatrix}
H::T # H is assumed to be Hessenberg of size (m + 1) × m
end

@inline Base.size(H::Hessenberg, args...) = size(H.H, args...)
@inline Base.size(H::FastHessenberg, args...) = size(H.H, args...)

"""
Solve Hy = rhs for a non-square Hessenberg matrix.
Note that `H` is also modified as is it converted
to an upper triangular matrix via Given's rotations
"""
function A_ldiv_B!(H::Hessenberg, rhs)
function A_ldiv_B!(H::FastHessenberg, rhs)
# Implicitly computes H = QR via Given's rotations
# and then computes the least-squares solution y to
# |Hy - rhs| = |QRy - rhs| = |Ry - Q'rhs|
Expand Down
6 changes: 2 additions & 4 deletions test/hessenberg.jl
@@ -1,8 +1,6 @@
using IterativeSolvers
using Base.Test

import IterativeSolvers: Hessenberg

@testset "Hessenberg" begin

# Some well-conditioned Hessenberg matrix
Expand All @@ -24,15 +22,15 @@ import IterativeSolvers: Hessenberg
0.0+0.0im 0.0+0.0im 0.0+0.0im 1.42175+0.0im
]

for H = [H1, H2]
for H = (H1, H2)
T = eltype(H)

# Fist standard basis vector as rhs
rhs = [i == 1 ? one(T) : zero(T) for i = 1 : size(H, 1)]

# Compare \ against the optimized version.
solution_with_residual = copy(rhs)
A_ldiv_B!(IterativeSolvers.Hessenberg(copy(H)), solution_with_residual)
A_ldiv_B!(IterativeSolvers.FastHessenberg(copy(H)), solution_with_residual)
solution = H \ rhs

# First part is the solution
Expand Down

0 comments on commit 756edef

Please sign in to comment.