Index arithmetic for binary matrix transposition #
The transposed source index stays inside the requested rectangle, and swapping dimensions reverses the index map. Consequently two transposes retain precisely the rectangle, adding false entries when the input is short.
theorem
Complexity.BitPolynomial.Internal.transposeBits_transposeBits
(rows cols : ℕ)
(bits : List Bool)
:
transposeBits cols rows (transposeBits rows cols bits) = List.map (fun (k : ℕ) => bits[k]?.getD false) (List.range (rows * cols))
theorem
Complexity.BitPolynomial.Internal.transposeEval_pair
(bits rowsWord colsWord : List Bool)
:
transposeEval (pair (pair bits rowsWord) colsWord) = transposeBits rowsWord.length colsWord.length bits