pow_mod_step

std.elementwise.pow_mod_step · Level L4

One step of binary exponentiation modulo m: if k is odd, multiply the result by the base; square the base; halve k. Each product is reduced modulo m at once, so nothing grows past m². The body that pow_mod runs.

acc ← acc·base mod m if k odd; base ← base² mod m; k ← ⌊k/2⌋

Signature

pow_mod_step(base: i64[n], k: i64[n], acc: i64[n], m: i64[n]) → i64[n], i64[n], i64[n]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

basei64[n]acci64[n]mi64[n]0ki64[n]2MultiplysqMultiplyprodGreaterliveModbit1FloorDivhalfModsq_mModprod_mEqualoddWherek2Wherebase2MultiplytakeWhereacc2base2i64[n]acc2i64[n]k2i64[n]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference acc*base % m if k odd; base*base % m; k // 2 in exact rational arithmetic, on all 40 test cases.
  • All 501 int64 results are exact: the error is zero.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them exact, with zero error.
Accuracy in detail
correctly rounded (the int64 nearest the exact value)
100%
bit-equal to the NumPy formula in int64
100%
largest error, in units in the last place
0

Identity

Calls
—
Called by
sha256:7cbec4d7f31ddd2ec29eb6f71631fff115dea36c870cb6250e2c1ffb94152710

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.elementwise.pow_mod_step · Ω:pow_mod_step
Pins
sha256:818507ea7b4f3632fc2aa1fa9c113c476db79f6fea9a84ce14666d927b67f624this graph alone
Evidence
sha256:4cbb40a37aa76e4acac9da89ae68dee0dd17e1fb8c53d57471d76451df44be36the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.