Skip to content

docs(book): Add the eunomia datatype-law book (outline) - #51

Closed
ryancinsight wants to merge 1 commit into
mainfrom
codex/eunomia-book
Closed

docs(book): Add the eunomia datatype-law book (outline)#51
ryancinsight wants to merge 1 commit into
mainfrom
codex/eunomia-book

Conversation

@ryancinsight

@ryancinsight ryancinsight commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closes the outline increment of ATLAS-BOOK-001 for the eunomia package (provider-first book sequencing #1).

  • docs/book/: book.toml, SUMMARY.md (full outline), README intro, 14 outline chapters + 3 example outlines
  • .github/workflows/book-pages.yml: thin caller of the Atlas shared book-pages workflow (ADR 0035)
  • Verified locally: mdbook build green, check_mdbook_links.py FILE_MISSING 0, no placeholder chapters
  • The Atlas docs.yml wiring lands with the eunomia gitlink advance (same-session atlas-meta change)

High-level PR Summary

This PR establishes the complete mdBook documentation structure for the eunomia datatype-law package. It adds a full outline covering the numeric scalar vocabulary (IEEE-754 formats, complex numbers, integer types), element and field traits for generic programming, conversion and casting semantics, byte layout contracts, packed sub-byte formats, and the crate's position in the Atlas stack. The book includes 14 outline chapters organized into six parts, three example outlines, and a GitHub Actions workflow that publishes the book to GitHub Pages using the Atlas shared book-pages workflow pattern.

⏱️ Estimated Review Time: 30-90 minutes

💡 Review Order Suggestion
Order File Path
1 docs/book/README.md
2 docs/book/SUMMARY.md
3 docs/book/book.toml
4 docs/book/scalar_types.md
5 docs/book/integer_types.md
6 docs/book/complex_numbers.md
7 docs/book/numeric_element.md
8 docs/book/float_element.md
9 docs/book/scalar_fields.md
10 docs/book/unit_scalar.md
11 docs/book/cast_lattice.md
12 docs/book/conversion_kernel.md
13 docs/book/byte_layout.md
14 docs/book/packed_formats.md
15 docs/book/relative_equality.md
16 docs/book/element_operations.md
17 docs/book/stack_position.md
18 docs/book/examples/choosing_precision.md
19 docs/book/examples/complex_arithmetic.md
20 docs/book/examples/rounding_behaviour.md
21 .github/workflows/book-pages.yml

Need help? Join our Discord

Summary by CodeRabbit

  • New Features
    • Added a comprehensive mdBook covering Eunomia’s scalar types, numeric traits, conversions, layouts, packed formats, complex numbers, and arithmetic semantics.
    • Added examples and guidance for precision selection, rounding behavior, and complex arithmetic.
    • Added documentation for layout safety, unit scaling, relative equality, and the Atlas stack’s datatype foundation.
    • Added automated deployment of the documentation site for updates, pull requests, and manual runs.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Added a complete mdBook for eunomia’s datatype documentation. The change defines the book structure, documents scalar and numeric abstractions, adds planned examples, configures HTML output, and deploys the generated book through GitHub Pages.

Changes

Eunomia mdBook

Layer / File(s) Summary
Book setup and navigation
docs/book/book.toml, docs/book/README.md, docs/book/SUMMARY.md
Adds mdBook metadata, rendering settings, an overview, and a six-part table of contents.
Scalar and layout foundations
docs/book/scalar_types.md, docs/book/integer_types.md, docs/book/complex_numbers.md, docs/book/byte_layout.md, docs/book/packed_formats.md
Documents scalar formats, integer and complex types, layout traits, and packed representations.
Numeric abstractions and operations
docs/book/numeric_element.md, docs/book/float_element.md, docs/book/cast_lattice.md, docs/book/conversion_kernel.md, docs/book/scalar_fields.md, docs/book/relative_equality.md, docs/book/element_operations.md, docs/book/unit_scalar.md
Documents numeric traits, conversion and casting, scalar fields, equality, element operations, transcendental functions, and unit scaling.
Examples, stack position, and publishing
docs/book/examples/*, docs/book/stack_position.md, .github/workflows/book-pages.yml
Adds three planned example chapters, documents Atlas Stack boundaries, and deploys the mdBook on GitHub Pages.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of the eunomia datatype-law book outline, which is the main change in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/eunomia-book

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/book/book.toml`:
- Around line 16-18: Update the [output.html] configuration in book.toml to set
no-section-label = true, preserving the manually numbered chapter titles in
docs/book/SUMMARY.md without duplicate automatic labels.

In `@docs/book/byte_layout.md`:
- Around line 5-13: Update the “Zeroable” and “Pod” section in
docs/book/byte_layout.md to separate their safety contracts: require only Pod
when viewing an existing value as bytes via bytes_of, require Zeroable for
all-zero construction via Zeroable::zeroed, and state that APIs performing both
operations require both traits.

In `@docs/book/examples/choosing_precision.md`:
- Around line 8-17: Update the precision comparison in the documented example to
call the metric reference error rather than round-trip error, and define the
reproducible workload by naming the input series, term count, summation order,
and f64 reference calculation. Ensure the table values are explicitly presented
as measurements for that workload, or relabel the table as illustrative
precision limits instead of fixed measured results.

In `@docs/book/examples/complex_arithmetic.md`:
- Around line 17-24: Update the byte round-trip outline in complex_arithmetic.md
to state that external GPU/FFI buffers must have a length aligned to a Complex64
element multiple and a suitably aligned pointer, or use an unaligned
single-element read. Also add this alignment precondition and its handling to
the DoR example.

In `@docs/book/examples/rounding_behaviour.md`:
- Around line 20-23: Update the rounding behaviour documentation to define
“small powers of two” as values representable as finite F16 numbers, and limit
exact round-trip assertions to that range. Add separate examples for underflow
and overflow that assert their expected rounded results rather than exact
round-trips.
- Around line 24-25: Update the rounding-behaviour outline to use a consistent
error metric: compare absolute error with 0.5 * ulp(reference) for normal
values, and explicitly define separate handling for zero and subnormal values;
alternatively, specify a mathematically derived relative bound instead of the
half-ulp comparison.

In `@docs/book/integer_types.md`:
- Around line 30-33: Update the “Source construction” guidance to remove the
invalid `v as Self` pattern for I8, I16, and I32 wrappers. Describe constructing
each tuple wrapper from a cast inner primitive, or using the existing
CastFrom<i32> conversion, while preserving the guidance about explicit
precision-correct construction.

In `@docs/book/packed_formats.md`:
- Around line 5-24: Update the opening documentation in the packed module
description to limit the packing and 2× memory-reduction claims to the 4-bit
formats F4 and Bf4. Describe F8 and Bf8 as already occupying one full u8 and
distinguish their format conversion or unpacking support from 4-bit packing;
keep the listed APIs and archival details unchanged.

In `@docs/book/README.md`:
- Around line 16-33: Update the “What it does not own” section to remove the
contradiction with the documented conversion kernel, COW buffers, and
SIMD-accelerated unpack. Narrow the exclusions to general-purpose computation,
allocation, scheduling, backend, and execution concerns, while explicitly
preserving the datatype-local storage and conversion exceptions already listed
above.
- Around line 51-54: Update the documentation paragraph around the `examples/`
reference to describe them as “planned example outlines” rather than “worked
examples,” while preserving the surrounding explanation and outline-edition
status.

In `@docs/book/scalar_fields.md`:
- Around line 11-12: Update the complex-number description in scalar_fields.md
to distinguish representation from arithmetic: state that the pair (re, im) is
the storage representation, while only addition and scalar operations are
componentwise; describe multiplication and division as following complex-field
rules. Remove any wording that implies componentwise complex multiplication.
- Around line 39-41: Update the “Ordered real scalars” description in
scalar_fields.md to call the ordering provided by PartialOrd a “partial order”
instead of a “total order,” while leaving the rest of the documented RealField
behavior unchanged.

In `@docs/book/scalar_types.md`:
- Around line 44-49: Qualify the bytemuck trait claim in
docs/book/scalar_types.md lines 44-49 so it states that Pod/Zeroable
implementations are available only with the bytemuck feature, while keeping the
unconditional native guarantees distinct. Apply the same qualification to the
Complex<T> claim in docs/book/complex_numbers.md lines 34-36.
- Around line 5-12: Update the floating-point equation description in the scalar
types documentation to explicitly scope it to normal finite values, and avoid
claiming that (E, M, B) alone determines all representable values unless
subnormals, NaN, and infinity are also documented. Preserve the existing
definitions for sign, significand, and exponent within the normal finite case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 00dc8d73-f8a1-4dad-b4ac-7581783292d4

📥 Commits

Reviewing files that changed from the base of the PR and between 98f8537 and 7aff3c1.

📒 Files selected for processing (21)
  • .github/workflows/book-pages.yml
  • docs/book/README.md
  • docs/book/SUMMARY.md
  • docs/book/book.toml
  • docs/book/byte_layout.md
  • docs/book/cast_lattice.md
  • docs/book/complex_numbers.md
  • docs/book/conversion_kernel.md
  • docs/book/element_operations.md
  • docs/book/examples/choosing_precision.md
  • docs/book/examples/complex_arithmetic.md
  • docs/book/examples/rounding_behaviour.md
  • docs/book/float_element.md
  • docs/book/integer_types.md
  • docs/book/numeric_element.md
  • docs/book/packed_formats.md
  • docs/book/relative_equality.md
  • docs/book/scalar_fields.md
  • docs/book/scalar_types.md
  • docs/book/stack_position.md
  • docs/book/unit_scalar.md

Comment thread docs/book/book.toml
Comment on lines +16 to +18
[output.html]
no-section-label = false
mathjax-support = true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repository files relevant to mdBook:"
git ls-files | rg '(^|/)book\.toml$|(^|/)SUMMARY\.md$|docs/book/' | sed -n '1,120p'

echo
echo "docs/book/book.toml:"
if [ -f docs/book/book.toml ]; then
  cat -n docs/book/book.toml
fi

echo
echo "docs/book/SUMMARY.md (first 180 lines):"
if [ -f docs/book/SUMMARY.md ]; then
  sed -n '1,180p' docs/book/SUMMARY.md | cat -n
fi

echo
echo "Search no-section-label usages:"
rg -n 'no-section-label|mathjax-support|site-url' .

Repository: ryancinsight/eunomia

Length of output: 3565


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Available mdbook version/tooling:"
command -v mdbook || true
mdbook --version 2>/dev/null || true

echo
echo "Check for local mdbook/docs tooling indicators:"
git ls-files | rg '(^|/)(cargo\.lock|package\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|\.github/workflows/.*)' | sed -n '1,120p'

Repository: ryancinsight/eunomia

Length of output: 309


🌐 Web query:

mdBook output.html no-section-label true disable section labels

💡 Result:

To disable numeric section labels in your mdBook output, you should add the following configuration to your book.toml file under the [output.html] table [1][2]: [output.html] no-section-label = true Setting no-section-label to true removes numeric labels (such as "1." or "2.1") from the table of contents [1][3]. By default, this option is false [1][2]. Note: Development in the mdBook repository includes plans to rename this configuration key to section-label-toc with a inverted default behavior (defaulting to true) to improve clarity [4]. However, as of the current standard documentation, no-section-label = true remains the correct directive to disable these labels [1][2][5].

Citations:


Disable automatic section labels or remove the manual numbers.

docs/book/SUMMARY.md uses numbered chapter titles like 1. Floating-Point ScalarTypes, and no-section-label = false enables mdBook’s numeric section labels in the table of contents. This creates duplicate numbering. Set no-section-label = true if the manual numbers are intentional.

Proposed fix. ```diff -no-section-label = false +no-section-label = true ```
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[output.html]
no-section-label = false
mathjax-support = true
[output.html]
no-section-label = true
mathjax-support = true
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/book.toml` around lines 16 - 18, Update the [output.html]
configuration in book.toml to set no-section-label = true, preserving the
manually numbered chapter titles in docs/book/SUMMARY.md without duplicate
automatic labels.

Comment thread docs/book/byte_layout.md
Comment on lines +5 to +13
Reinterpreting a value as raw bytes is safe only when the type's layout
permits it. Two facts must hold:

1. **Zeroable** — the all-zero bit pattern is a valid, inhabited value
(this excludes types with a validity niche at zero, such as `NonZeroU32`
or `&T`).
2. **Pod** (plain-old-data) — every bit pattern of `size_of::<Self>()`
bytes is a valid `Self`, and the type carries no padding or invalid
representations.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Separate the Pod and Zeroable safety contracts.

bytes_of accepts only T: Pod in crates/eunomia/src/layout/bytes.rs:36-40; Zeroable is not required to view an existing value as bytes. Zeroable is required for all-zero construction through Zeroable::zeroed. State these as separate requirements, and require both only for APIs that perform both operations.

Proposed wording
-Reinterpreting a value as raw bytes is safe only when the type's layout
-permits it. Two facts must hold:
+Viewing an existing value as raw bytes requires a `Pod` layout.
+Creating a value from all-zero bytes requires `Zeroable`. APIs that perform
+both operations require both contracts.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/byte_layout.md` around lines 5 - 13, Update the “Zeroable” and
“Pod” section in docs/book/byte_layout.md to separate their safety contracts:
require only Pod when viewing an existing value as bytes via bytes_of, require
Zeroable for all-zero construction via Zeroable::zeroed, and state that APIs
performing both operations require both traits.

Comment on lines +8 to +17
The precision trade-off across the eunomia scalar vocabulary: computing the
same accumulated sum in `F32`, `F64`, `F16`, and `Bf16`, and reporting the
round-trip error against the `f64` reference.

| Scalar | Storage | Relative error vs `f64` |
|---|---|---|
| `F64` | `u64` | reference |
| `F32` | `u32` | ~1e-7 (single precision) |
| `F16` (binary16) | `u16` | ~1e-3 (half precision) |
| `Bf16` (E8M7) | `u16` | ~4e-3 (bfloat range) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Define the measured error before publishing fixed values.

Lines 8-10 describe an accumulated-sum comparison but call the result “round-trip error”. Lines 12-17 provide fixed values without a named series, term count, summation order, or a distinction between measured workload error and format precision. Rename the metric to reference error and define the workload, or label the table as illustrative precision limits. Otherwise the planned example cannot reproduce the table.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/examples/choosing_precision.md` around lines 8 - 17, Update the
precision comparison in the documented example to call the metric reference
error rather than round-trip error, and define the reproducible workload by
naming the input series, term count, summation order, and f64 reference
calculation. Ensure the table values are explicitly presented as measurements
for that workload, or relabel the table as illustrative precision limits instead
of fixed measured results.

Comment on lines +17 to +24
- `bytemuck::cast_slice` round-trip through raw bytes (chapter 10)

## Outline

- Build a complex phasor `re + im·i` from real measurements
- Apply a complex product and quotient, checking results with
`assert_relative_eq!`
- Cast a slice of `Complex64` to bytes and back via the `Pod` contract

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 5 \
  'cast_slice|try_cast_slice|pod_read_unaligned|unaligned|Complex64|Pod|Zeroable' \
  crates/eunomia docs/adr docs/book

Repository: ryancinsight/eunomia

Length of output: 50378


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== book_complex_arithmetic.rs =="
if [ -f crates/eunomia/examples/book_complex_arithmetic.rs ]; then
  cat -n crates/eunomia/examples/book_complex_arithmetic.rs
else
  echo "crate example file not found"
fi

echo
echo "== relevant layout definitions =="
sed -n '1,220p' crates/eunomia/src/types/complex/mod.rs | cat -n
sed -n '40,110p' crates/eunomia/src/types/mod.rs | cat -n

echo
echo "== complex numeric assertions/search =="
rg -n -C 3 'size_of::<Complex64>|align_of::<Complex64>|Complex<f64>|Complex64>::(ZERO|ONE)|pod_read_unaligned|try_cast_slice|cast_slice' crates/eunomia/src crates/eunomia/examples || true

Repository: ryancinsight/eunomia

Length of output: 20957


State the alignment precondition for the byte round-trip.

cast_slice checks element length and pointer alignment, so external GPU/FFI byte buffers need an aligned Complex64-multiple length or an unaligned single-element read. Add this precondition to the outline and cover it in the DoR example.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/examples/complex_arithmetic.md` around lines 17 - 24, Update the
byte round-trip outline in complex_arithmetic.md to state that external GPU/FFI
buffers must have a length aligned to a Complex64 element multiple and a
suitably aligned pointer, or use an unaligned single-element read. Also add this
alignment precondition and its handling to the DoR example.

Comment on lines +20 to +23
- Convert `1.0f32` and small powers of two, asserting exact
round-trips (`0x3C00` for `F16`)
- Feed exact ties (values exactly midway between two representable
values) and show the even-significand choice

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Limit exact-round-trip assertions to representable values.

“Small powers of two” is underspecified. Values outside the finite F16 range do not round-trip exactly. State the range covered by the exact assertions, and test underflow and overflow as separate expected-rounding cases.

Suggested wording
- Convert `1.0f32` and small powers of two, asserting exact
-   round-trips (`0x3C00` for `F16`)
+ Convert `1.0f32` and powers of two in the documented representable
+   range, asserting exact round-trips (`0x3C00` for `F16`)
+   and testing underflow and overflow separately.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Convert `1.0f32` and small powers of two, asserting exact
round-trips (`0x3C00` for `F16`)
- Feed exact ties (values exactly midway between two representable
values) and show the even-significand choice
- Convert `1.0f32` and powers of two in the documented representable
range, asserting exact round-trips (`0x3C00` for `F16`)
and testing underflow and overflow separately.
- Feed exact ties (values exactly midway between two representable
values) and show the even-significand choice
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/examples/rounding_behaviour.md` around lines 20 - 23, Update the
rounding behaviour documentation to define “small powers of two” as values
representable as finite F16 numbers, and limit exact round-trip assertions to
that range. Add separate examples for underflow and overflow that assert their
expected rounded results rather than exact round-trips.

Comment thread docs/book/README.md
Comment on lines +51 to +54
Each chapter maps the theory onto the crate's public API, and worked examples
in `examples/` show the abstractions in use. This is the outline edition: the
chapter structure is complete, and the chapters themselves land as DoR items
per subsystem.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Describe the example files according to their current status.

This paragraph calls the files in examples/ worked examples, but the PR adds outline chapters. Replace “worked examples” with “planned example outlines” until those chapters contain worked code or results.

Proposed wording
- in `examples/` show the abstractions in use.
+ in `examples/` outline the planned abstractions and use cases.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Each chapter maps the theory onto the crate's public API, and worked examples
in `examples/` show the abstractions in use. This is the outline edition: the
chapter structure is complete, and the chapters themselves land as DoR items
per subsystem.
Each chapter maps the theory onto the crate's public API, and planned example outlines
in `examples/` outline the planned abstractions and use cases. This is the outline edition: the
chapter structure is complete, and the chapters themselves land as DoR items
per subsystem.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/README.md` around lines 51 - 54, Update the documentation paragraph
around the `examples/` reference to describe them as “planned example outlines”
rather than “worked examples,” while preserving the surrounding explanation and
outline-edition status.

Comment on lines +11 to +12
For complex numbers the same operations exist, but the order does not — the
field is the pair `(re, im)` with componentwise arithmetic.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not describe complex multiplication as componentwise.

Complex<T> uses a component pair for representation, but only addition and scalar operations are componentwise. Multiplication and division follow complex-field rules. Update this sentence to avoid implying (a + bi)(c + di) = ac + bdi.

Proposed wording
- field is the pair `(re, im)` with componentwise arithmetic.
+ field is represented by the pair `(re, im)`; addition is componentwise, while multiplication and division follow complex-field rules.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
For complex numbers the same operations exist, but the order does not — the
field is the pair `(re, im)` with componentwise arithmetic.
For complex numbers the same operations exist, but the order does not — the
field is represented by the pair `(re, im)`; addition is componentwise, while multiplication and division follow complex-field rules.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/scalar_fields.md` around lines 11 - 12, Update the complex-number
description in scalar_fields.md to distinguish representation from arithmetic:
state that the pair (re, im) is the storage representation, while only addition
and scalar operations are componentwise; describe multiplication and division as
following complex-field rules. Remove any wording that implies componentwise
complex multiplication.

Comment on lines +39 to +41
- **Ordered real scalars.** `RealField` adds the total order (`PartialOrd`),
the mathematical constants, and sign helpers to the `FloatElement` math
surface. Implemented for `f32`/`f64` (and the reduced float wrappers).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 6 'trait RealField|PartialOrd|fn nan|impl.*RealField' \
  docs/book/scalar_fields.md crates/eunomia

Repository: ryancinsight/eunomia

Length of output: 22158


🌐 Web query:

Rust std::cmp::PartialOrd NaN not ordered documentation total_cmp

💡 Result:

In Rust, floating-point types (f32 and f64) only implement the PartialOrd trait rather than the Ord trait because floating-point numbers do not satisfy the requirements of a total order [1][2]. Specifically, the IEEE 754 standard specifies that NaN (Not-a-Number) values are not equal to themselves and are not comparable to other numbers, which violates the reflexivity required for a total order [3][4]. Because PartialOrd is used, standard comparison operators like <, >, <=, and >= behave according to a strict or non-strict partial order where comparisons involving NaN return false or None [3][5]. For example, f64::NAN <= f64::NAN is false [3]. To enable sorting and other operations that require a total order, Rust provides the total_cmp method on both f32 and f64 [4][6]. This method implements the totalOrder predicate defined in IEEE 754-2008, providing a consistent ordering for all floating-point values, including NaNs, negative zeros, and positive zeros [4][7]. The ordering defined by total_cmp is [4][6][8]: 1. Negative quiet NaN 2. Negative signaling NaN 3. Negative infinity 4. Negative numbers 5. Negative subnormal numbers 6. Negative zero 7. Positive zero 8. Positive subnormal numbers 9. Positive numbers 10. Positive infinity 11. Positive signaling NaN 12. Positive quiet NaN Note that the ordering provided by total_cmp does not always align with the standard PartialOrd and PartialEq implementations (e.g., total_cmp distinguishes between negative and positive zero) [4][6].

Citations:


Use PartialOrd terminology accurately.

PartialOrd is a partial-order trait. f32 and f64 NaN values are unordered, while Rust’s total ordering for floats is exposed via total_cmp. Replace “total order” with “partial order”.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/scalar_fields.md` around lines 39 - 41, Update the “Ordered real
scalars” description in scalar_fields.md to call the ordering provided by
PartialOrd a “partial order” instead of a “total order,” while leaving the rest
of the documented RealField behavior unchanged.

Comment thread docs/book/scalar_types.md
Comment on lines +5 to +12
A floating-point number is a finite approximation to a real value, stored as

$$x = (-1)^{s} \cdot m \cdot 2^{e}$$

with a sign bit `s`, a significand `m` of width `M` bits (plus the implicit
leading bit in normal numbers), and an exponent `e` biased by a format-
specific constant `B` over `E` bits. The set of representable values is
determined entirely by the triple `(E, M, B)`:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Scope the floating-point equation to normal finite values.

The equation does not represent subnormals, NaN, or infinity. NumericElement exposes NAN and INFINITY in crates/eunomia/src/traits/numeric.rs:18-172. Label this equation as the normal finite case, or document the missing representations before claiming that (E, M, B) fully determines the complete value set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/scalar_types.md` around lines 5 - 12, Update the floating-point
equation description in the scalar types documentation to explicitly scope it to
normal finite values, and avoid claiming that (E, M, B) alone determines all
representable values unless subnormals, NaN, and infinity are also documented.
Preserve the existing definitions for sign, significand, and exponent within the
normal finite case.

Comment thread docs/book/scalar_types.md
Comment on lines +44 to +49
- **Float-semantic comparisons.** `PartialEq`/`PartialOrd` for `F16`/`Bf16`
compare through `f32`, not bitwise, so `1.0` and `0x3C00` compare equal.
- **Exact layout.** `const _` assertions pin each type's size and alignment,
and every type is `bytemuck::Pod`/`Zeroable` (§10).
- **Precision-correct construction.** `FloatElement::from_f64` (on `F16`/
`Bf16`) rounds through the native kernel rather than a truncating `as` cast.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Apply the bytemuck feature gate consistently.

The native Pod/Zeroable guarantees are unconditional, but the bytemuck implementations are feature-gated in docs/book/byte_layout.md.

  • docs/book/scalar_types.md#L44-L49: qualify the bytemuck trait claim with the feature.
  • docs/book/complex_numbers.md#L34-L36: apply the same qualification to Complex<T>.
📍 Affects 2 files
  • docs/book/scalar_types.md#L44-L49 (this comment)
  • docs/book/complex_numbers.md#L34-L36
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/book/scalar_types.md` around lines 44 - 49, Qualify the bytemuck trait
claim in docs/book/scalar_types.md lines 44-49 so it states that Pod/Zeroable
implementations are available only with the bytemuck feature, while keeping the
unconditional native guarantees distinct. Apply the same qualification to the
Complex<T> claim in docs/book/complex_numbers.md lines 34-36.

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.

1 participant