Roe matrix-element generation¶
oracq.applications.roe
Reversible arithmetic generation of one-dimensional Euler frozen-Roe matrix elements; physical and fixed-point correctness pending verification.
- class oracq.applications.roe.Word(algebra, ref)[source]¶
Bases:
objectA word in fixed-point arithmetic expressions; overloaded operators delegate to the owning builder.
- Variables:
algebra (oracq.applications.roe.ArithmeticBuilder) – The
ArithmeticBuilderthat produced this word and emits the actual arithmetic nodes.ref (oracq.infrastructure.ir.Ref) – The register reference carrying the value.
- algebra¶
- ref¶
- class oracq.applications.roe.ArithmeticBuilder(builder, fmt)[source]¶
Bases:
objectHost-side expression builder; on finish only module calls or gates and private registers remain.
- b¶
- fmt¶
- count¶
- constants¶
- flags¶
- start¶
- local(width=None)[source]¶
Allocate a new private register for intermediate values or constants.
- Parameters:
width – Bit width; defaults to the word width of the current fixed-point format.
- Returns:
The newly allocated register reference, named
v_plus an incrementing counter.
- word(value)[source]¶
Wrap various inputs into a
Worduniformly.A
Wordis returned as-is; a register reference with apartsattribute is wrapped directly; numeric values are encoded in the current fixed-point format, and constants with the same encoding are materialized once and share one register.- Parameters:
value – A
Word, a register reference, or a numeric value encodable in the fixed-point format.- Returns:
The arithmetic word equivalent to the input.
- Return type:
- calc(kind, *args, select=None)[source]¶
Emit one fixed-point arithmetic node and return its output word.
When the same register is reused as an operand, it is first copied with XOR into a fresh register and restored after the call, supporting cases such as squaring where a value participates in its own operation; the node status register is recorded in
flagsand aggregated byfinish.- Parameters:
kind – Operation type name, e.g.
add,mul,sqrt.*args – Operands; each may be a
Word, a register, or a numeric value.select – The control bit for the
selectoperation; unused by other operations.
- Returns:
The word carrying the operation result.
- Return type:
- choose(bit, yes, no)[source]¶
Select between two words by a single control bit: value 1 picks
yesand 0 picksno.- Parameters:
bit – A one-bit control register view.
yes – The word, register or numeric value selected when the control bit is 1.
no – The word, register or numeric value selected when the control bit is 0.
- Returns:
The arithmetic word carrying the selected value.
- Return type:
- choose3(index, values)[source]¶
Select among three candidate words with a two-bit index.
- Parameters:
index – The two-bit control sequence, least significant bit first.
values – The three candidate words, corresponding to indices 0..2 in order.
- Returns:
The selected word; the result is zero when the index is 3.
- Return type:
- finish(outputs, status)[source]¶
Finalize and return the resulting operation.
Each output word is XORed into its target register; the status bits of the arithmetic nodes are bitwise-ORed into
status; the forward instructions emitted during construction are replayed in reverse viaAdjoint, erasing all intermediate values.- Parameters:
outputs – Pairs of target register and result word.
status – The two-bit register receiving the aggregated status.
- Returns:
The complete generated operation.
- Return type:
- oracq.applications.roe.roe_face(*, fmt=None, gamma=1.4, entropy_delta=0.125)[source]¶
Automatic compilation of a plain Python Roe function, keeping the existing six-field plus row and column input ABI.
- Parameters:
fmt – The fixed-point format for field values and fluxes; defaults to
FixedFormat(10, 5).gamma – Ratio of specific heats.
entropy_delta – Harten entropy fix threshold.
- Returns:
The reversible face-flux computation module auto-compiled from
frozen_roe_facewith fixed-point arithmetic.- Return type: