Skip to content

add LayoutLeft mapping and Integer trait#14

Merged
oliverlee merged 2 commits into
mainfrom
layout-left
Mar 19, 2026
Merged

add LayoutLeft mapping and Integer trait#14
oliverlee merged 2 commits into
mainfrom
layout-left

Conversation

@oliverlee

@oliverlee oliverlee commented Mar 17, 2026

Copy link
Copy Markdown
Collaborator

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.

Base automatically changed from layout-right to main March 17, 2026 23:57
@oliverlee oliverlee changed the title LayoutLeft add LayoutLeft mapping and Integer trait Mar 18, 2026
Comment thread src/internal/integer.rs
Comment thread src/layout.rs Outdated
@oliverlee oliverlee enabled auto-merge (squash) March 18, 2026 01:09
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.
@oliverlee oliverlee merged commit 071bec3 into main Mar 19, 2026
6 checks passed
@oliverlee oliverlee deleted the layout-left branch March 19, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants