The Miller indices and the storage.

TODO: Offsets are not well tested.

Each Miller index corresponds to a storage indices. For example, for an even and centered grid, the correspondance is

miller:   -3 -2 -1  0  1  2  
standard:  4  5  6  1  2  3  

The Miller indices are convenient to use, whereas the standard indices are suited for FFT. The correspondance is continuous, so iterations should have cache locality.

For off-centered grids, with an offset of 1, we effectively translate the orbital to the right by one.

miller:    -4 -3 -2 -1  0  1 
standard:   5  6  1  2  3  4

For an odd grid, without an offset.

miller:   -3 -2 -1  0  1  2  3
standard:  5  6  7  1  2  3  4

With an offset, we have

miller:   -4 -3 -2 -1  0  1  2
standard:  5  6  7  1  2  3  4

In summary, gor an even grid, the indices with offsets go from -n+1-o to n-o. For an odd grid, the indices with offsets go from -n-o to n-o.

Conversion

WTP.miller_to_standard β€” Function
miller_to_standard(sizes, indices, offsets)

Convert a set of miller indices to standard indices.

Example:

julia> miller_to_standard((4, 4, 4), (0, 0, 0), (0, 0, 0))
(1, 1, 1)
julia> miller_to_standard(sizes, (-3, -1, 1), (1, 0, 0))
(3, 4, 2)
source
WTP.standard_to_miller β€” Function
standard_to_miller(sizes, indices, offsets)

Convert a set of standard indices to miller indices.

Example:

julia> standard_to_miller(sizes, (1, 1, 1), (0, 0, 0))
(0, 0, 0)
julia> standard_to_miller(sizes, (3, 4, 2), (1, 0, 0))
(-3, -1, 1)
source
WTP.one_to_three β€” Function
one_to_three(i, sizes)

Convert 1D indices to 3D ones.

The conversion is best characterized as the following relation.

reshape(A, prod(sizes))[i] == A[one_to_three(i, sizes)...]

That is, indexing with a 3D index and a 1D index should be identical if the two indices are mapped to each other with one_to_three.

Example:

julia> one_to_three(5, (4, 4, 4))
(1, 2, 1)
source
WTP.three_to_one β€” Function
three_to_one(x, y, z, sizes)

Convert 3D indices to 1D ones.

The conversion is best characterized as the following relation.

reshape(A, prod(sizes))[three_to_one(i, j, k, sizes)] = A[i, j, k]

Example:

julia> three_to_one(1, 2, 1, (4, 4, 4))
5
source