@@ -9,11 +9,41 @@ export Tiling, diamond, ka_diamond, dr_path
99
1010inds (N) = ((1 - N): N, (1 - N): N)
1111
12+ """
13+ Tiling(N::Int[, x::OffsetMatrix{AztecDiamonds.Edge}]; sizehint::Int = N)
14+
15+ Represents an order N diamond-shaped tiling. If `x` is not provided, it is initialized with `NONE`
16+ representing an empty tiling. The `sizehint` keyword argument may be used to preallocate a larger
17+ matrix for `x` fitting a tiling of order `sizehint` to avoid reallocations when the tiling grows.
18+
19+ The indices of `x` represent the coordinates of the diamond-shaped tiling and run from 1-N to N
20+ (though `x` is allowed to be larger as long as it contains these indices).
21+ The edges it contains can either be `UP`, `RIGHT`, or `NONE`, where `UP` represents a vertical tile
22+ covering one more tile to the top, `RIGHT` represents a horizontal tile covering one more tile to
23+ the right. `NONE` means the edge is either already covered by another tile to the bottom or left or
24+ the tiling is not fully filled yet.
25+
26+ ```jldoctest
27+ julia> t = Tiling(1)
28+ 1-order Tiling{Matrix{AztecDiamonds.Edge}}
29+
30+
31+
32+ julia> t[0, 0] = t[1, 0] = AztecDiamonds.RIGHT;
33+
34+ julia> t
35+ 1-order Tiling{Matrix{AztecDiamonds.Edge}}
36+ 🬇🬋🬋🬃
37+ 🬇🬋🬋🬃
38+ ```
39+
40+ See [`diamond`](@ref) and [`ka_diamond`](@ref) for constructing a filled tiling.
41+ """
1242struct Tiling{M <: AbstractMatrix{Edge} }
1343 N:: Int
1444 x:: OffsetMatrix{Edge, M}
1545end
16- Tiling (N:: Int ; sizehint = N) = Tiling (N, fill (NONE, inds (sizehint)))
46+ Tiling (N:: Int ; sizehint:: Int = N) = Tiling (N, fill (NONE, inds (sizehint)))
1747
1848in_diamond (N, i, j) = abs (2 i - 1 ) + abs (2 j - 1 ) ≤ 2 N
1949Base. checkbounds (:: Type{Bool} , (; N):: Tiling , i, j) = in_diamond (N, i, j)
@@ -145,7 +175,32 @@ function diamond!(t, t′, N)
145175 return t
146176end
147177
148- function diamond (N)
178+ """
179+ diamond(N::Int) -> Tiling{Matrix{AztecDiamonds.Edge}}
180+
181+ Generates a uniformally random order N diamond tiling.
182+
183+ ```jldoctest
184+ julia> using Random; Random.seed!(1);
185+
186+ julia> diamond(4)
187+ 4-order Tiling{Matrix{AztecDiamonds.Edge}}
188+ 🬇🬋🬋🬃
189+ 🬇🬋🬋🬃🬇🬋🬋🬃
190+ 🬦🬓🬦🬓🬦🬓🬦🬓🬇🬋🬋🬃
191+ 🬦🬓🬉🬄🬉🬄🬉🬄🬉🬄🬇🬋🬋🬃🬦🬓
192+ 🬉🬄🬦🬓🬦🬓🬇🬋🬋🬃🬦🬓🬦🬓🬉🬄
193+ 🬉🬄🬉🬄🬇🬋🬋🬃🬉🬄🬉🬄
194+ 🬇🬋🬋🬃🬇🬋🬋🬃
195+ 🬇🬋🬋🬃
196+ ```
197+
198+ See [`ka_diamond`](@ref) for a version that can take advantage of GPU acceleration.
199+ `ka_diamond(N, Array)` may also be faster for large N.
200+
201+ Ref [`Tiling`](@ref)
202+ """
203+ function diamond (N:: Int )
149204 t, t′ = Tiling (0 ; sizehint = N), Tiling (0 ; sizehint = N)
150205 return diamond! (t, t′, N)
151206end
0 commit comments