33
44represents an `N`-dimensional point on a `G` lattice.
55"""
6- struct LatticePoint{N,G <: AbstractLattice{N} }
7- coordinates:: NTuple{N,Int}
6+ struct LatticePoint{N, G <: AbstractLattice{N} }
7+ coordinates:: NTuple{N, Int}
88 lattice:: G
9- function LatticePoint (coordinates:: NTuple{N,Int} , lattice:: AbstractLattice{N} ) where {N}
9+ function LatticePoint (coordinates:: NTuple{N, Int} , lattice:: AbstractLattice{N} ) where {N}
1010 checkbounds (lattice, coordinates... )
11- return new {N,typeof(lattice)} (coordinates, lattice)
11+ return new {N, typeof(lattice)} (coordinates, lattice)
1212 end
1313end
1414
15- function LatticePoint (ind:: Int , lattice:: G ) where {G<: AbstractLattice{1} }
15+ function LatticePoint (ind:: Int , lattice:: G ) where {G <: AbstractLattice{1} }
1616 return LatticePoint ((ind,), lattice)
1717end
1818
@@ -21,47 +21,47 @@ function Base.show(io::IO, p::LatticePoint)
2121end
2222
2323function Base. show (io:: IO , :: MIME"text/plain" , p:: LatticePoint )
24- if get (io, :typeinfo , Any) === typeof (p)
24+ return if get (io, :typeinfo , Any) === typeof (p)
2525 print (io, [p. coordinates... ])
2626 else
2727 print (io, p. lattice, [p. coordinates... ])
2828 end
2929end
3030
31- function Base. getindex (lattice:: AbstractLattice{N} , inds:: Vararg{Int,N} ) where {N}
31+ function Base. getindex (lattice:: AbstractLattice{N} , inds:: Vararg{Int, N} ) where {N}
3232 return LatticePoint (inds, lattice)
3333end
3434
3535Base. to_index (p:: LatticePoint ) = linearize_index (p)
3636linearize_index (p:: LatticePoint ) = linearize_index (p. lattice, p. coordinates... )
3737
38- function Base.:+ (i:: LatticePoint{N,G} , j:: LatticePoint{N,G} ) where {N,G}
38+ function Base.:+ (i:: LatticePoint{N, G} , j:: LatticePoint{N, G} ) where {N, G}
3939 i. lattice == j. lattice || throw (ArgumentError (" lattices should be equal" ))
4040 return LatticePoint (i. coordinates .+ j. coordinates, i. lattice)
4141end
42- function Base.:- (i:: LatticePoint{N,G} , j:: LatticePoint{N,G} ) where {N,G}
42+ function Base.:- (i:: LatticePoint{N, G} , j:: LatticePoint{N, G} ) where {N, G}
4343 i. lattice == j. lattice || throw (ArgumentError (" lattices should be equal" ))
4444 return LatticePoint (i. coordinates .- j. coordinates, i. lattice)
4545end
4646
47- function Base.:+ (i:: LatticePoint{N} , j:: NTuple{N,Int} ) where {N}
47+ function Base.:+ (i:: LatticePoint{N} , j:: NTuple{N, Int} ) where {N}
4848 return LatticePoint (i. coordinates .+ j, i. lattice)
4949end
5050Base.:+ (i:: LatticePoint{1} , j:: Int ) = LatticePoint (i. coordinates .+ j, i. lattice)
51- Base.:+ (i:: NTuple{N,Int} , j:: LatticePoint{N} ) where {N} = j + i
51+ Base.:+ (i:: NTuple{N, Int} , j:: LatticePoint{N} ) where {N} = j + i
5252Base.:+ (i:: Int , j:: LatticePoint{1} ) = j + i
5353
54- function Base.:- (i:: LatticePoint{N} , j:: NTuple{N,Int} ) where {N}
54+ function Base.:- (i:: LatticePoint{N} , j:: NTuple{N, Int} ) where {N}
5555 return LatticePoint (i. coordinates .- j, i. lattice)
5656end
5757Base.:- (i:: LatticePoint{1} , j:: Int ) = LatticePoint (i. coordinates .- j, i. lattice)
58- function Base.:- (i:: NTuple{N,Int} , j:: LatticePoint{N} ) where {N}
58+ function Base.:- (i:: NTuple{N, Int} , j:: LatticePoint{N} ) where {N}
5959 return LatticePoint (i .- j. coordinates, j. lattice)
6060end
6161Base.:- (i:: Int , j:: LatticePoint{1} ) = LatticePoint (i .- j, j. lattice)
6262
63- Base. isless (i:: L , j:: L ) where {L<: LatticePoint } = linearize_index (i) < linearize_index (j)
64- function Base. isfinite (:: Union{LatticePoint{N,G},Type{<:LatticePoint{N,G}}} ) where {N,G}
63+ Base. isless (i:: L , j:: L ) where {L <: LatticePoint } = linearize_index (i) < linearize_index (j)
64+ function Base. isfinite (:: Union{LatticePoint{N, G}, Type{<:LatticePoint{N, G}}} ) where {N, G}
6565 return isfinite (G)
6666end
67- latticetype (:: Union{LatticePoint{N,G},Type{<:LatticePoint{N,G}}} ) where {N,G} = G
67+ latticetype (:: Union{LatticePoint{N, G}, Type{<:LatticePoint{N, G}}} ) where {N, G} = G
0 commit comments