Skip to content

Commit

Permalink
Merge 90a3a2c into 8e8d27e
Browse files Browse the repository at this point in the history
  • Loading branch information
neveritt committed Oct 20, 2019
2 parents 8e8d27e + 90a3a2c commit 9dd6575
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/reductions.jl
Expand Up @@ -112,10 +112,17 @@ julia> H
Triangularization" IEEE Transactions on Automatic Control, vol. 44,
no. 3, Mar. 1999.
"""
function hermite(p::PolyMatrix{T1,M,Val{W},N}, iterative::Bool=true, dᵤ::Int=-1) where {T1,M,W,N}
function hermite(p::PolyMatrix{T1,M,Val{W},N}, iterative::Bool=true, dᵤ::Int=-1,
ϵ=-one(T1)) where {T1,M,W,N}
L,U,d = _ltriang(p, iterative, dᵤ)
n,m = size(p)

# truncate elements close to zero
ϵ = ϵ < zero(ϵ) ? Base.rtoldefault(real(T1))*length(p)*d : ϵ
for i in eachindex(L)
L[i] = abs(L[i]) < ϵ ? zero(L[i]) : L[i]
end

# scale diagonal elements first
Σ = [findfirst(x -> x!=0, L[:,k]) for k in 1:m]
U1 = Diagonal([1 ./ L[Σ[k],k] for k in 1:m])
Expand Down

0 comments on commit 9dd6575

Please sign in to comment.