| Title: | Equivalence and Alignment of Periodic Binary Weaving Drawdowns |
|---|---|
| Description: | Compares periodic binary weaving drawdowns using cyclic alignment, primitive rectangular repeats, exact canonical representations and Hamming distance on a common periodic domain. Optional reflections, axis exchange and face inversion define explicit equivalence rules. Supports collection distance matrices and duplicate grouping without requiring weaving design software. Comparisons describe binary interlacements, not fabric mechanics or cultural provenance. |
| Authors: | Mark Joshua R. Secretario [aut, cre] |
| Maintainer: | Mark Joshua R. Secretario <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-11-08 20:54:33 UTC |
| Source: | https://github.com/cran/weaveCompare |
Validate a binary weaving drawdown
as_drawdown(x)as_drawdown(x)
x |
A nonempty logical or numeric binary matrix. A weaveDraft weave_draft object is also accepted through its drawdown member. |
An integer matrix, with rows representing picks and columns ends.
as_drawdown(matrix(c(1, 0, 0, 1), 2))as_drawdown(matrix(c(1, 0, 0, 1), 2))
Keys encode primitive dimensions and row-major bits. The lexicographically smallest representation over allowed transformations and all cyclic shifts is selected. Keys are lossless strings, not cryptographic hashes.
canonical_drawdown( x, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )canonical_drawdown( x, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )
x |
A binary drawdown. |
reflect |
Allow independent reversal of rows and columns. |
transpose |
Allow axis exchange. This does not invert bits automatically. |
invert |
Allow exchange of zero and one (face inversion). |
max_work |
Maximum estimated number of cell comparisons, guarding exhaustive search. Default 5e7. Memory and runtime still depend on input. |
A single character key. Equivalence is conditional on the options.
canonical_drawdown(matrix(c(1, 0, 0, 1), 2))canonical_drawdown(matrix(c(1, 0, 0, 1), 2))
Minimizes the fraction of unequal cells over allowed transformations of y and cyclic shifts. Primitive repeats are tiled to the least common multiple of each axis, so differently sized repeats can be compared without resizing. Ties use the first transformation, then smallest row and column offsets. Both matrices must use the same pick/end and zero/one conventions.
compare_drawdowns( x, y, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )compare_drawdowns( x, y, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )
x, y
|
Binary drawdowns. |
reflect, transpose, invert
|
Transformation flags; see [canonical_drawdown()]. |
max_work |
Cell-comparison budget; see [canonical_drawdown()]. |
A list with distance, similarity, equivalent (exact zero distance), transformation, offsets applied after transformation and repeat reduction, domain dimensions, and aligned matrices x and y on that domain.
a <- matrix(c(1, 0, 0, 1), 2) compare_drawdowns(a, shift_drawdown(a, 1))$equivalenta <- matrix(c(1, 0, 0, 1), 2) compare_drawdowns(a, shift_drawdown(a, 1))$equivalent
Pairwise periodic Hamming distances
drawdown_dist( drafts, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )drawdown_dist( drafts, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )
drafts |
A nonempty list of binary drawdowns. |
reflect, transpose, invert
|
Transformation flags. |
max_work |
Cell-comparison budget per pair. |
A stats dist object. Distances ignore phase and optionally other transformations. Distinct input matrices can have zero distance. No mechanical, perceptual or cultural meaning is implied. Clustering can use stats::hclust; Ward clustering is not recommended without Euclidean checks.
a <- matrix(c(1, 0, 0, 1), 2) drawdown_dist(list(a, matrix(1, 2, 2)))a <- matrix(c(1, 0, 0, 1), 2) drawdown_dist(list(a, matrix(1, 2, 2)))
Find exact duplicate structures in a collection
duplicate_drawdowns( drafts, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )duplicate_drawdowns( drafts, reflect = FALSE, transpose = FALSE, invert = FALSE, max_work = 5e+07 )
drafts |
A nonempty list of binary drawdowns, optionally uniquely named. |
reflect, transpose, invert
|
Transformation flags. |
max_work |
Cell-comparison budget per canonicalization. |
A data frame of draft names, group numbers, first representative and canonical keys. Groups follow first occurrence, including singleton groups.
a <- matrix(c(1, 0, 0, 1), 2) duplicate_drawdowns(list(first = a, shifted = shift_drawdown(a, 1)))a <- matrix(c(1, 0, 0, 1), 2) duplicate_drawdowns(list(first = a, shifted = shift_drawdown(a, 1)))
Only exact periods dividing the observed dimensions are considered. Incomplete repeats are not inferred. Constant matrices reduce to one cell.
primitive_repeat(x)primitive_repeat(x)
x |
A binary drawdown; see [as_drawdown()]. |
An integer matrix containing the top-left primitive repeat.
primitive_repeat(matrix(rep(c(1, 0), 8), 4))primitive_repeat(matrix(rep(c(1, 0), 8), 4))
Output cell (i,j) takes input cell (i + row_shift,j + col_shift), with indices wrapped around the matrix. Positive shifts move data up/left.
shift_drawdown(x, row_shift = 0, col_shift = 0)shift_drawdown(x, row_shift = 0, col_shift = 0)
x |
A binary drawdown. |
row_shift, col_shift
|
Finite integer offsets; negative offsets allowed. |
An integer matrix of the original dimensions.
shift_drawdown(matrix(c(1, 0, 0, 0), 2), 1, 0)shift_drawdown(matrix(c(1, 0, 0, 0), 2), 1, 0)