Mappings from 1D to 2D lattices
This module provides functions for mappings between 1D points and 2D coordinates in various space-filling curves: zigzag, snake, and Hilbert curves. They are designed to work with 0-based indexing for points and coordinates. For the zigzag and snake curve mappings, the 1D points are counted from 0 to (nx * ny) - 1, and the coordinates (x, y) range from 0 to nx - 1 (ny - 1). For the Hilbert curve mappings, the 1D points are counted from 0 to (n**2) - 1, and the coordinates (x, y) range from 0 to n - 1. The functions provide the option to start indexing from 1 by adding/subtracting 1 as needed.
- ed_lgt.tools.mappings_1D_2D.coords(x, y)[source]
- ed_lgt.tools.mappings_1D_2D.inverse_zig_zag(lvals, coords)[source]
Inverse zigzag curve mapping (from d coords to the 1D points).
NOTE: Given the sizes of a multidimensional lattice, the d-dimensional coords are supposed to start from 0 and have to be smaller than each lattice dimension Correspondingly, the points of the zigzag curve start from 0.
- Parameters:
lvals (list or tuple of int) – The dimensions of the lattice in each direction (Lx, Ly, Lz, …)
coords (list or tuple of int) – Multi-dimensional coordinates of the 1D point of the ZigZag curve in the lattice (x, y, z, …).
- Returns:
1D point of the zigzag curve
- Return type:
int
- ed_lgt.tools.mappings_1D_2D.zig_zag(lvals, d)[source]
Given the 1d point at position d of the zigzag curve in a discrete lattice with arbitrary dimensions, it provides the corresponding multidimensional coordinates of the point.
NOTE: d has to be smaller than the total number of lattice sites
- Parameters:
lvals (list or tuple of int) – The dimensions of the lattice in each direction (Lx, Ly, Lz, …)
d (int) – Point of a 1D curve covering the multi-dimensional lattice.
- Returns:
Multi-dimensional coordinates of the 1D point of the ZigZag curve in the lattice (x, y, z, …).
- Return type:
tuple of int