Tensor Segments Along an Arbitrary Axis #
Packing is concatenation along one tensor axis, while unpacking is the corresponding family of half-open slices. This module defines those operations independently of pattern syntax and scalar algebra.
Coord.appendEquiv separates a coordinate into coordinates for a shape leadingShape
and trailingShape. The tensor operations use it to isolate the selected axis:
Rep.concatenateAxisconcatenates two tensors;Rep.sliceAxisreads one checked half-open interval;Rep.concatenateAxesconcatenates a finite dependent family; andRep.splitAxispartitions one axis according to a list of lengths.
The two family operations are proved mutually inverse, including empty families and zero-length segments. Consequently these primitives preserve all scalar values without requiring an operation on the scalar type.
Identify an index in a list of consecutive segments with its index in the concatenated interval.
The first component selects a segment and the second selects a position inside that segment. Mathlib's dependent finite-sum equivalence places the segments in list order, including segments of length zero.
Instances For
Separate a coordinate of an appended shape into its leadingShape and trailingShape coordinates.
The equivalence follows the recursive shape representation, so it preserves the usual outermost-first coordinate order.
Instances For
Concatenate two tensors along the axis following leadingShape.
The dimensions in leadingShape and trailingShape are shared. Coordinates below
leftLength read the left tensor, and the remaining coordinates read the
right tensor after subtracting leftLength.
Instances For
Read a checked half-open interval from the axis following leadingShape.
The output coordinate i reads source coordinate start + i. The bound
proof prevents out-of-range slicing before tensor execution.
Instances For
The first slice of a binary concatenation recovers the left tensor.
The second slice of a binary concatenation recovers the right tensor.
Concatenating two adjacent slices that partition an axis recovers the source tensor.
Identify a component coordinate in a segmented tensor family with its coordinate after concatenation along the selected axis.
Leading and trailing coordinates are preserved. The local selected-axis
coordinate is placed in the component's consecutive segment by
segmentIndexEquiv.
Instances For
Concatenate a dependent family of tensors along one shared axis.
The family may be empty. In that case the result has a zero-length selected axis and therefore no coordinates.
Instances For
Split one tensor axis into a dependent family with the requested lengths.
Each segment coordinate is sent directly to the corresponding position in
the concatenated axis. This definition shares the same coordinate
equivalence as concatenateAxes.
Instances For
Splitting a concatenated family recovers every original segment.
Concatenating every segment of a complete split recovers the source tensor.