Skip to content

Commit

Permalink
Add utility isfinite(::AbstractLattice) (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos authored Nov 12, 2024
1 parent 7efc444 commit aaa4de3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lattices/chains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct InfiniteChain <: AbstractLattice{1}
end
end
Base.axes(::InfiniteChain) = ((-typemax(Int)):typemax(Int),)
Base.isfinite(::Type{InfiniteChain}) = false

"""
FiniteChain(length::Integer=1)
Expand All @@ -23,6 +24,7 @@ struct FiniteChain <: AbstractLattice{1}
end
end
Base.axes(chain::FiniteChain) = (1:(chain.L),)
Base.isfinite(::Type{FiniteChain}) = true

const Chain = Union{InfiniteChain,FiniteChain}

Expand Down
3 changes: 3 additions & 0 deletions src/lattices/squarelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct InfiniteStrip <: AbstractLattice{2}
end
InfiniteLadder(N::Integer) = InfiniteStrip(2, N)
Base.axes(strip::InfiniteStrip) = (1:(strip.L), (-typemax(Int)):typemax(Int))
Base.isfinite(::Type{InfiniteStrip}) = false

"""
InfiniteCylinder(L::Int, N::Int)
Expand All @@ -33,6 +34,7 @@ struct InfiniteCylinder <: AbstractLattice{2}
end

Base.axes(::InfiniteCylinder) = ((-typemax(Int)):typemax(Int), (-typemax(Int)):typemax(Int))
Base.isfinite(::Type{InfiniteCylinder}) = false

"""
InfiniteHelix(L::Integer, N::Integer)
Expand All @@ -51,6 +53,7 @@ end
function Base.axes(::InfiniteHelix)
return ((-typemax(Int)):typemax(Int), (-typemax(Int)):typemax(Int))
end
Base.isfinite(::Type{InfiniteHelix}) = false

############################################################################################

Expand Down
2 changes: 2 additions & 0 deletions src/lattices/triangularlattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct HoneycombYC <: AbstractLattice{2}
end
end

Base.isfinite(::Type{HoneycombYC}) = false

# TODO: do proper boundscheck
function Base.checkbounds(::Type{Bool}, lattice::HoneycombYC, inds::Vararg{Int,2})
return true
Expand Down

0 comments on commit aaa4de3

Please sign in to comment.