add LayoutLeft mapping and Integer trait#14
Merged
Merged
Conversation
oliverlee
commented
Mar 18, 2026
oliverlee
commented
Mar 18, 2026
Add `LayoutLeft` and `LayoutLeftMapping` implementing column-major (Fortran-order) index mapping, where stride in dimension `k` is the product of extents in dimensions `0..k` (exclusive prefix product, forward order). Extract `exclusive_product_scan` to replace the ad-hoc `extents_to_strides_layout_right` function. The new implementation is generic over an `Integer` bound and parameterized by a `Direction` type tag (`Forward`/`Reverse`), dispatching to either `core::array::from_fn` or `array_from_fn_rev` to avoid an in-place reversal. `LayoutLeft` uses `Forward` and `LayoutRight` uses `Reverse`. Extract `inner_product` as a standalone helper used by both mappings in `to_memory_index`, replacing the inline `zip(...).map(...).sum()`. Add an `Integer` trait alias over `num_integer::Integer + NumAssign + Copy + Sum + Product` to give a coherent numeric concept for array dimension arithmetic, excluding floating point via `Eq` (through `num_integer::Integer`) while keeping the bound concise at call sites. Add `num-integer` and `num-traits` to crate universe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
LayoutLeftandLayoutLeftMappingimplementing column-major (Fortran-order)index mapping, where stride in dimension
kis the product of extents in dimensions0..k(exclusive prefix product, forward order).Extract
exclusive_product_scanto replace the ad-hocextents_to_strides_layout_rightfunction. The new implementation is generic over an
Integerbound and parameterizedby a
Directiontype tag (Forward/Reverse), dispatching to eithercore::array::from_fnor
array_from_fn_revto avoid an in-place reversal.LayoutLeftusesForwardandLayoutRightusesReverse.Extract
inner_productas a standalone helper used by both mappings into_memory_index, replacing the inlinezip(...).map(...).sum().Add an
Integertrait alias overnum_integer::Integer + NumAssign + Copy + Sum + Productto give a coherent numeric concept for array dimension arithmetic, excluding floating
point via
Eq(throughnum_integer::Integer) while keeping the bound concise atcall sites.
Add
num-integerandnum-traitsto crate universe.