Skip to content

Commit

Permalink
Merge pull request #181 from pablosanjose/nopivot
Browse files Browse the repository at this point in the history
Fix compatibility issues with v1.7+
  • Loading branch information
pablosanjose authored Jul 1, 2021
2 parents 9b9fb61 + 5119a2d commit b093cdf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ jobs:
strategy:
matrix:
version:
- '1.5'
- '1'
- '1.6'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
Expand Down
3 changes: 2 additions & 1 deletion src/Quantica.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Quantica

# Use README as the docstring of the module:
using Base.Threads: Iterators
@doc read(joinpath(dirname(@__DIR__), "README.md"), String) Quantica

using Requires
Expand All @@ -19,7 +20,7 @@ using SparseArrays: getcolptr, AbstractSparseMatrix, AbstractSparseMatrixCSC

using Statistics: mean

using Compat # for use of findmin/findmax in bandstructure.jl
using Compat # for use of argmin/argmax in bandstructure.jl

export sublat, bravais, lattice, dims, supercell, unitcell,
hopping, onsite, @onsite!, @hopping!, @block!, parameters, siteselector, hopselector, nrange,
Expand Down
6 changes: 3 additions & 3 deletions src/bandstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ function refine_bisection(found, neighs, steps, criterion, diag)
end

select_closest(εs, criterion, ε0, εi...) =
last(findmin(ε -> ifelse(criterion(ε, ε0, εi...), abs- ε0), Inf), εs))
argmin(ε -> ifelse(criterion(ε, ε0, εi...), abs- ε0), Inf), εs)

"""
gapedge(b::Bandstructure{1}, ε₀; refinesteps = 0)
Expand All @@ -1057,15 +1057,15 @@ function gapedge(b::Bandstructure{1,<:Any,T}, ε0, ::typeof(+); kw...) where {T}
isinband(b, ε0) && return (missing, zero(T))
minbands = Iterators.flatten(filter!.(φε -> last(φε) > ε0, minima(b; kw...)))
isempty(minbands) && return (missing, T(Inf))
(φ₊, ε₊) = findmin(last, minbands) |> last
(φ₊, ε₊) = argmin(last, minbands)
return (φ₊, ε₊)
end

function gapedge(b::Bandstructure{1,<:Any,T}, ε0, ::typeof(-); kw...) where {T}
isinband(b, ε0) && return (missing, zero(T))
maxbands = Iterators.flatten(filter!.(φε -> last(φε) < ε0, maxima(b; kw...)))
isempty(maxbands) && return (missing, T(-Inf))
(φ₋, ε₋) = findmax(last, maxbands) |> last
(φ₋, ε₋) = argmax(last, maxbands)
return (φ₋, ε₋)
end

Expand Down
6 changes: 5 additions & 1 deletion src/tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ end
pinverse(::SMatrix{E,0,T}) where {E,T} = SMatrix{0,E,T}() # BUG: workaround StaticArrays bug SMatrix{E,0,T}()'

function pinverse(m::SMatrix)
qrm = qr(m)
@static if VERSION >= v"1.7.0-beta2"
qrm = qr(m, NoPivot())
else
qrm = qr(m)
end
return inv(qrm.R) * qrm.Q'
end

Expand Down

0 comments on commit b093cdf

Please sign in to comment.