Skip to content

Complete recurrence matrix-exponentiation optimization and harden large-branch/update execution paths#103

Merged
DanexCodr merged 4 commits into
mainfrom
copilot/fix-incremental-lazy-branching
Apr 14, 2026
Merged

Complete recurrence matrix-exponentiation optimization and harden large-branch/update execution paths#103
DanexCodr merged 4 commits into
mainfrom
copilot/fix-incremental-lazy-branching

Conversation

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

This addresses the remaining third optimization plan (matrix exponentiation) and aligns it with the already landed large-scale conditional/lazy-update improvements. The recurrence fast path now avoids unnecessary matrix materialization while preserving lazy-branching and pending-update semantics at scale.

  • Matrix exponentiation fast path (recurrence evaluation)

    • Reworked recurrence evaluation in both scalar and vector formulas to apply exponentiation directly to the state vector instead of building M^k first.
    • Removes one full dense matrix accumulation path per random-access recurrence evaluation while keeping exponentiation-by-squaring behavior.
  • Files updated

    • src/main/java/cod/range/formula/LinearRecurrenceFormula.java
    • src/main/java/cod/range/formula/VectorRecurrenceFormula.java
  • Recurrence stress coverage expansion

    • Extended recurrence optimization demos to include deeper index reads and additional high-index outputs so matrix-exponentiation behavior is exercised beyond small checkpoints.
    • Added an additional simple constant-shift recurrence probe to broaden scalar recurrence coverage.
  • Files updated

    • src/main/cod/demo/src/main/test/linearrecurrenceoptimization/LinearRecurrenceOptimization.cod
    • src/main/cod/demo/src/main/test/linearrecurrenceoptimization/VectorLinearRecurrenceOptimization.cod
private AutoStackingNumber[] applyMatrixPowerToVector(AutoStackingNumber[][] base, long exp, AutoStackingNumber[] vector) {
    AutoStackingNumber[] result = Arrays.copyOf(vector, vector.length);
    AutoStackingNumber[][] current = base;
    long e = exp;
    while (e > 0) {
        if ((e & 1L) == 1L) result = multiply(current, result);
        e >>= 1;
        if (e > 0) current = multiply(current, current);
    }
    return result;
}

Copilot AI and others added 4 commits April 14, 2026 10:30
…te indexing

Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/e09efce3-65e4-4b52-b570-1f833e7bbc72

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/e09efce3-65e4-4b52-b570-1f833e7bbc72

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
…ecurrence stress tests

Agent-Logs-Url: https://github.com/DanexCodr/Coderive/sessions/666ae70e-6c69-416c-adf2-c1a2f0a942da

Co-authored-by: DanexCodr <216312766+DanexCodr@users.noreply.github.com>
@DanexCodr DanexCodr marked this pull request as ready for review April 14, 2026 15:04
@DanexCodr DanexCodr merged commit 3b5c0a9 into main Apr 14, 2026
@DanexCodr DanexCodr deleted the copilot/fix-incremental-lazy-branching branch April 14, 2026 15:05
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