Skip to content

Make LinearRecurrenceFormula truly O(1) memory in NaturalArray formula path; bump to v0.8.4#90

Merged
DanexCodr merged 3 commits into
mainfrom
copilot/improve-linear-recurrence-formula
Apr 12, 2026
Merged

Make LinearRecurrenceFormula truly O(1) memory in NaturalArray formula path; bump to v0.8.4#90
DanexCodr merged 3 commits into
mainfrom
copilot/improve-linear-recurrence-formula

Conversation

Copilot AI commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Linear recurrence formulas were still carrying range-sized precomputation overhead, unlike the now O(1) conditional formula path. This PR removes recurrence precompute tables and aligns recurrence formula composition with the same constant-space, newer-over-older model.

  • Linear recurrence memory model

    • Removed eager range-table precomputation from LinearRecurrenceFormula (buildPrecomputedValues path).
    • Kept direct evaluation via recurrence math per lookup, avoiding storage proportional to covered index span.
  • Recurrence composition parity with conditional formulas

    • Added LinearRecurrenceFormula.compose(newer, older).
    • Added composite-aware contains(...) and evaluate(...) so recurrence formulas resolve in newer-first order over overlapping ranges.
    • Updated NaturalArray.addLinearRecurrenceFormula(...) to merge into a single composed recurrence formula instead of appending unbounded entries.
  • NaturalArray recurrence cache cleanup

    • Removed per-index recurrence-formula index cache usage, eliminating linear growth in metadata from random recurrence reads.
  • Release/version updates

    • Bumped repository version to 0.8.4.
    • Added v0.8.4 changelog entry focused on the recurrence O(1) improvement.
    • Updated visible version strings to 0.8.4 in README/docs/install fallback.

Example (new composition model):

if (linearRecurrenceFormulas.isEmpty()) {
    linearRecurrenceFormulas.add(formula);
} else {
    int lastIndex = linearRecurrenceFormulas.size() - 1;
    LinearRecurrenceFormula current = linearRecurrenceFormulas.get(lastIndex);
    LinearRecurrenceFormula merged = LinearRecurrenceFormula.compose(formula, current);
    linearRecurrenceFormulas.set(lastIndex, merged);
}

Copilot AI and others added 3 commits April 12, 2026 12:59
@DanexCodr DanexCodr marked this pull request as ready for review April 12, 2026 13:40
@DanexCodr DanexCodr merged commit 4b6caf1 into main Apr 12, 2026
@DanexCodr DanexCodr deleted the copilot/improve-linear-recurrence-formula branch April 12, 2026 13:42
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